10 #if GFX_USE_GDISP && GDISP_NEED_PIXMAP
14 #undef GDISP_HARDWARE_DEINIT
15 #undef GDISP_HARDWARE_FLUSH
16 #undef GDISP_HARDWARE_STREAM_WRITE
17 #undef GDISP_HARDWARE_STREAM_READ
18 #undef GDISP_HARDWARE_STREAM_POS
19 #undef GDISP_HARDWARE_DRAWPIXEL
20 #undef GDISP_HARDWARE_CLEARS
21 #undef GDISP_HARDWARE_FILLS
22 #undef GDISP_HARDWARE_BITFILLS
23 #undef GDISP_HARDWARE_SCROLL
24 #undef GDISP_HARDWARE_PIXELREAD
25 #undef GDISP_HARDWARE_CONTROL
26 #undef GDISP_HARDWARE_QUERY
27 #undef GDISP_HARDWARE_CLIP
28 #define GDISP_HARDWARE_DEINIT GFXON
29 #define GDISP_HARDWARE_DRAWPIXEL GFXON
30 #define GDISP_HARDWARE_PIXELREAD GFXON
31 #define GDISP_HARDWARE_CONTROL GFXON
32 #define IN_PIXMAP_DRIVER GFXON
33 #define GDISP_DRIVER_VMT GDISPVMT_pixmap
34 #define GDISP_DRIVER_VMT_FLAGS (GDISP_VFLG_DYNAMICONLY|GDISP_VFLG_PIXMAP)
38 #if (GDISP_LLD_PIXELFORMAT & GDISP_COLORSYSTEM_GRAYSCALE) && (GDISP_LLD_PIXELFORMAT & 0xFF) != 8
39 #error "GDISP Pixmap: Pixmap's do not currently support the specified GDISP_LLD_PIXELFORMAT"
43 #include "../gdriver/gdriver.h"
45 typedef struct pixmap {
46 #if GDISP_NEED_PIXMAP_IMAGE
58 i = width*height*
sizeof(
gColor);
63 if (!(p =
gfxAlloc(i+
sizeof(pixmap)-
sizeof(p->pixels))))
67 #if GDISP_NEED_PIXMAP_IMAGE
70 p->imghdr[2] = (gU8)(width >> 8);
71 p->imghdr[3] = (gU8)width;
72 p->imghdr[4] = (gU8)(height >> 8);
73 p->imghdr[5] = (gU8)height;
74 p->imghdr[6] = (gU8)(GDISP_PIXELFORMAT >> 8);
75 p->imghdr[7] = (gU8)(GDISP_PIXELFORMAT);
79 ((
gCoord *)p->pixels)[0] = width;
80 ((
gCoord *)p->pixels)[1] = height;
90 if (gvmt(g) != GDISPVMT_pixmap)
96 if (gvmt(g) != GDISPVMT_pixmap)
98 return ((pixmap *)g->priv)->pixels;
101 #if GDISP_NEED_PIXMAP_IMAGE
103 if (gvmt(g) != GDISPVMT_pixmap)
105 return ((pixmap *)g->priv)->imghdr;
113 LLDSPEC gBool gdisp_lld_init(GDisplay *g) {
121 g->g.Width = ((
gCoord *)((pixmap *)g->priv)->pixels)[0];
122 g->g.Height = ((
gCoord *)((pixmap *)g->priv)->pixels)[1];
123 g->g.Backlight = 100;
132 LLDSPEC
void gdisp_lld_deinit(GDisplay *g) {
136 LLDSPEC
void gdisp_lld_draw_pixel(GDisplay *g) {
139 #if GDISP_NEED_CONTROL
140 switch(g->g.Orientation) {
143 pos = g->p.y * g->g.Width + g->p.x;
146 pos = (g->g.Width-g->p.x-1) * g->g.Height + g->p.y;
149 pos = (g->g.Height-g->p.y-1) * g->g.Width + g->g.Width-g->p.x-1;
152 pos = g->p.x * g->g.Height + g->g.Height-g->p.y-1;
156 pos = g->p.y * g->g.Width + g->p.x;
159 ((pixmap *)(g)->priv)->pixels[pos] = g->p.color;
162 LLDSPEC
gColor gdisp_lld_get_pixel_color(GDisplay *g) {
165 #if GDISP_NEED_CONTROL
166 switch(g->g.Orientation) {
169 pos = g->p.y * g->g.Width + g->p.x;
172 pos = (g->g.Width-g->p.x-1) * g->g.Height + g->p.y;
175 pos = (g->g.Height-g->p.y-1) * g->g.Width + g->g.Width-g->p.x-1;
178 pos = g->p.x * g->g.Height + g->g.Height-g->p.y-1;
182 pos = g->p.y * g->g.Width + g->p.x;
185 return ((pixmap *)(g)->priv)->pixels[pos];
188 #if GDISP_NEED_CONTROL
189 LLDSPEC
void gdisp_lld_control(GDisplay *g) {
191 case GDISP_CONTROL_ORIENTATION:
201 g->g.Width = g->g.Height;
211 g->g.Width = g->g.Height;
GDISP Graphic Driver subsystem low level driver header.
COLOR_TYPE gColor
The color type definition.
gColor gPixel
The pixel format.
gOrientation
Type for the screen orientation.
gI16 gCoord
The type for a coordinate or length on the screen.
GDriver * gdriverRegister(const GDriverVMT *vmt, void *param)
Register a new driver instance.
void gdriverUnRegister(GDriver *driver)
UnRegister a driver instance.
void * gfxAlloc(gMemSize sz)
Allocate memory.
void gfxFree(void *ptr)
Free memory.
gPixel * gdispPixmapGetBits(GDisplay *g)
Get a pointer to the pixels of the display surface.
void gdispPixmapDelete(GDisplay *g)
Destroy an off-screen pixmap.
GDisplay * gdispPixmapCreate(gCoord width, gCoord height)
Create an off-screen pixmap that can be drawn to just like a normal display.
void * gdispPixmapGetMemoryImage(GDisplay *g)
Get a pointer to a native format gImage.