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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [services/] [gfx/] [mw/] [current/] [include/] [microwin/] [device.h] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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