OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [mw/] [src/] [include/] [device.h] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
#ifndef _DEVICE_H
2
#define _DEVICE_H
3
/*
4
 * Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com>
5
 *
6
 * Engine-level Screen, Mouse and Keyboard device driver API's and types
7
 *
8
 * Contents of this file are not for general export
9
 */
10
#include "mwtypes.h"                            /* public export typedefs*/
11
 
12
/* Changeable limits and options*/
13
#define ALPHABLEND      1                       /* =1 to include blending code*/
14
#define DYNAMICREGIONS  1                       /* =1 to use MWCLIPREGIONS*/
15
#define HAVEFLOAT       1                       /* =1 incl float, GdArcAngle*/
16
#define POLYREGIONS     1                       /* =1 includes polygon regions*/
17
#define ANIMATEPALETTE  0                        /* =1 animated palette test*/
18
#define FONTMAPPER      0                        /* =1 for Morten's font mapper*/
19
#define USE_ALLOCA      1                       /* alloca() is available */
20
#define EPRINTF         GdError                 /* error output*/
21
#define DPRINTF         GdErrorNull             /* debug output*/
22
 
23
/* max char height/width must be >= 16 and a multiple of sizeof(MWIMAGEBITS)*/
24
#define MAX_CHAR_HEIGHT 128                     /* maximum text bitmap height*/
25
#define MAX_CHAR_WIDTH  128                     /* maximum text bitmap width*/
26
#define MIN_MWCOORD     ((MWCOORD) -32768)      /* minimum coordinate value */
27
#define MAX_MWCOORD     ((MWCOORD) 32767)       /* maximum coordinate value */
28
#define MAX_CLIPRECTS   200                     /* max clip rects (obsolete)*/
29
 
30
typedef struct _mwscreendevice *PSD;
31
 
32
/* builtin C-based proportional/fixed font structure*/
33
typedef struct {
34
        char *          name;           /* font name*/
35
        int             maxwidth;       /* max width in pixels*/
36
        int             height;         /* height in pixels*/
37
        int             ascent;         /* ascent (baseline) height*/
38
        int             firstchar;      /* first character in bitmap*/
39
        int             size;           /* font size in characters*/
40
        MWIMAGEBITS *   bits;           /* 16-bit right-padded bitmap data*/
41
        unsigned short *offset;         /* 256 offsets into bitmap data*/
42
        unsigned char * width;          /* 256 character widths or 0 if fixed*/
43
} MWCFONT, *PMWCFONT;
44
 
45
/* draw procs associated with fonts.  Strings are [re]packed using defencoding*/
46
typedef struct {
47
        int     encoding;       /* routines expect this encoding*/
48
        MWBOOL  (*GetFontInfo)(PMWFONT pfont, PMWFONTINFO pfontinfo);
49
        void    (*GetTextSize)(PMWFONT pfont, const void *text, int cc,
50
                        MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase);
51
        void    (*GetTextBits)(PMWFONT pfont, int ch, MWIMAGEBITS *retmap,
52
                        MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase);
53
        void    (*DestroyFont)(PMWFONT pfont);
54
        void    (*DrawText)(PMWFONT pfont, PSD psd, MWCOORD x, MWCOORD y,
55
                        const void *str, int count, int flags);
56
        void    (*SetFontSize)(PMWFONT pfont, MWCOORD fontsize);
57
        void    (*SetFontRotation)(PMWFONT pfont, int tenthdegrees);
58
        void    (*SetFontAttr)(PMWFONT pfont, int setflags, int clrflags);
59
} MWFONTPROCS, *PMWFONTPROCS;
60
 
61
/* new multi-renderer font struct*/
62
typedef struct _mwfont {                /* common hdr for all font structures*/
63
        PMWFONTPROCS    fontprocs;      /* font-specific rendering routines*/
64
        MWCOORD         fontsize;       /* font height in pixels*/
65
        int             fontrotation;   /* font rotation*/
66
        int             fontattr;       /* font attributes: kerning/antialias*/
67
        /* font-specific rendering data here*/
68
} MWFONT;
69
 
70
/* fontattr flags*/
71
#define FS_FREETYPE      0x0800
72
 
73
/* builtin core font struct*/
74
typedef struct {
75
        PMWFONTPROCS    fontprocs;      /* common hdr*/
76
        MWCOORD         fontsize;
77
        int             fontrotation;
78
        int             fontattr;
79
 
80
        char *          name;           /* Microwindows font name*/
81
        PMWCFONT        cfont;          /* builtin font data*/
82
} MWCOREFONT, *PMWCOREFONT;
83
 
84
/* This structure is used to pass parameters into the low
85
 * level device driver functions.
86
 */
87
typedef struct {
88
        MWCOORD dstx, dsty, dstw, dsth, dst_linelen;
89
        MWCOORD srcx, srcy, src_linelen;
90
        void *pixels, *misc;
91
        MWPIXELVAL bg_color, fg_color;
92
        int gr_usebg;
93
} driver_gc_t;
94
 
95
/* Operations for the Blitter/Area functions */
96
#define PSDOP_COPY      0
97
#define PSDOP_COPYALL   1
98
#define PSDOP_COPYTRANS 2
99
#define PSDOP_ALPHAMAP  3
100
#define PSDOP_ALPHACOL  4
101
#define PSDOP_PIXMAP_COPYALL    5
102
 
103
/* common blitter parameter structure*/
104
typedef struct {
105
        PSD             dstpsd;         /* dst drawable*/
106
        MWCOORD         dstx, dsty;     /* dst x,y,w,h*/
107
        MWCOORD         dstw, dsth;
108
        MWCOORD         srcx, srcy;     /* src x,y*/
109
        MWCOORD         srcw, srch;     /* src w,h if stretchblit*/
110
        PSD             srcpsd;         /* src drawable*/
111
        unsigned long   rop;            /* raster opcode*/
112
        PSD             alphachan;      /* alpha chan for MWROP_BLENDCHANNEL*/
113
        MWPIXELVAL      fgcolor;        /* fg/bg color for MWROP_BLENDFGBG*/
114
        MWPIXELVAL      bgcolor;
115
        MWPIXELVAL      transcolor;     /* trans color for MWROP_SRCTRANSCOPY*/
116
} MWBLITARGS, *PMWBLITARGS;
117
 
118
/* screen subdriver entry points: one required for each draw function*/
119
/* NOTE: currently used for fb driver only*/
120
typedef struct {
121
        int      (*Init)(PSD psd);
122
        void     (*DrawPixel)(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c);
123
        MWPIXELVAL (*ReadPixel)(PSD psd, MWCOORD x, MWCOORD y);
124
        void     (*DrawHorzLine)(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y,
125
                        MWPIXELVAL c);
126
        void     (*DrawVertLine)(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2,
127
                        MWPIXELVAL c);
128
        void     (*FillRect)(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,
129
                        MWCOORD y2,MWPIXELVAL c);
130
        void     (*Blit)(PSD destpsd, MWCOORD destx, MWCOORD desty, MWCOORD w,
131
                        MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
132
        void     (*DrawArea)(PSD psd, driver_gc_t *gc, int op);
133
        void     (*StretchBlit)(PSD destpsd, MWCOORD destx, MWCOORD desty,
134
                        MWCOORD dstw, MWCOORD dsth, PSD srcpsd, MWCOORD srcx,
135
                        MWCOORD srcy, MWCOORD srcw, MWCOORD srch, long op);
136
} SUBDRIVER, *PSUBDRIVER;
137
 
138
/*
139
 * Interface to Screen Device Driver
140
 * This structure is also allocated for memory (offscreen) drawing and blitting.
141
 */
142
typedef struct _mwscreendevice {
143
        MWCOORD xres;           /* X screen res (real) */
144
        MWCOORD yres;           /* Y screen res (real) */
145
        MWCOORD xvirtres;       /* X drawing res (will be flipped in portrait mode) */
146
        MWCOORD yvirtres;       /* Y drawing res (will be flipped in portrait mode) */
147
        int     planes;         /* # planes*/
148
        int     bpp;            /* # bpp*/
149
        int     linelen;        /* line length in bytes for bpp 1,2,4,8*/
150
                                /* line length in pixels for bpp 16, 24, 32*/
151
        int     size;           /* size of memory allocated*/
152
        long    ncolors;        /* # screen colors*/
153
        int     pixtype;        /* format of pixel value*/
154
        int     flags;          /* device flags*/
155
        void *  addr;           /* address of memory allocated (memdc or fb)*/
156
 
157
        PSD     (*Open)(PSD psd);
158
        void    (*Close)(PSD psd);
159
        void    (*GetScreenInfo)(PSD psd,PMWSCREENINFO psi);
160
        void    (*SetPalette)(PSD psd,int first,int count,MWPALENTRY *pal);
161
        void    (*DrawPixel)(PSD psd,MWCOORD x,MWCOORD y,MWPIXELVAL c);
162
        MWPIXELVAL (*ReadPixel)(PSD psd,MWCOORD x,MWCOORD y);
163
        void    (*DrawHorzLine)(PSD psd,MWCOORD x1,MWCOORD x2,MWCOORD y,
164
                        MWPIXELVAL c);
165
        void    (*DrawVertLine)(PSD psd,MWCOORD x,MWCOORD y1,MWCOORD y2,
166
                        MWPIXELVAL c);
167
        void    (*FillRect)(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,
168
                        MWPIXELVAL c);
169
        PMWCOREFONT builtin_fonts;
170
 
171
        /***void (*DrawText)(PSD psd,MWCOORD x,MWCOORD y,const MWUCHAR *str,
172
                        int count, MWPIXELVAL fg, PMWFONT pfont);***/
173
 
174
        void    (*Blit)(PSD destpsd,MWCOORD destx,MWCOORD desty,MWCOORD w,
175
                        MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
176
        void    (*PreSelect)(PSD psd);
177
        void    (*DrawArea)(PSD psd, driver_gc_t *gc, int op);
178
        int     (*SetIOPermissions)(PSD psd);
179
        PSD     (*AllocateMemGC)(PSD psd);
180
        MWBOOL  (*MapMemGC)(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,
181
                        int linelen,int size,void *addr);
182
        void    (*FreeMemGC)(PSD mempsd);
183
        void    (*StretchBlit)(PSD destpsd,MWCOORD destx,MWCOORD desty,
184
                        MWCOORD destw,MWCOORD desth,PSD srcpsd,MWCOORD srcx,
185
                        MWCOORD srcy,MWCOORD srcw,MWCOORD srch,long op);
186
        void    (*SetPortrait)(PSD psd,int portraitmode);
187
        int     portrait;        /* screen portrait mode*/
188
        PSUBDRIVER orgsubdriver; /* original subdriver for portrait modes*/
189
} SCREENDEVICE;
190
 
191
/* PSD flags*/
192
#define PSF_SCREEN              0x0001  /* screen device*/
193
#define PSF_MEMORY              0x0002  /* memory device*/
194
#define PSF_HAVEBLIT            0x0004  /* have bitblit*/
195
#define PSF_HAVEOP_COPY         0x0008  /* psd->DrawArea can do area copy*/
196
#define PSF_ADDRMALLOC          0x0010  /* psd->addr was malloc'd*/
197
#define PSF_ADDRSHAREDMEM       0x0020  /* psd->addr is shared memory*/
198
 
199
/* Interface to Mouse Device Driver*/
200
typedef struct _mousedevice {
201
        int     (*Open)(struct _mousedevice *);
202
        void    (*Close)(void);
203
        int     (*GetButtonInfo)(void);
204
        void    (*GetDefaultAccel)(int *pscale,int *pthresh);
205
        int     (*Read)(MWCOORD *dx,MWCOORD *dy,MWCOORD *dz,int *bp);
206
        int     (*Poll)(void);          /* not required if have select()*/
207
} MOUSEDEVICE;
208
 
209
/* Interface to Keyboard Device Driver*/
210
typedef struct _kbddevice {
211
        int  (*Open)(struct _kbddevice *pkd);
212
        void (*Close)(void);
213
        void (*GetModifierInfo)(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers);
214
        int  (*Read)(MWKEY *buf,MWKEYMOD *modifiers,MWSCANCODE *scancode);
215
        int  (*Poll)(void);             /* not required if have select()*/
216
} KBDDEVICE;
217
 
218
/* Clip areas*/
219
#define CLIP_VISIBLE            0
220
#define CLIP_INVISIBLE          1
221
#define CLIP_PARTIAL            2
222
 
223
/* static clip rectangle: drawing allowed if point within rectangle*/
224
typedef struct {
225
        MWCOORD         x;              /* x coordinate of top left corner */
226
        MWCOORD         y;              /* y coordinate of top left corner */
227
        MWCOORD         width;          /* width of rectangle */
228
        MWCOORD         height;         /* height of rectangle */
229
} MWCLIPRECT;
230
 
231
#ifndef TRUE
232
#define TRUE                    1
233
#endif
234
#ifndef FALSE
235
#define FALSE                   0
236
#endif
237
 
238
#define MWMIN(a,b)              ((a) < (b) ? (a) : (b))
239
#define MWMAX(a,b)              ((a) > (b) ? (a) : (b))
240
 
241
/* MWIMAGEBITS macros*/
242
#define MWIMAGE_SIZE(width, height)  ((height) * (((width) + MWIMAGE_BITSPERIMAGE - 1) / MWIMAGE_BITSPERIMAGE))
243
#define MWIMAGE_WORDS(x)        (((x)+15)/16)
244
#define MWIMAGE_BYTES(x)        (((x)+7)/8)
245
#define MWIMAGE_BITSPERIMAGE    (sizeof(MWIMAGEBITS) * 8)
246
#define MWIMAGE_FIRSTBIT        ((MWIMAGEBITS) 0x8000)
247
#define MWIMAGE_NEXTBIT(m)      ((MWIMAGEBITS) ((m) >> 1))
248
#define MWIMAGE_TESTBIT(m)      ((m) & MWIMAGE_FIRSTBIT)  /* use with shiftbit*/
249
#define MWIMAGE_SHIFTBIT(m)     ((MWIMAGEBITS) ((m) << 1))  /* for testbit*/
250
 
251
/* color and palette defines*/
252
#define RGBDEF(r,g,b)   {r, g, b}
253
 
254
#define GETPALENTRY(pal,index) ((unsigned long)(pal[index].r |\
255
                                (pal[index].g << 8) | (pal[index].b << 16)))
256
/*#define GETPALENTRY(pal,index) ((*(unsigned long *)&pal[index])&0x00ffffff)*/
257
 
258
#define REDVALUE(rgb)   ((rgb) & 0xff)
259
#define GREENVALUE(rgb) (((rgb) >> 8) & 0xff)
260
#define BLUEVALUE(rgb)  (((rgb) >> 16) & 0xff)
261
 
262
/* Truecolor color conversion and extraction macros*/
263
/*
264
 * Conversion from RGB to MWPIXELVAL
265
 */
266
/* create 24 bit 8/8/8 format pixel (0x00RRGGBB) from RGB triplet*/
267
#define RGB2PIXEL888(r,g,b)     \
268
        (((r) << 16) | ((g) << 8) | (b))
269
 
270
/* create 16 bit 5/6/5 format pixel from RGB triplet */
271
#define RGB2PIXEL565(r,g,b)     \
272
        ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
273
 
274
/* create 16 bit 5/5/5 format pixel from RGB triplet */
275
#define RGB2PIXEL555(r,g,b)     \
276
        ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3))
277
 
278
/* create 8 bit 3/3/2 format pixel from RGB triplet*/
279
#define RGB2PIXEL332(r,g,b)     \
280
        (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
281
 
282
/*
283
 * Conversion from MWCOLORVAL to MWPIXELVAL
284
 */
285
/* create 24 bit 8/8/8 format pixel from RGB colorval (0x00BBGGRR)*/
286
#define COLOR2PIXEL888(c)       \
287
        ((((c) & 0xff) << 16) | ((c) & 0xff00) | (((c) & 0xff0000) >> 16))
288
 
289
/* create 16 bit 5/6/5 format pixel from RGB colorval (0x00BBGGRR)*/
290
#define COLOR2PIXEL565(c)       \
291
        ((((c) & 0xf8) << 8) | (((c) & 0xfc00) >> 5) | (((c) & 0xf80000) >> 19))
292
 
293
/* create 16 bit 5/5/5 format pixel from RGB colorval (0x00BBGGRR)*/
294
#define COLOR2PIXEL555(c)       \
295
        ((((c) & 0xf8) << 7) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 19))
296
 
297
/* create 8 bit 3/3/2 format pixel from RGB colorval (0x00BBGGRR)*/
298
#define COLOR2PIXEL332(c)       \
299
        (((c) & 0xe0) | (((c) & 0xe000) >> 11) | (((c) & 0xc00000) >> 22))
300
 
301
/*
302
 * Conversion from MWPIXELVAL to red, green or blue components
303
 */
304
/* return 8/8/8 bit r, g or b component of 24 bit pixelval*/
305
#define PIXEL888RED(pixelval)           (((pixelval) >> 16) & 0xff)
306
#define PIXEL888GREEN(pixelval)         (((pixelval) >> 8) & 0xff)
307
#define PIXEL888BLUE(pixelval)          ((pixelval) & 0xff)
308
 
309
/* return 5/6/5 bit r, g or b component of 16 bit pixelval*/
310
#define PIXEL565RED(pixelval)           (((pixelval) >> 11) & 0x1f)
311
#define PIXEL565GREEN(pixelval)         (((pixelval) >> 5) & 0x3f)
312
#define PIXEL565BLUE(pixelval)          ((pixelval) & 0x1f)
313
 
314
/* return 5/5/5 bit r, g or b component of 16 bit pixelval*/
315
#define PIXEL555RED(pixelval)           (((pixelval) >> 10) & 0x1f)
316
#define PIXEL555GREEN(pixelval)         (((pixelval) >> 5) & 0x1f)
317
#define PIXEL555BLUE(pixelval)          ((pixelval) & 0x1f)
318
 
319
/* return 3/3/2 bit r, g or b component of 8 bit pixelval*/
320
#define PIXEL332RED(pixelval)           (((pixelval) >> 5) & 0x07)
321
#define PIXEL332GREEN(pixelval)         (((pixelval) >> 2) & 0x07)
322
#define PIXEL332BLUE(pixelval)          ((pixelval) & 0x03)
323
 
324
/*
325
 * Conversion from MWPIXELVAL to MWCOLORVAL
326
 */
327
/* create RGB colorval (0x00BBGGRR) from 8/8/8 format pixel*/
328
#define PIXEL888TOCOLORVAL(p)   \
329
        ((((p) & 0xff0000) >> 16) | ((p) & 0xff00) | (((p) & 0xff) << 16))
330
 
331
/* create RGB colorval (0x00BBGGRR) from 5/6/5 format pixel*/
332
#define PIXEL565TOCOLORVAL(p)   \
333
        ((((p) & 0xf800) >> 8) | (((p) & 0x07e0) << 5) | (((p) & 0x1f) << 19))
334
 
335
#define PIXEL555TOCOLORVAL(p)   \
336
        ((((p) & 0x7c00) >> 7) | (((p) & 0x03e0) << 6) | (((p) & 0x1f) << 19))
337
 
338
/* create RGB colorval (0x00BBGGRR) from 3/3/2 format pixel*/
339
#define PIXEL332TOCOLORVAL(p)   \
340
        ((((p) & 0xe0)) | (((p) & 0x1c) << 11) | (((p) & 0x03) << 19))
341
 
342
#if (MWPIXEL_FORMAT == MWPF_TRUECOLOR888) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR0888)
343
#define RGB2PIXEL(r,g,b)        RGB2PIXEL888(r,g,b)
344
#define COLORVALTOPIXELVAL(c)   COLOR2PIXEL888(c)
345
#define PIXELVALTOCOLORVAL(p)   PIXEL888TOCOLORVAL(p)
346
#define PIXEL2RED(p)            PIXEL888RED(p)
347
#define PIXEL2GREEN(p)          PIXEL888GREEN(p)
348
#define PIXEL2BLUE(p)           PIXEL888BLUE(p)
349
#endif
350
 
351
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR565
352
#define RGB2PIXEL(r,g,b)        RGB2PIXEL565(r,g,b)
353
#define COLORVALTOPIXELVAL(c)   COLOR2PIXEL565(c)
354
#define PIXELVALTOCOLORVAL(p)   PIXEL565TOCOLORVAL(p)
355
#define PIXEL2RED(p)            PIXEL565RED(p)
356
#define PIXEL2GREEN(p)          PIXEL565GREEN(p)
357
#define PIXEL2BLUE(p)           PIXEL565BLUE(p)
358
#endif
359
 
360
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR555
361
#define RGB2PIXEL(r,g,b)        RGB2PIXEL555(r,g,b)
362
#define COLORVALTOPIXELVAL(c)   COLOR2PIXEL555(c)
363
#define PIXELVALTOCOLORVAL(p)   PIXEL555TOCOLORVAL(p)
364
#define PIXEL2RED(p)            PIXEL555RED(p)
365
#define PIXEL2GREEN(p)          PIXEL555GREEN(p)
366
#define PIXEL2BLUE(p)           PIXEL555BLUE(p)
367
#endif
368
 
369
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR332
370
#define RGB2PIXEL(r,g,b)        RGB2PIXEL332(r,g,b)
371
#define COLORVALTOPIXELVAL(c)   COLOR2PIXEL332(c)
372
#define PIXELVALTOCOLORVAL(p)   PIXEL332TOCOLORVAL(p)
373
#define PIXEL2RED(p)            PIXEL332RED(p)
374
#define PIXEL2GREEN(p)          PIXEL332GREEN(p)
375
#define PIXEL2BLUE(p)           PIXEL332BLUE(p)
376
#endif
377
 
378
/* Alpha blend two pixels using 8-bit alpha */
379
/* FIXME this will be quite a bit faster as an inlined function */
380
#define ALPHAPIXELRED(pixelvalsrc, pixelvaldest, alpha) \
381
        (unsigned char)((((PIXEL2RED(pixelvalsrc) - PIXEL2RED(pixelvaldest))\
382
                          * alpha) >> 8) + PIXEL2RED(pixelvaldest))
383
 
384
#define ALPHAPIXELGREEN(pixelvalsrc, pixelvaldest, alpha)       \
385
        (unsigned char)((((PIXEL2GREEN(pixelvalsrc)-PIXEL2GREEN(pixelvaldest))\
386
                          * alpha) >> 8) + PIXEL2GREEN(pixelvaldest))
387
 
388
#define ALPHAPIXELBLUE(pixelvalsrc, pixelvaldest, alpha)        \
389
        (unsigned char)((((PIXEL2BLUE(pixelvalsrc) - PIXEL2BLUE(pixelvaldest))\
390
                          * alpha) >> 8) + PIXEL2BLUE(pixelvaldest))
391
 
392
#if 0000
393
/* colors assumed in first 16 palette entries*/
394
/* note: don't use palette indices if the palette may
395
 * be reloaded.  Use the RGB values instead.
396
 */
397
#define BLACK           PALINDEX(0)             /*   0,   0,   0*/
398
#define BLUE            PALINDEX(1)
399
#define GREEN           PALINDEX(2)
400
#define CYAN            PALINDEX(3)
401
#define RED             PALINDEX(4)
402
#define MAGENTA         PALINDEX(5)
403
#define BROWN           PALINDEX(6)
404
#define LTGRAY          PALINDEX(7)             /* 192, 192, 192*/
405
#define GRAY            PALINDEX(8)             /* 128, 128, 128*/
406
#define LTBLUE          PALINDEX(9)
407
#define LTGREEN         PALINDEX(10)
408
#define LTCYAN          PALINDEX(11)
409
#define LTRED           PALINDEX(12)
410
#define LTMAGENTA       PALINDEX(13)
411
#define YELLOW          PALINDEX(14)
412
#define WHITE           PALINDEX(15)            /* 255, 255, 255*/
413
#endif
414
 
415
/* GdMakePaletteConversionTable bLoadType types*/
416
#define LOADPALETTE     1       /* load image palette into system palette*/
417
#define MERGEPALETTE    2       /* merge image palette into system palette*/
418
 
419
/* entry points*/
420
 
421
/* devdraw.c*/
422
PSD     GdOpenScreen(void);
423
void    GdCloseScreen(PSD psd);
424
int     GdSetPortraitMode(PSD psd, int portraitmode);
425
int     GdSetMode(int mode);
426
MWBOOL  GdSetUseBackground(MWBOOL flag);
427
MWPIXELVAL GdSetForeground(MWPIXELVAL fg);
428
MWPIXELVAL GdSetBackground(MWPIXELVAL bg);
429
void    GdResetPalette(void);
430
void    GdSetPalette(PSD psd,int first, int count, MWPALENTRY *palette);
431
int     GdGetPalette(PSD psd,int first, int count, MWPALENTRY *palette);
432
MWPIXELVAL GdFindColor(MWCOLORVAL c);
433
MWPIXELVAL GdFindNearestColor(MWPALENTRY *pal, int size, MWCOLORVAL cr);
434
int     GdCaptureScreen(char *path);
435
void    GdGetScreenInfo(PSD psd,PMWSCREENINFO psi);
436
void    GdPoint(PSD psd,MWCOORD x, MWCOORD y);
437
void    GdLine(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,
438
                MWBOOL bDrawLastPoint);
439
void    GdRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
440
void    GdFillRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
441
void    GdBitmap(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
442
                MWIMAGEBITS *imagebits);
443
MWBOOL  GdColorInPalette(MWCOLORVAL cr,MWPALENTRY *palette,int palsize);
444
void    GdMakePaletteConversionTable(PSD psd,MWPALENTRY *palette,int palsize,
445
                MWPIXELVAL *convtable,int fLoadType);
446
void    GdDrawImage(PSD psd,MWCOORD x, MWCOORD y, PMWIMAGEHDR pimage);
447
void    GdPoly(PSD psd,int count, MWPOINT *points);
448
void    GdFillPoly(PSD psd,int count, MWPOINT *points);
449
void    GdReadArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
450
                MWPIXELVAL *pixels);
451
void    GdArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
452
                void *pixels, int pixtype);
453
void    GdTranslateArea(MWCOORD width, MWCOORD height, void *in, int inpixtype,
454
                MWCOORD inpitch, void *out, int outpixtype, int outpitch);
455
void    GdCopyArea(PSD psd,MWCOORD srcx,MWCOORD srcy,MWCOORD width,
456
                MWCOORD height, MWCOORD destx, MWCOORD desty);
457
void    GdBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD width,
458
                MWCOORD height,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long rop);
459
void    GdStretchBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw,
460
                MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy,
461
                MWCOORD srcw, MWCOORD srch, long rop);
462
int     GdCalcMemGCAlloc(PSD psd, unsigned int width, unsigned int height,
463
                int planes, int bpp, int *size, int *linelen);
464
extern SCREENDEVICE scrdev;
465
 
466
/* devarc.c*/
467
/* requires float*/
468
void    GdArcAngle(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry,
469
                MWCOORD angle1, MWCOORD angle2, int type);
470
/* integer only*/
471
void    GdArc(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry,
472
                MWCOORD ax, MWCOORD ay, MWCOORD bx, MWCOORD by, int type);
473
void    GdEllipse(PSD psd,MWCOORD x, MWCOORD y, MWCOORD rx, MWCOORD ry,
474
                MWBOOL fill);
475
 
476
/* devfont.c*/
477
void    GdClearFontList(void);
478
int     GdAddFont(char *fndry, char *family, char *fontname, PMWLOGFONT lf,
479
                  unsigned int flags);
480
PMWFONT GdSetFont(PMWFONT pfont);
481
PMWFONT GdCreateFont(PSD psd, const char *name, MWCOORD height,
482
                const PMWLOGFONT plogfont);
483
MWCOORD GdSetFontSize(PMWFONT pfont, MWCOORD fontsize);
484
void GdGetFontList(MWFONTLIST ***list, int *num);
485
void GdFreeFontList(MWFONTLIST ***list, int num);
486
int     GdSetFontRotation(PMWFONT pfont, int tenthdegrees);
487
int     GdSetFontAttr(PMWFONT pfont, int setflags, int clrflags);
488
void    GdDestroyFont(PMWFONT pfont);
489
MWBOOL  GdGetFontInfo(PMWFONT pfont, PMWFONTINFO pfontinfo);
490
int     GdConvertEncoding(const void *istr, int iflags, int cc, void *ostr,
491
                int oflags);
492
void    GdGetTextSize(PMWFONT pfont, const void *str, int cc, MWCOORD *pwidth,
493
                MWCOORD *pheight, MWCOORD *pbase, int flags);
494
int     GdGetTextSizeEx(PMWFONT pfont, const void *str, int cc,
495
                int nMaxExtent, int *lpnFit, int *alpDx, MWCOORD *pwidth,
496
                MWCOORD *pheight, MWCOORD *pbase, int flags);
497
void    GdText(PSD psd,MWCOORD x,MWCOORD y,const void *str,int count,int flags);
498
 
499
/* devclip1.c*/
500
void    GdSetClipRects(PSD psd,int count,MWCLIPRECT *table);
501
MWBOOL  GdClipPoint(PSD psd,MWCOORD x,MWCOORD y);
502
int     GdClipArea(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2);
503
extern MWCOORD clipminx, clipminy, clipmaxx, clipmaxy;
504
 
505
/* devclip2.c*/
506
void    GdSetClipRegion(PSD psd, MWCLIPREGION *reg);
507
 
508
/* devrgn.c - multi-rectangle region entry points*/
509
MWBOOL GdPtInRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
510
int    GdRectInRegion(MWCLIPREGION *rgn, const MWRECT *rect);
511
MWBOOL GdEqualRegion(MWCLIPREGION *r1, MWCLIPREGION *r2);
512
MWBOOL GdEmptyRegion(MWCLIPREGION *rgn);
513
MWCLIPREGION *GdAllocRegion(void);
514
MWCLIPREGION *GdAllocRectRegion(MWCOORD left,MWCOORD top,MWCOORD right,MWCOORD bottom);
515
MWCLIPREGION *GdAllocRectRegionIndirect(MWRECT *prc);
516
void GdSetRectRegion(MWCLIPREGION *rgn, MWCOORD left, MWCOORD top,
517
                MWCOORD right, MWCOORD bottom);
518
void GdSetRectRegionIndirect(MWCLIPREGION *rgn, MWRECT *prc);
519
void GdDestroyRegion(MWCLIPREGION *rgn);
520
void GdOffsetRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
521
int  GdGetRegionBox(MWCLIPREGION *rgn, MWRECT *prc);
522
void GdUnionRectWithRegion(const MWRECT *rect, MWCLIPREGION *rgn);
523
void GdSubtractRectFromRegion(const MWRECT *rect, MWCLIPREGION *rgn);
524
void GdCopyRegion(MWCLIPREGION *d, MWCLIPREGION *s);
525
void GdIntersectRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
526
void GdUnionRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
527
void GdSubtractRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
528
void GdXorRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
529
 
530
/* devrgn2.c*/
531
MWCLIPREGION *GdAllocPolygonRegion(MWPOINT *points, int count, int mode);
532
MWCLIPREGION *GdAllocPolyPolygonRegion(MWPOINT *points, int *count,
533
                int nbpolygons, int mode);
534
 
535
/* devmouse.c*/
536
int     GdOpenMouse(void);
537
void    GdCloseMouse(void);
538
void    GdGetButtonInfo(int *buttons);
539
void    GdRestrictMouse(MWCOORD newminx,MWCOORD newminy,MWCOORD newmaxx,
540
                MWCOORD newmaxy);
541
void    GdSetAccelMouse(int newthresh, int newscale);
542
void    GdMoveMouse(MWCOORD newx, MWCOORD newy);
543
int     GdReadMouse(MWCOORD *px, MWCOORD *py, int *pb);
544
void    GdMoveCursor(MWCOORD x, MWCOORD y);
545
MWBOOL  GdGetCursorPos(MWCOORD *px, MWCOORD *py);
546
void    GdSetCursor(PMWCURSOR pcursor);
547
int     GdShowCursor(PSD psd);
548
int     GdHideCursor(PSD psd);
549
void    GdCheckCursor(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2);
550
void    GdFixCursor(PSD psd);
551
extern MOUSEDEVICE mousedev;
552
 
553
/* devkbd.c*/
554
int     GdOpenKeyboard(void);
555
void    GdCloseKeyboard(void);
556
void    GdGetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers);
557
int     GdReadKeyboard(MWKEY *buf, MWKEYMOD *modifiers, MWSCANCODE *scancode);
558
extern KBDDEVICE kbddev;
559
 
560
/* devimage.c */
561
 
562
int     GdLoadImageFromBuffer(PSD psd, void *buffer, int size, int flags);
563
void    GdDrawImageFromBuffer(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
564
                 MWCOORD height, void *buffer, int size, int flags);
565
void    GdDrawImageFromFile(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
566
                MWCOORD height, char *path, int flags);
567
int     GdLoadImageFromFile(PSD psd, char *path, int flags);
568
void    GdDrawImageToFit(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
569
                MWCOORD height, int id);
570
void    GdFreeImage(int id);
571
MWBOOL  GdGetImageInfo(int id, PMWIMAGEINFO pii);
572
void    GdStretchImage(PMWIMAGEHDR src, MWCLIPRECT *srcrect, PMWIMAGEHDR dst,
573
                MWCLIPRECT *dstrect);
574
 
575
/* devlist.c*/
576
/* field offset*/
577
#define MWITEM_OFFSET(type, field)    ((long)&(((type *)0)->field))
578
 
579
void *  GdItemAlloc(unsigned int size);
580
void    GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem);
581
void    GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem);
582
void    GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem);
583
#define GdItemNew(type) ((type *)GdItemAlloc(sizeof(type)))
584
#define GdItemFree(ptr) free((void *)ptr)
585
 
586
/* return base item address from list ptr*/
587
#define GdItemAddr(p,type,list) ((type *)((long)p - MWITEM_OFFSET(type,list)))
588
 
589
#if UNIX || DOS_DJGPP
590
 
591
#include <sys/time.h>
592
 
593
typedef void (*MWTIMERCB)(void *);
594
 
595
#define  MWTIMER_ONESHOT         0 
596
#define  MWTIMER_PERIODIC        1
597
 
598
typedef struct mw_timer MWTIMER;
599
struct mw_timer {
600
        struct timeval  timeout;
601
        MWTIMERCB       callback;
602
        void            *arg;
603
        MWTIMER         *next;
604
        MWTIMER         *prev;
605
    int         type;     /* MWTIMER_ONESHOT or MWTIMER_PERIODIC */
606
    MWTIMEOUT   period;
607
};
608
 
609
MWTIMER         *GdAddTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);
610
MWTIMER         *GdAddPeriodicTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);
611
void            GdDestroyTimer(MWTIMER *timer);
612
MWTIMER         *GdFindTimer(void *arg);
613
MWBOOL          GdGetNextTimeout(struct timeval *tv, MWTIMEOUT timeout);
614
MWBOOL          GdTimeout(void);
615
 
616
#endif
617
 
618
/* error.c*/
619
int     GdError(const char *format, ...);
620
int     GdErrorNull(const char *format, ...);  /* doesn't print msgs */
621
 
622
#ifdef USE_ALLOCA
623
/* alloca() is available, so use it for better performance */
624
#define ALLOCA(size)    alloca(size)
625
#define FREEA(pmem)
626
#else
627
/* no alloca(), so use malloc()/free() instead */
628
#define ALLOCA(size)    malloc(size)
629
#define FREEA(pmem)     free(pmem)
630
#endif
631
 
632
/* no assert() in MSDOS or ELKS...*/
633
#if MSDOS | ELKS
634
#undef assert
635
#define assert(x)
636
#endif
637
 
638
/* RTEMS requires rtems_main()*/
639
#if __rtems__
640
#define main    rtems_main
641
#endif
642
 
643
#if !_MINIX
644
#ifndef __rtems__
645
#define HAVESELECT      1       /* has select system call*/
646
#endif
647
#endif
648
 
649
#endif /*_DEVICE_H*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.