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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [include/] [microwin/] [device.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#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
#if 0
295
#define COLOR2PIXEL555(c)       \
296
        ((((c) & 0xf8) << 7) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 19))
297
#else
298
#define COLOR2PIXEL555(c)       \
299
        ((((c) & 0xf8) >> (3-0)) | (((c) & 0xf800) >> (11-5)) | (((c) & 0xf80000) >> (19-10)))
300
#endif
301
 
302
/* create 8 bit 3/3/2 format pixel from RGB colorval (0x00BBGGRR)*/
303
#define COLOR2PIXEL332(c)       \
304
        (((c) & 0xe0) | (((c) & 0xe000) >> 11) | (((c) & 0xc00000) >> 22))
305
 
306
/*
307
 * Conversion from MWPIXELVAL to red, green or blue components
308
 */
309
/* return 8/8/8 bit r, g or b component of 24 bit pixelval*/
310
#define PIXEL888RED(pixelval)           (((pixelval) >> 16) & 0xff)
311
#define PIXEL888GREEN(pixelval)         (((pixelval) >> 8) & 0xff)
312
#define PIXEL888BLUE(pixelval)          ((pixelval) & 0xff)
313
 
314
/* return 5/6/5 bit r, g or b component of 16 bit pixelval*/
315
#define PIXEL565RED(pixelval)           (((pixelval) >> 11) & 0x1f)
316
#define PIXEL565GREEN(pixelval)         (((pixelval) >> 5) & 0x3f)
317
#define PIXEL565BLUE(pixelval)          ((pixelval) & 0x1f)
318
 
319
/* return 5/5/5 bit r, g or b component of 16 bit pixelval*/
320
#define PIXEL555RED(pixelval)           (((pixelval) >> 10) & 0x1f)
321
#define PIXEL555GREEN(pixelval)         (((pixelval) >> 5) & 0x1f)
322
#define PIXEL555BLUE(pixelval)          ((pixelval) & 0x1f)
323
 
324
/* return 3/3/2 bit r, g or b component of 8 bit pixelval*/
325
#define PIXEL332RED(pixelval)           (((pixelval) >> 5) & 0x07)
326
#define PIXEL332GREEN(pixelval)         (((pixelval) >> 2) & 0x07)
327
#define PIXEL332BLUE(pixelval)          ((pixelval) & 0x03)
328
 
329
/*
330
 * Conversion from MWPIXELVAL to MWCOLORVAL
331
 */
332
/* create RGB colorval (0x00BBGGRR) from 8/8/8 format pixel*/
333
#define PIXEL888TOCOLORVAL(p)   \
334
        ((((p) & 0xff0000) >> 16) | ((p) & 0xff00) | (((p) & 0xff) << 16))
335
 
336
/* create RGB colorval (0x00BBGGRR) from 5/6/5 format pixel*/
337
#define PIXEL565TOCOLORVAL(p)   \
338
        ((((p) & 0xf800) >> 8) | (((p) & 0x07e0) << 5) | (((p) & 0x1f) << 19))
339
 
340
#define PIXEL555TOCOLORVAL(p)   \
341
        ((((p) & 0x7c00) >> 7) | (((p) & 0x03e0) << 6) | (((p) & 0x1f) << 19))
342
 
343
/* create RGB colorval (0x00BBGGRR) from 3/3/2 format pixel*/
344
#define PIXEL332TOCOLORVAL(p)   \
345
        ((((p) & 0xe0)) | (((p) & 0x1c) << 11) | (((p) & 0x03) << 19))
346
 
347
#if (MWPIXEL_FORMAT == MWPF_TRUECOLOR888) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR0888)
348
#define RGB2PIXEL(r,g,b)        RGB2PIXEL888(r,g,b)
349
#define COLORVALTOPIXELVAL(c)   COLOR2PIXEL888(c)
350
#define PIXELVALTOCOLORVAL(p)   PIXEL888TOCOLORVAL(p)
351
#define PIXEL2RED(p)            PIXEL888RED(p)
352
#define PIXEL2GREEN(p)          PIXEL888GREEN(p)
353
#define PIXEL2BLUE(p)           PIXEL888BLUE(p)
354
#endif
355
 
356
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR565
357
#define RGB2PIXEL(r,g,b)        RGB2PIXEL565(r,g,b)
358
#define COLORVALTOPIXELVAL(c)   COLOR2PIXEL565(c)
359
#define PIXELVALTOCOLORVAL(p)   PIXEL565TOCOLORVAL(p)
360
#define PIXEL2RED(p)            PIXEL565RED(p)
361
#define PIXEL2GREEN(p)          PIXEL565GREEN(p)
362
#define PIXEL2BLUE(p)           PIXEL565BLUE(p)
363
#endif
364
 
365
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR555
366
#define RGB2PIXEL(r,g,b)        RGB2PIXEL555(r,g,b)
367
#define COLORVALTOPIXELVAL(c)   COLOR2PIXEL555(c)
368
#define PIXELVALTOCOLORVAL(p)   PIXEL555TOCOLORVAL(p)
369
#define PIXEL2RED(p)            PIXEL555RED(p)
370
#define PIXEL2GREEN(p)          PIXEL555GREEN(p)
371
#define PIXEL2BLUE(p)           PIXEL555BLUE(p)
372
#endif
373
 
374
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR332
375
#define RGB2PIXEL(r,g,b)        RGB2PIXEL332(r,g,b)
376
#define COLORVALTOPIXELVAL(c)   COLOR2PIXEL332(c)
377
#define PIXELVALTOCOLORVAL(p)   PIXEL332TOCOLORVAL(p)
378
#define PIXEL2RED(p)            PIXEL332RED(p)
379
#define PIXEL2GREEN(p)          PIXEL332GREEN(p)
380
#define PIXEL2BLUE(p)           PIXEL332BLUE(p)
381
#endif
382
 
383
/* Alpha blend two pixels using 8-bit alpha */
384
/* FIXME this will be quite a bit faster as an inlined function */
385
#define ALPHAPIXELRED(pixelvalsrc, pixelvaldest, alpha) \
386
        (unsigned char)((((PIXEL2RED(pixelvalsrc) - PIXEL2RED(pixelvaldest))\
387
                          * alpha) >> 8) + PIXEL2RED(pixelvaldest))
388
 
389
#define ALPHAPIXELGREEN(pixelvalsrc, pixelvaldest, alpha)       \
390
        (unsigned char)((((PIXEL2GREEN(pixelvalsrc)-PIXEL2GREEN(pixelvaldest))\
391
                          * alpha) >> 8) + PIXEL2GREEN(pixelvaldest))
392
 
393
#define ALPHAPIXELBLUE(pixelvalsrc, pixelvaldest, alpha)        \
394
        (unsigned char)((((PIXEL2BLUE(pixelvalsrc) - PIXEL2BLUE(pixelvaldest))\
395
                          * alpha) >> 8) + PIXEL2BLUE(pixelvaldest))
396
 
397
#if 0000
398
/* colors assumed in first 16 palette entries*/
399
/* note: don't use palette indices if the palette may
400
 * be reloaded.  Use the RGB values instead.
401
 */
402
#define BLACK           PALINDEX(0)             /*   0,   0,   0*/
403
#define BLUE            PALINDEX(1)
404
#define GREEN           PALINDEX(2)
405
#define CYAN            PALINDEX(3)
406
#define RED             PALINDEX(4)
407
#define MAGENTA         PALINDEX(5)
408
#define BROWN           PALINDEX(6)
409
#define LTGRAY          PALINDEX(7)             /* 192, 192, 192*/
410
#define GRAY            PALINDEX(8)             /* 128, 128, 128*/
411
#define LTBLUE          PALINDEX(9)
412
#define LTGREEN         PALINDEX(10)
413
#define LTCYAN          PALINDEX(11)
414
#define LTRED           PALINDEX(12)
415
#define LTMAGENTA       PALINDEX(13)
416
#define YELLOW          PALINDEX(14)
417
#define WHITE           PALINDEX(15)            /* 255, 255, 255*/
418
#endif
419
 
420
/* GdMakePaletteConversionTable bLoadType types*/
421
#define LOADPALETTE     1       /* load image palette into system palette*/
422
#define MERGEPALETTE    2       /* merge image palette into system palette*/
423
 
424
/* entry points*/
425
 
426
/* devdraw.c*/
427
PSD     GdOpenScreen(void);
428
void    GdCloseScreen(PSD psd);
429
int     GdSetPortraitMode(PSD psd, int portraitmode);
430
int     GdSetMode(int mode);
431
MWBOOL  GdSetUseBackground(MWBOOL flag);
432
MWPIXELVAL GdSetForeground(MWPIXELVAL fg);
433
MWPIXELVAL GdSetBackground(MWPIXELVAL bg);
434
void    GdResetPalette(void);
435
void    GdSetPalette(PSD psd,int first, int count, MWPALENTRY *palette);
436
int     GdGetPalette(PSD psd,int first, int count, MWPALENTRY *palette);
437
MWPIXELVAL GdFindColor(MWCOLORVAL c);
438
MWPIXELVAL GdFindNearestColor(MWPALENTRY *pal, int size, MWCOLORVAL cr);
439
int     GdCaptureScreen(char *path);
440
void    GdGetScreenInfo(PSD psd,PMWSCREENINFO psi);
441
void    GdPoint(PSD psd,MWCOORD x, MWCOORD y);
442
void    GdLine(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,
443
                MWBOOL bDrawLastPoint);
444
void    GdRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
445
void    GdFillRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
446
void    GdBitmap(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
447
                MWIMAGEBITS *imagebits);
448
MWBOOL  GdColorInPalette(MWCOLORVAL cr,MWPALENTRY *palette,int palsize);
449
void    GdMakePaletteConversionTable(PSD psd,MWPALENTRY *palette,int palsize,
450
                MWPIXELVAL *convtable,int fLoadType);
451
void    GdDrawImage(PSD psd,MWCOORD x, MWCOORD y, PMWIMAGEHDR pimage);
452
void    GdPoly(PSD psd,int count, MWPOINT *points);
453
void    GdFillPoly(PSD psd,int count, MWPOINT *points);
454
void    GdReadArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
455
                MWPIXELVAL *pixels);
456
void    GdArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
457
                void *pixels, int pixtype);
458
void    GdTranslateArea(MWCOORD width, MWCOORD height, void *in, int inpixtype,
459
                MWCOORD inpitch, void *out, int outpixtype, int outpitch);
460
void    GdCopyArea(PSD psd,MWCOORD srcx,MWCOORD srcy,MWCOORD width,
461
                MWCOORD height, MWCOORD destx, MWCOORD desty);
462
void    GdBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD width,
463
                MWCOORD height,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long rop);
464
void    GdStretchBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw,
465
                MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy,
466
                MWCOORD srcw, MWCOORD srch, long rop);
467
int     GdCalcMemGCAlloc(PSD psd, unsigned int width, unsigned int height,
468
                int planes, int bpp, int *size, int *linelen);
469
extern SCREENDEVICE scrdev;
470
 
471
/* devarc.c*/
472
/* requires float*/
473
void    GdArcAngle(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry,
474
                MWCOORD angle1, MWCOORD angle2, int type);
475
/* integer only*/
476
void    GdArc(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry,
477
                MWCOORD ax, MWCOORD ay, MWCOORD bx, MWCOORD by, int type);
478
void    GdEllipse(PSD psd,MWCOORD x, MWCOORD y, MWCOORD rx, MWCOORD ry,
479
                MWBOOL fill);
480
 
481
/* devfont.c*/
482
void    GdClearFontList(void);
483
int     GdAddFont(char *fndry, char *family, char *fontname, PMWLOGFONT lf,
484
                  unsigned int flags);
485
PMWFONT GdSetFont(PMWFONT pfont);
486
PMWFONT GdCreateFont(PSD psd, const char *name, MWCOORD height,
487
                const PMWLOGFONT plogfont);
488
MWCOORD GdSetFontSize(PMWFONT pfont, MWCOORD fontsize);
489
void GdGetFontList(MWFONTLIST ***list, int *num);
490
void GdFreeFontList(MWFONTLIST ***list, int num);
491
int     GdSetFontRotation(PMWFONT pfont, int tenthdegrees);
492
int     GdSetFontAttr(PMWFONT pfont, int setflags, int clrflags);
493
void    GdDestroyFont(PMWFONT pfont);
494
MWBOOL  GdGetFontInfo(PMWFONT pfont, PMWFONTINFO pfontinfo);
495
int     GdConvertEncoding(const void *istr, int iflags, int cc, void *ostr,
496
                int oflags);
497
void    GdGetTextSize(PMWFONT pfont, const void *str, int cc, MWCOORD *pwidth,
498
                MWCOORD *pheight, MWCOORD *pbase, int flags);
499
int     GdGetTextSizeEx(PMWFONT pfont, const void *str, int cc,
500
                int nMaxExtent, int *lpnFit, int *alpDx, MWCOORD *pwidth,
501
                MWCOORD *pheight, MWCOORD *pbase, int flags);
502
void    GdText(PSD psd,MWCOORD x,MWCOORD y,const void *str,int count,int flags);
503
 
504
/* devclip1.c*/
505
void    GdSetClipRects(PSD psd,int count,MWCLIPRECT *table);
506
MWBOOL  GdClipPoint(PSD psd,MWCOORD x,MWCOORD y);
507
int     GdClipArea(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2);
508
extern MWCOORD clipminx, clipminy, clipmaxx, clipmaxy;
509
 
510
/* devclip2.c*/
511
void    GdSetClipRegion(PSD psd, MWCLIPREGION *reg);
512
 
513
/* devrgn.c - multi-rectangle region entry points*/
514
MWBOOL GdPtInRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
515
int    GdRectInRegion(MWCLIPREGION *rgn, const MWRECT *rect);
516
MWBOOL GdEqualRegion(MWCLIPREGION *r1, MWCLIPREGION *r2);
517
MWBOOL GdEmptyRegion(MWCLIPREGION *rgn);
518
MWCLIPREGION *GdAllocRegion(void);
519
MWCLIPREGION *GdAllocRectRegion(MWCOORD left,MWCOORD top,MWCOORD right,MWCOORD bottom);
520
MWCLIPREGION *GdAllocRectRegionIndirect(MWRECT *prc);
521
void GdSetRectRegion(MWCLIPREGION *rgn, MWCOORD left, MWCOORD top,
522
                MWCOORD right, MWCOORD bottom);
523
void GdSetRectRegionIndirect(MWCLIPREGION *rgn, MWRECT *prc);
524
void GdDestroyRegion(MWCLIPREGION *rgn);
525
void GdOffsetRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
526
int  GdGetRegionBox(MWCLIPREGION *rgn, MWRECT *prc);
527
void GdUnionRectWithRegion(const MWRECT *rect, MWCLIPREGION *rgn);
528
void GdSubtractRectFromRegion(const MWRECT *rect, MWCLIPREGION *rgn);
529
void GdCopyRegion(MWCLIPREGION *d, MWCLIPREGION *s);
530
void GdIntersectRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
531
void GdUnionRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
532
void GdSubtractRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
533
void GdXorRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
534
 
535
/* devrgn2.c*/
536
MWCLIPREGION *GdAllocPolygonRegion(MWPOINT *points, int count, int mode);
537
MWCLIPREGION *GdAllocPolyPolygonRegion(MWPOINT *points, int *count,
538
                int nbpolygons, int mode);
539
 
540
/* devmouse.c*/
541
int     GdOpenMouse(void);
542
void    GdCloseMouse(void);
543
void    GdGetButtonInfo(int *buttons);
544
void    GdRestrictMouse(MWCOORD newminx,MWCOORD newminy,MWCOORD newmaxx,
545
                MWCOORD newmaxy);
546
void    GdSetAccelMouse(int newthresh, int newscale);
547
void    GdMoveMouse(MWCOORD newx, MWCOORD newy);
548
int     GdReadMouse(MWCOORD *px, MWCOORD *py, int *pb);
549
void    GdMoveCursor(MWCOORD x, MWCOORD y);
550
MWBOOL  GdGetCursorPos(MWCOORD *px, MWCOORD *py);
551
void    GdSetCursor(PMWCURSOR pcursor);
552
int     GdShowCursor(PSD psd);
553
int     GdHideCursor(PSD psd);
554
void    GdCheckCursor(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2);
555
void    GdFixCursor(PSD psd);
556
extern MOUSEDEVICE mousedev;
557
 
558
/* devkbd.c*/
559
int     GdOpenKeyboard(void);
560
void    GdCloseKeyboard(void);
561
void    GdGetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers);
562
int     GdReadKeyboard(MWKEY *buf, MWKEYMOD *modifiers, MWSCANCODE *scancode);
563
extern KBDDEVICE kbddev;
564
 
565
/* devimage.c */
566
 
567
int     GdLoadImageFromBuffer(PSD psd, void *buffer, int size, int flags);
568
void    GdDrawImageFromBuffer(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
569
                 MWCOORD height, void *buffer, int size, int flags);
570
void    GdDrawImageFromFile(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
571
                MWCOORD height, char *path, int flags);
572
int     GdLoadImageFromFile(PSD psd, char *path, int flags);
573
void    GdDrawImageToFit(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
574
                MWCOORD height, int id);
575
void    GdFreeImage(int id);
576
MWBOOL  GdGetImageInfo(int id, PMWIMAGEINFO pii);
577
void    GdStretchImage(PMWIMAGEHDR src, MWCLIPRECT *srcrect, PMWIMAGEHDR dst,
578
                MWCLIPRECT *dstrect);
579
 
580
/* devlist.c*/
581
/* field offset*/
582
#define MWITEM_OFFSET(type, field)    ((long)&(((type *)0)->field))
583
 
584
void *  GdItemAlloc(unsigned int size);
585
void    GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem);
586
void    GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem);
587
void    GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem);
588
#define GdItemNew(type) ((type *)GdItemAlloc(sizeof(type)))
589
#define GdItemFree(ptr) free((void *)ptr)
590
 
591
/* return base item address from list ptr*/
592
#define GdItemAddr(p,type,list) ((type *)((long)p - MWITEM_OFFSET(type,list)))
593
 
594
#if UNIX || DOS_DJGPP
595
 
596
#include <sys/time.h>
597
 
598
typedef void (*MWTIMERCB)(void *);
599
 
600
#define  MWTIMER_ONESHOT         0 
601
#define  MWTIMER_PERIODIC        1
602
 
603
typedef struct mw_timer MWTIMER;
604
struct mw_timer {
605
        struct timeval  timeout;
606
        MWTIMERCB       callback;
607
        void            *arg;
608
        MWTIMER         *next;
609
        MWTIMER         *prev;
610
    int         type;     /* MWTIMER_ONESHOT or MWTIMER_PERIODIC */
611
    MWTIMEOUT   period;
612
};
613
 
614
MWTIMER         *GdAddTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);
615
MWTIMER         *GdAddPeriodicTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);
616
void            GdDestroyTimer(MWTIMER *timer);
617
MWTIMER         *GdFindTimer(void *arg);
618
MWBOOL          GdGetNextTimeout(struct timeval *tv, MWTIMEOUT timeout);
619
MWBOOL          GdTimeout(void);
620
 
621
#endif
622
 
623
/* error.c*/
624
int     GdError(const char *format, ...);
625
int     GdErrorNull(const char *format, ...);  /* doesn't print msgs */
626
 
627
#ifdef USE_ALLOCA
628
/* alloca() is available, so use it for better performance */
629
#define ALLOCA(size)    alloca(size)
630
#define FREEA(pmem)
631
#else
632
/* no alloca(), so use malloc()/free() instead */
633
#define ALLOCA(size)    malloc(size)
634
#define FREEA(pmem)     free(pmem)
635
#endif
636
 
637
/* no assert() in MSDOS or ELKS...*/
638
#if MSDOS | ELKS
639
#undef assert
640
#define assert(x)
641
#endif
642
 
643
/* RTEMS requires rtems_main()*/
644
#if __rtems__
645
#define main    rtems_main
646
#endif
647
 
648
#if !_MINIX
649
#ifndef __rtems__
650
#define HAVESELECT      1       /* has select system call*/
651
#endif
652
#endif
653
 
654
#endif /*_DEVICE_H*/

powered by: WebSVN 2.1.0

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