diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gdisp/gdisp.c | 1773 | ||||
-rw-r--r-- | src/gfx.c | 1 |
2 files changed, 910 insertions, 864 deletions
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c index 756d5c1d..41f2f0f9 100644 --- a/src/gdisp/gdisp.c +++ b/src/gdisp/gdisp.c @@ -31,81 +31,92 @@ #define INLINE #endif +// Number of milliseconds for the startup logo - 0 means disabled. +#define GDISP_STARTUP_LOGO_TIMEOUT 1000 + /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ -#define GC ((GDISPDriver *)GDISP) -GDISPControl *GDISP = &GDISP_DRIVER_STRUCT.g; +// The controller array, the display array and the default display +#if GDISP_TOTAL_CONTROLLERS > 1 + typedef const struct GDISPVMT const VMTEL[1]; + extern VMTEL GDISP_CONTROLLER_LIST; + static const struct GDISPVMT const * ControllerList[GDISP_TOTAL_CONTROLLERS] = {GDISP_CONTROLLER_LIST}; + static const unsigned DisplayCountList[GDISP_TOTAL_CONTROLLERS] = {GDISP_CONTROLLER_DISPLAYS}; +#endif +static GDisplay GDisplayArray[GDISP_TOTAL_DISPLAYS]; +GDisplay *GDISP = GDisplayArray; #if GDISP_NEED_MULTITHREAD - #define MUTEX_INIT() gfxMutexInit(&GC->mutex) - #define MUTEX_ENTER() gfxMutexEnter(&GC->mutex) - #define MUTEX_EXIT() gfxMutexExit(&GC->mutex) + #define MUTEX_INIT(g) gfxMutexInit(&(g)->mutex) + #define MUTEX_ENTER(g) gfxMutexEnter(&(g)->mutex) + #define MUTEX_EXIT(g) gfxMutexExit(&(g)->mutex) #else - #define MUTEX_INIT() - #define MUTEX_ENTER() - #define MUTEX_EXIT() + #define MUTEX_INIT(g) + #define MUTEX_ENTER(g) + #define MUTEX_EXIT(g) #endif #define NEED_CLIPPING (!GDISP_HARDWARE_CLIP && (GDISP_NEED_VALIDATION || GDISP_NEED_CLIP)) + /*==========================================================================*/ /* Internal functions. */ /*==========================================================================*/ #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - static INLINE void setglobalwindow(void) { + static INLINE void setglobalwindow(GDisplay *g) { coord_t x, y; - x = GC->p.x; y = GC->p.y; - GC->p.cx = GC->g.Width; GC->p.cy = GC->g.Height; - gdisp_lld_write_start(GC); - GC->p.x = x; GC->p.y = y; - GC->flags |= GDISP_FLG_SCRSTREAM; + x = g->p.x; y = g->p.y; + g->p.cx = g->g.Width; g->p.cy = g->g.Height; + gdisp_lld_write_start(g); + g->p.x = x; g->p.y = y; + g->flags |= GDISP_FLG_SCRSTREAM; } #endif -// drawpixel_clip() +// drawpixel_clip(g) // Parameters: x,y // Alters: cx, cy (if using streaming) #if GDISP_HARDWARE_DRAWPIXEL // Best is hardware accelerated pixel draw #if NEED_CLIPPING - static INLINE void drawpixel_clip(void) { - if (GC->p.x >= GC->clipx0 && GC->p.x < GC->clipx1 && GC->p.y >= GC->clipy0 && GC->p.y < GC->clipy1) - gdisp_lld_draw_pixel(GC); + static INLINE void drawpixel_clip(GDisplay *g) { + if (g->p.x >= g->clipx0 && g->p.x < g->clipx1 && g->p.y >= g->clipy0 && g->p.y < g->clipy1) + gdisp_lld_draw_pixel(g); } #else - #define drawpixel_clip() gdisp_lld_draw_pixel(GC) + #define drawpixel_clip(g) gdisp_lld_draw_pixel(g) #endif #elif GDISP_HARDWARE_STREAM_POS // Next best is cursor based streaming - static INLINE void drawpixel_clip(void) { + static INLINE void drawpixel_clip(GDisplay *g) { #if NEED_CLIPPING - if (GC->p.x < GC->clipx0 || GC->p.x >= GC->clipx1 || GC->p.y < GC->clipy0 || GC->p.y >= GC->clipy1) + if (g->p.x < g->clipx0 || g->p.x >= g->clipx1 || g->p.y < g->clipy0 || g->p.y >= g->clipy1) return; #endif - if (!(GC->flags & GDISP_FLG_SCRSTREAM)) - setglobalwindow(); - gdisp_lld_write_pos(GC); - gdisp_lld_write_color(GC); + if (!(g->flags & GDISP_FLG_SCRSTREAM)) + setglobalwindow(g); + gdisp_lld_write_pos(g); + gdisp_lld_write_color(g); } #else // Worst is streaming - static INLINE void drawpixel_clip(void) { + static INLINE void drawpixel_clip(GDisplay *g) { #if NEED_CLIPPING - if (GC->p.x < GC->clipx0 || GC->p.x >= GC->clipx1 || GC->p.y < GC->clipy0 || GC->p.y >= GC->clipy1) + if (g->p.x < g->clipx0 || g->p.x >= g->clipx1 || g->p.y < g->clipy0 || g->p.y >= g->clipy1) return; #endif - GC->p.cx = GC->p.cy = 1; - gdisp_lld_write_start(GC); - gdisp_lld_write_color(GC); - gdisp_lld_write_stop(GC); + g->p.cx = g->p.cy = 1; + gdisp_lld_write_start(g); + gdisp_lld_write_color(g); + gdisp_lld_write_stop(g); } #endif -// fillarea() +// fillarea(g) // Parameters: x,y cx,cy and color // Alters: nothing // Note: This is not clipped @@ -113,94 +124,94 @@ GDISPControl *GDISP = &GDISP_DRIVER_STRUCT.g; // if GDISP_HARDWARE_STREAM_WRITE and GDISP_HARDWARE_STREAM_POS is set. #if GDISP_HARDWARE_FILLS // Best is hardware accelerated area fill - #define fillarea() gdisp_lld_fill_area(GC) + #define fillarea(g) gdisp_lld_fill_area(g) #elif GDISP_HARDWARE_STREAM_WRITE // Next best is hardware streaming - static INLINE void fillarea(void) { + static INLINE void fillarea(GDisplay *g) { uint32_t area; - area = (uint32_t)GC->p.cx * GC->p.cy; + area = (uint32_t)g->p.cx * g->p.cy; #if GDISP_HARDWARE_STREAM_POS - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - gdisp_lld_write_start(GC); + gdisp_lld_write_start(g); #if GDISP_HARDWARE_STREAM_POS - gdisp_lld_write_pos(GC); + gdisp_lld_write_pos(g); #endif for(; area; area--) - gdisp_lld_write_color(GC); - gdisp_lld_write_stop(GC); + gdisp_lld_write_color(g); + gdisp_lld_write_stop(g); } #else // Worst is drawing pixels - static INLINE void fillarea(void) { + static INLINE void fillarea(GDisplay *g) { coord_t x0, y0, x1, y1; - x0 = GC->p.x; - y0 = GC->p.y; - x1 = GC->p.x + GC->p.cx; - y1 = GC->p.y + GC->p.cy; - for(; GC->p.y < y1; GC->p.y++, GC->p.x = x0) - for(; GC->p.x < x1; GC->p.x++) - gdisp_lld_draw_pixel(GC); - GC->p.y = y0; + x0 = g->p.x; + y0 = g->p.y; + x1 = g->p.x + g->p.cx; + y1 = g->p.y + g->p.cy; + for(; g->p.y < y1; g->p.y++, g->p.x = x0) + for(; g->p.x < x1; g->p.x++) + gdisp_lld_draw_pixel(g); + g->p.y = y0; } #endif #if NEED_CLIPPING - #define TEST_CLIP_AREA(x,y,cx,cy) \ - if ((x) < GC->clipx0) { (cx) -= GC->clipx0 - (x); (x) = GC->clipx0; } \ - if ((y) < GC->clipy0) { (cy) -= GC->clipy0 - (y); (y) = GC->clipy0; } \ - if ((x) + (cx) > GC->clipx1) (cx) = GC->clipx1 - (x); \ - if ((y) + (cy) > GC->clipy1) (cy) = GC->clipy1 - (y); \ - if ((cx) > 0 && (cy) > 0) + #define TEST_CLIP_AREA(g) \ + if ((g)->p.x < (g)->clipx0) { (g)->p.cx -= (g)->clipx0 - (g)->p.x; (g)->p.x = (g)->clipx0; } \ + if ((g)->p.y < (g)->clipy0) { (g)->p.cy -= (g)->clipy0 - (g)->p.y; (g)->p.y = (g)->clipy0; } \ + if ((g)->p.x + (g)->p.cx > (g)->clipx1) (g)->p.cx = (g)->clipx1 - (g)->p.x; \ + if ((g)->p.y + (g)->p.cy > (g)->clipy1) (g)->p.cy = (g)->clipy1 - (g)->p.y; \ + if ((g)->p.cx > 0 && (g)->p.cy > 0) #else - #define TEST_CLIP_AREA(x,y,cx,cy) + #define TEST_CLIP_AREA(g) #endif // Parameters: x,y and x1 // Alters: x,y x1,y1 cx,cy // Assumes the window covers the screen and a write_stop() will occur later // if GDISP_HARDWARE_STREAM_WRITE and GDISP_HARDWARE_STREAM_POS is set. -static void hline_clip(void) { +static void hline_clip(GDisplay *g) { // Swap the points if necessary so it always goes from x to x1 - if (GC->p.x1 < GC->p.x) { - GC->p.cx = GC->p.x; GC->p.x = GC->p.x1; GC->p.x1 = GC->p.cx; + if (g->p.x1 < g->p.x) { + g->p.cx = g->p.x; g->p.x = g->p.x1; g->p.x1 = g->p.cx; } // Clipping #if NEED_CLIPPING - if (GC->p.y < GC->clipy0 || GC->p.y >= GC->clipy1) return; - if (GC->p.x < GC->clipx0) GC->p.x = GC->clipx0; - if (GC->p.x1 >= GC->clipx1) GC->p.x1 = GC->clipx1 - 1; - if (GC->p.x1 < GC->p.x) return; + if (g->p.y < g->clipy0 || g->p.y >= g->clipy1) return; + if (g->p.x < g->clipx0) g->p.x = g->clipx0; + if (g->p.x1 >= g->clipx1) g->p.x1 = g->clipx1 - 1; + if (g->p.x1 < g->p.x) return; #endif // This is an optimization for the point case. It is only worthwhile however if we // have hardware fills or if we support both hardware pixel drawing and hardware streaming #if GDISP_HARDWARE_FILLS || (GDISP_HARDWARE_DRAWPIXEL && GDISP_HARDWARE_STREAM_WRITE) // Is this a point - if (GC->p.x == GC->p.x1) { + if (g->p.x == g->p.x1) { #if GDISP_HARDWARE_DRAWPIXEL // Best is hardware accelerated pixel draw - gdisp_lld_draw_pixel(GC); + gdisp_lld_draw_pixel(g); #elif GDISP_HARDWARE_STREAM_POS // Next best is cursor based streaming - if (!(GC->flags & GDISP_FLG_SCRSTREAM)) - setglobalwindow(); - gdisp_lld_write_pos(GC); - gdisp_lld_write_color(GC); + if (!(g->flags & GDISP_FLG_SCRSTREAM)) + setglobalwindow(g); + gdisp_lld_write_pos(g); + gdisp_lld_write_color(g); #else // Worst is streaming - GC->p.cx = GC->p.cy = 1; - gdisp_lld_write_start(GC); - gdisp_lld_write_color(GC); - gdisp_lld_write_stop(GC); + g->p.cx = g->p.cy = 1; + gdisp_lld_write_start(g); + gdisp_lld_write_color(g); + gdisp_lld_write_stop(g); #endif return; } @@ -208,65 +219,65 @@ static void hline_clip(void) { #if GDISP_HARDWARE_FILLS // Best is hardware accelerated area fill - GC->p.cx = GC->p.x1 - GC->p.x + 1; - GC->p.cy = 1; - gdisp_lld_fill_area(GC); + g->p.cx = g->p.x1 - g->p.x + 1; + g->p.cy = 1; + gdisp_lld_fill_area(g); #elif GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE // Next best is cursor based streaming - if (!(GC->flags & GDISP_FLG_SCRSTREAM)) - setglobalwindow(); - gdisp_lld_write_pos(GC); - do { gdisp_lld_write_color(GC); } while(GC->p.cx--); + if (!(g->flags & GDISP_FLG_SCRSTREAM)) + setglobalwindow(g); + gdisp_lld_write_pos(g); + do { gdisp_lld_write_color(g); } while(g->p.cx--); #elif GDISP_HARDWARE_STREAM_WRITE // Next best is streaming - GC->p.cx = GC->p.x1 - GC->p.x + 1; - GC->p.cy = 1; - gdisp_lld_write_start(GC); - do { gdisp_lld_write_color(GC); } while(GC->p.cx--); - gdisp_lld_write_stop(GC); + g->p.cx = g->p.x1 - g->p.x + 1; + g->p.cy = 1; + gdisp_lld_write_start(g); + do { gdisp_lld_write_color(g); } while(g->p.cx--); + gdisp_lld_write_stop(g); #else // Worst is drawing pixels - for(; GC->p.x <= GC->p.x1; GC->p.x++) - gdisp_lld_draw_pixel(GC); + for(; g->p.x <= g->p.x1; g->p.x++) + gdisp_lld_draw_pixel(g); #endif } // Parameters: x,y and y1 // Alters: x,y x1,y1 cx,cy -static void vline_clip(void) { +static void vline_clip(GDisplay *g) { // Swap the points if necessary so it always goes from y to y1 - if (GC->p.y1 < GC->p.y) { - GC->p.cy = GC->p.y; GC->p.y = GC->p.y1; GC->p.y1 = GC->p.cy; + if (g->p.y1 < g->p.y) { + g->p.cy = g->p.y; g->p.y = g->p.y1; g->p.y1 = g->p.cy; } // Clipping #if NEED_CLIPPING - if (GC->p.x < GC->clipx0 || GC->p.x >= GC->clipx1) return; - if (GC->p.y < GC->clipy0) GC->p.y = GC->clipy0; - if (GC->p.y1 >= GC->clipy1) GC->p.y1 = GC->clipy1 - 1; - if (GC->p.y1 < GC->p.y) return; + if (g->p.x < g->clipx0 || g->p.x >= g->clipx1) return; + if (g->p.y < g->clipy0) g->p.y = g->clipy0; + if (g->p.y1 >= g->clipy1) g->p.y1 = g->clipy1 - 1; + if (g->p.y1 < g->p.y) return; #endif // This is an optimization for the point case. It is only worthwhile however if we // have hardware fills or if we support both hardware pixel drawing and hardware streaming #if GDISP_HARDWARE_FILLS || (GDISP_HARDWARE_DRAWPIXEL && GDISP_HARDWARE_STREAM_WRITE) || (GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE) // Is this a point - if (GC->p.y == GC->p.y1) { + if (g->p.y == g->p.y1) { #if GDISP_HARDWARE_DRAWPIXEL // Best is hardware accelerated pixel draw - gdisp_lld_draw_pixel(GC); + gdisp_lld_draw_pixel(g); #elif GDISP_HARDWARE_STREAM_POS // Next best is cursor based streaming - if (!(GC->flags & GDISP_FLG_SCRSTREAM)) - setglobalwindow(); - gdisp_lld_write_pos(GC); - gdisp_lld_write_color(GC); + if (!(g->flags & GDISP_FLG_SCRSTREAM)) + setglobalwindow(g); + gdisp_lld_write_pos(g); + gdisp_lld_write_color(g); #else // Worst is streaming - GC->p.cx = GC->p.cy = 1; - gdisp_lld_write_start(GC); - gdisp_lld_write_color(GC); - gdisp_lld_write_stop(GC); + g->p.cx = g->p.cy = 1; + gdisp_lld_write_start(g); + gdisp_lld_write_color(g); + gdisp_lld_write_stop(g); #endif return; } @@ -274,48 +285,48 @@ static void vline_clip(void) { #if GDISP_HARDWARE_FILLS // Best is hardware accelerated area fill - GC->p.cy = GC->p.y1 - GC->p.y + 1; - GC->p.cx = 1; - gdisp_lld_fill_area(GC); + g->p.cy = g->p.y1 - g->p.y + 1; + g->p.cx = 1; + gdisp_lld_fill_area(g); #elif GDISP_HARDWARE_STREAM_WRITE // Next best is streaming #if GDISP_HARDWARE_STREAM_POS - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - GC->p.cy = GC->p.y1 - GC->p.y + 1; - GC->p.cx = 1; - gdisp_lld_write_start(GC); + g->p.cy = g->p.y1 - g->p.y + 1; + g->p.cx = 1; + gdisp_lld_write_start(g); #if GDISP_HARDWARE_STREAM_POS - gdisp_lld_write_pos(GC); + gdisp_lld_write_pos(g); #endif - do { gdisp_lld_write_color(GC); } while(GC->p.cy--); - gdisp_lld_write_stop(GC); + do { gdisp_lld_write_color(g); } while(g->p.cy--); + gdisp_lld_write_stop(g); #else // Worst is drawing pixels - for(; GC->p.y <= GC->p.y1; GC->p.y++) - gdisp_lld_draw_pixel(GC); + for(; g->p.y <= g->p.y1; g->p.y++) + gdisp_lld_draw_pixel(g); #endif } // Parameters: x,y and x1,y1 // Alters: x,y x1,y1 cx,cy -static void line_clip(void) { +static void line_clip(GDisplay *g) { int16_t dy, dx; int16_t addx, addy; int16_t P, diff, i; // Is this a horizontal line (or a point) - if (GC->p.y == GC->p.y1) { - hline_clip(); + if (g->p.y == g->p.y1) { + hline_clip(g); return; } // Is this a vertical line (or a point) - if (GC->p.x == GC->p.x1) { - vline_clip(); + if (g->p.x == g->p.x1) { + vline_clip(g); return; } @@ -327,18 +338,18 @@ static void line_clip(void) { // When clipping is needed, all the clipping could also be done up front // instead of on each pixel. - if (GC->p.x1 >= GC->p.x) { - dx = GC->p.x1 - GC->p.x; + if (g->p.x1 >= g->p.x) { + dx = g->p.x1 - g->p.x; addx = 1; } else { - dx = GC->p.x - GC->p.x1; + dx = g->p.x - g->p.x1; addx = -1; } - if (GC->p.y1 >= GC->p.y) { - dy = GC->p.y1 - GC->p.y; + if (g->p.y1 >= g->p.y) { + dy = g->p.y1 - g->p.y; addy = 1; } else { - dy = GC->p.y - GC->p.y1; + dy = g->p.y - g->p.y1; addy = -1; } @@ -348,14 +359,14 @@ static void line_clip(void) { diff = P - dx; for(i=0; i<=dx; ++i) { - drawpixel_clip(); + drawpixel_clip(g); if (P < 0) { P += dy; - GC->p.x += addx; + g->p.x += addx; } else { P += diff; - GC->p.x += addx; - GC->p.y += addy; + g->p.x += addx; + g->p.y += addy; } } } else { @@ -364,90 +375,126 @@ static void line_clip(void) { diff = P - dy; for(i=0; i<=dy; ++i) { - drawpixel_clip(); + drawpixel_clip(g); if (P < 0) { P += dx; - GC->p.y += addy; + g->p.y += addy; } else { P += diff; - GC->p.x += addx; - GC->p.y += addy; + g->p.x += addx; + g->p.y += addy; } } } } +#if GDISP_STARTUP_LOGO_TIMEOUT > 0 + static void StatupLogoDisplay(GDisplay *g) { + gdispGClear(g, Black); + gdispGFillArea(g, g->g.Width/4, g->g.Height/4, g->g.Width/2, g->g.Height/2, Blue); + } +#endif + /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/ /* Our module initialiser */ void _gdispInit(void) { - MUTEX_INIT(); + GDisplay *g; + unsigned i; + #if GDISP_TOTAL_CONTROLLERS > 1 + unsigned j; + #endif + /* Initialise driver */ - MUTEX_ENTER(); - GC->flags = 0; - gdisp_lld_init(GC); - #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP - #if GDISP_HARDWARE_CLIP - GC->p.x = x; - GC->p.y = y; - GC->p.cx = cx; - GC->p.cy = cy; - gdisp_lld_set_clip(GC); - #else - GC->clipx0 = 0; - GC->clipy0 = 0; - GC->clipx1 = GC->g.Width; - GC->clipy1 = GC->g.Height; - #endif + #if GDISP_TOTAL_CONTROLLERS > 1 + for(g = GDisplayArray, j=0; j < GDISP_TOTAL_CONTROLLERS; j++) + for(i = 0; i < DisplayCountList[j]; g++, i++) { + g->vmt = ControllerList[j]; + #else + for(g = GDisplayArray, i = 0; i < GDISP_TOTAL_DISPLAYS; g++, i++) { + #endif + MUTEX_INIT(g); + MUTEX_ENTER(g); + g->flags = 0; + gdisp_lld_init(g, i); + #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP + #if GDISP_HARDWARE_CLIP + g->p.x = x; + g->p.y = y; + g->p.cx = cx; + g->p.cy = cy; + gdisp_lld_set_clip(g); + #else + g->clipx0 = 0; + g->clipy0 = 0; + g->clipx1 = g->g.Width; + g->clipy1 = g->g.Height; + #endif + #endif + MUTEX_EXIT(g); + #if GDISP_STARTUP_LOGO_TIMEOUT > 0 + StatupLogoDisplay(g); + #else + gdispGClear(g, Black); + #endif + } + #if GDISP_STARTUP_LOGO_TIMEOUT > 0 + gfxSleepMilliseconds(GDISP_STARTUP_LOGO_TIMEOUT); + for(g = GDisplayArray, i = 0; i < GDISP_TOTAL_DISPLAYS; g++, i++) + gdispGClear(g, Black); #endif - MUTEX_EXIT(); +} + +void gdispSetDisplay(unsigned display) { + if (display < GDISP_TOTAL_DISPLAYS) + GDISP = &GDisplayArray[display]; } #if GDISP_NEED_STREAMING - void gdispStreamStart(coord_t x, coord_t y, coord_t cx, coord_t cy) { - MUTEX_ENTER(); + void gdispGStreamStart(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy) { + MUTEX_ENTER(g); #if NEED_CLIPPING // Test if the area is valid - if not then exit - if (x < GC->clipx0 || x+cx > GC->clipx1 || y < GC->clipy0 || y+cy > GC->clipy1) { - MUTEX_EXIT(); + if (x < g->clipx0 || x+cx > g->clipx1 || y < g->clipy0 || y+cy > g->clipy1) { + MUTEX_EXIT(g); return; } #endif - GC->flags |= GDISP_FLG_INSTREAM; + g->flags |= GDISP_FLG_INSTREAM; #if GDISP_HARDWARE_STREAM_WRITE // Best is hardware streaming - GC->p.x = x; - GC->p.y = y; - GC->p.cx = cx; - GC->p.cy = cy; - gdisp_lld_write_start(GC); + g->p.x = x; + g->p.y = y; + g->p.cx = cx; + g->p.cy = cy; + gdisp_lld_write_start(g); #if GDISP_HARDWARE_STREAM_POS - gdisp_lld_write_pos(GC); + gdisp_lld_write_pos(g); #endif #else // Worst - save the parameters and use pixel drawing // Use x,y as the current position, x1,y1 as the save position and x2,y2 as the end position, cx = bufpos - GC->p.x1 = GC->p.x = x; - GC->p.y1 = GC->p.y = y; - GC->p.x2 = x + cx; - GC->p.y2 = y + cy; + g->p.x1 = g->p.x = x; + g->p.y1 = g->p.y = y; + g->p.x2 = x + cx; + g->p.y2 = y + cy; #if (GDISP_LINEBUF_SIZE != 0 && GDISP_HARDWARE_BITFILLS) || GDISP_HARDWARE_FILLS - GC->p.cx = 0; - GC->p.cy = 1; + g->p.cx = 0; + g->p.cy = 1; #endif #endif // Don't release the mutex as gdispStreamEnd() will do that. } - void gdispStreamColor(color_t color) { + void gdispGStreamColor(GDisplay *g, color_t color) { #if !GDISP_HARDWARE_STREAM_WRITE && GDISP_LINEBUF_SIZE != 0 && GDISP_HARDWARE_BITFILLS coord_t sx1, sy1; #endif @@ -455,224 +502,224 @@ void _gdispInit(void) { // Don't touch the mutex as we should already own it // Ignore this call if we are not streaming - if (!(GC->flags & GDISP_FLG_INSTREAM)) + if (!(g->flags & GDISP_FLG_INSTREAM)) return; #if GDISP_HARDWARE_STREAM_WRITE // Best is hardware streaming - GC->p.color = color; - gdisp_lld_write_color(GC); + g->p.color = color; + gdisp_lld_write_color(g); #elif GDISP_LINEBUF_SIZE != 0 && GDISP_HARDWARE_BITFILLS - GC->linebuf[GC->p.cx++] = color; - if (GC->p.cx >= GDISP_LINEBUF_SIZE) { - sx1 = GC->p.x1; - sy1 = GC->p.y1; - GC->p.x1 = 0; - GC->p.y1 = 0; - GC->p.ptr = (void *)GC->linebuf; - gdisp_lld_blit_area(GC); - GC->p.x1 = sx1; - GC->p.y1 = sy1; - GC->p.x += GC->p.cx; - GC->p.cx = 0; + g->linebuf[g->p.cx++] = color; + if (g->p.cx >= GDISP_LINEBUF_SIZE) { + sx1 = g->p.x1; + sy1 = g->p.y1; + g->p.x1 = 0; + g->p.y1 = 0; + g->p.ptr = (void *)g->linebuf; + gdisp_lld_blit_area(g); + g->p.x1 = sx1; + g->p.y1 = sy1; + g->p.x += g->p.cx; + g->p.cx = 0; } // Just wrap at end-of-line and end-of-buffer - if (GC->p.x+GC->p.cx >= GC->p.x2) { - if (GC->p.cx) { - sx1 = GC->p.x1; - sy1 = GC->p.y1; - GC->p.x1 = 0; - GC->p.y1 = 0; - GC->p.ptr = (void *)GC->linebuf; - gdisp_lld_blit_area(GC); - GC->p.x1 = sx1; - GC->p.y1 = sy1; - GC->p.cx = 0; + if (g->p.x+g->p.cx >= g->p.x2) { + if (g->p.cx) { + sx1 = g->p.x1; + sy1 = g->p.y1; + g->p.x1 = 0; + g->p.y1 = 0; + g->p.ptr = (void *)g->linebuf; + gdisp_lld_blit_area(g); + g->p.x1 = sx1; + g->p.y1 = sy1; + g->p.cx = 0; } - GC->p.x = GC->p.x1; - if (++GC->p.y >= GC->p.y2) - GC->p.y = GC->p.y1; + g->p.x = g->p.x1; + if (++g->p.y >= g->p.y2) + g->p.y = g->p.y1; } #elif GDISP_HARDWARE_FILLS // Only slightly better than drawing pixels is to look for runs and use fill area - if (!GC->p.cx || GC->p.color == color) { - GC->p.cx++; - GC->p.color = color; + if (!g->p.cx || g->p.color == color) { + g->p.cx++; + g->p.color = color; } else { - if (GC->p.cx == 1) - gdisp_lld_draw_pixel(GC); + if (g->p.cx == 1) + gdisp_lld_draw_pixel(g); else - gdisp_lld_fill_area(GC); - GC->p.x += GC->p.cx; - GC->p.color = color; - GC->p.cx = 1; + gdisp_lld_fill_area(g); + g->p.x += g->p.cx; + g->p.color = color; + g->p.cx = 1; } // Just wrap at end-of-line and end-of-buffer - if (GC->p.x+GC->p.cx >= GC->p.x2) { - if (GC->p.cx) { - if (GC->p.cx == 1) - gdisp_lld_draw_pixel(GC); + if (g->p.x+g->p.cx >= g->p.x2) { + if (g->p.cx) { + if (g->p.cx == 1) + gdisp_lld_draw_pixel(g); else - gdisp_lld_fill_area(GC); - GC->p.cx = 0; + gdisp_lld_fill_area(g); + g->p.cx = 0; } - GC->p.x = GC->p.x1; - if (++GC->p.y >= GC->p.y2) - GC->p.y = GC->p.y1; + g->p.x = g->p.x1; + if (++g->p.y >= g->p.y2) + g->p.y = g->p.y1; } #else // Worst is using pixel drawing - GC->p.color = color; - gdisp_lld_draw_pixel(GC); + g->p.color = color; + gdisp_lld_draw_pixel(g); // Just wrap at end-of-line and end-of-buffer - if (++GC->p.x >= GC->p.x2) { - GC->p.x = GC->p.x1; - if (++GC->p.y >= GC->p.y2) - GC->p.y = GC->p.y1; + if (++g->p.x >= g->p.x2) { + g->p.x = g->p.x1; + if (++g->p.y >= g->p.y2) + g->p.y = g->p.y1; } #endif } - void gdispStreamStop(void) { + void gdispGStreamStop(GDisplay *g) { // Only release the mutex and end the stream if we are actually streaming. - if (!(GC->flags & GDISP_FLG_INSTREAM)) + if (!(g->flags & GDISP_FLG_INSTREAM)) return; #if GDISP_HARDWARE_STREAM_WRITE - gdisp_lld_write_stop(GC); + gdisp_lld_write_stop(g); #elif GDISP_LINEBUF_SIZE != 0 && GDISP_HARDWARE_BITFILLS - if (GC->p.cx) { - GC->p.x1 = 0; - GC->p.y1 = 0; - GC->p.ptr = (void *)GC->linebuf; - gdisp_lld_blit_area(GC); + if (g->p.cx) { + g->p.x1 = 0; + g->p.y1 = 0; + g->p.ptr = (void *)g->linebuf; + gdisp_lld_blit_area(g); } #elif GDISP_HARDWARE_FILLS - if (GC->p.cx) { - if (GC->p.cx == 1) - gdisp_lld_draw_pixel(GC); + if (g->p.cx) { + if (g->p.cx == 1) + gdisp_lld_draw_pixel(g); else - gdisp_lld_fill_area(GC); + gdisp_lld_fill_area(g); } #endif - GC->flags &= ~GDISP_FLG_INSTREAM; - MUTEX_EXIT(); + g->flags &= ~GDISP_FLG_INSTREAM; + MUTEX_EXIT(g); } #endif -void gdispDrawPixel(coord_t x, coord_t y, color_t color) { - MUTEX_ENTER(); - GC->p.x = x; - GC->p.y = y; - GC->p.color = color; - drawpixel_clip(); +void gdispGDrawPixel(GDisplay *g, coord_t x, coord_t y, color_t color) { + MUTEX_ENTER(g); + g->p.x = x; + g->p.y = y; + g->p.color = color; + drawpixel_clip(g); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } -void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - MUTEX_ENTER(); - GC->p.x = x0; - GC->p.y = y0; - GC->p.x1 = x1; - GC->p.y1 = y1; - GC->p.color = color; - line_clip(); +void gdispGDrawLine(GDisplay *g, coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + MUTEX_ENTER(g); + g->p.x = x0; + g->p.y = y0; + g->p.x1 = x1; + g->p.y1 = y1; + g->p.color = color; + line_clip(g); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } -void gdispClear(color_t color) { +void gdispGClear(GDisplay *g, color_t color) { // Note - clear() ignores the clipping area. It clears the screen. - MUTEX_ENTER(); + MUTEX_ENTER(g); #if GDISP_HARDWARE_CLEARS // Best is hardware accelerated clear - GC->p.color = color; - gdisp_lld_clear(GC); + g->p.color = color; + gdisp_lld_clear(g); #elif GDISP_HARDWARE_FILLS // Next best is hardware accelerated area fill - GC->p.x = GC->p.y = 0; - GC->p.cx = GC->g.Width; - GC->p.cy = GC->g.Height; - GC->p.color = color; - gdisp_lld_fill_area(GC); + g->p.x = g->p.y = 0; + g->p.cx = g->g.Width; + g->p.cy = g->g.Height; + g->p.color = color; + gdisp_lld_fill_area(g); #elif GDISP_HARDWARE_STREAM_WRITE // Next best is streaming uint32_t area; - GC->p.x = GC->p.y = 0; - GC->p.cx = GC->g.Width; - GC->p.cy = GC->g.Height; - GC->p.color = color; - area = (uint32_t)GC->p.cx * GC->p.cy; + g->p.x = g->p.y = 0; + g->p.cx = g->g.Width; + g->p.cy = g->g.Height; + g->p.color = color; + area = (uint32_t)g->p.cx * g->p.cy; - gdisp_lld_write_start(GC); + gdisp_lld_write_start(g); #if GDISP_HARDWARE_STREAM_POS - gdisp_lld_write_pos(GC); + gdisp_lld_write_pos(g); #endif for(; area; area--) - gdisp_lld_write_color(GC); - gdisp_lld_write_stop(GC); + gdisp_lld_write_color(g); + gdisp_lld_write_stop(g); #else // Worst is drawing pixels - GC->p.color = color; - for(GC->p.y = 0; GC->p.y < GC->g.Height; GC->p.y++) - for(GC->p.x = 0; GC->p.x < GC->g.Width; GC->p.x++) - gdisp_lld_draw_pixel(GC); + g->p.color = color; + for(g->p.y = 0; g->p.y < g->g.Height; g->p.y++) + for(g->p.x = 0; g->p.x < g->g.Width; g->p.x++) + gdisp_lld_draw_pixel(g); #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } -void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - MUTEX_ENTER(); - TEST_CLIP_AREA(x,y,cx,cy) { - GC->p.x = x; - GC->p.y = y; - GC->p.cx = cx; - GC->p.cy = cy; - GC->p.color = color; - fillarea(); +void gdispGFillArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + MUTEX_ENTER(g); + g->p.x = x; + g->p.y = y; + g->p.cx = cx; + g->p.cy = cy; + g->p.color = color; + TEST_CLIP_AREA(g) { + fillarea(g); } - MUTEX_EXIT(); + MUTEX_EXIT(g); } -void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { - MUTEX_ENTER(); +void gdispGBlitArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { + MUTEX_ENTER(g); #if NEED_CLIPPING - // This is a different cliping to fillarea() as it needs to take into account srcx,srcy - if (x < GC->clipx0) { cx -= GC->clipx0 - x; srcx += GC->clipx0 - x; x = GC->clipx0; } - if (y < GC->clipy0) { cy -= GC->clipy0 - y; srcy += GC->clipy0 - x; y = GC->clipy0; } - if (x+cx > GC->clipx1) cx = GC->clipx1 - x; - if (y+cy > GC->clipy1) cy = GC->clipy1 - y; + // This is a different cliping to fillarea(g) as it needs to take into account srcx,srcy + if (x < g->clipx0) { cx -= g->clipx0 - x; srcx += g->clipx0 - x; x = g->clipx0; } + if (y < g->clipy0) { cy -= g->clipy0 - y; srcy += g->clipy0 - x; y = g->clipy0; } + if (x+cx > g->clipx1) cx = g->clipx1 - x; + if (y+cy > g->clipy1) cy = g->clipy1 - y; if (srcx+cx > srccx) cx = srccx - srcx; - if (cx <= 0 || cy <= 0) { MUTEX_EXIT(); return; } + if (cx <= 0 || cy <= 0) { MUTEX_EXIT(g); return; } #endif #if GDISP_HARDWARE_BITFILLS // Best is hardware bitfills - GC->p.x = x; - GC->p.y = y; - GC->p.cx = cx; - GC->p.cy = cy; - GC->p.x1 = srcx; - GC->p.y1 = srcy; - GC->p.x2 = srccx; - GC->p.ptr = (void *)buffer; - gdisp_lld_blit_area(GC); + g->p.x = x; + g->p.y = y; + g->p.cx = cx; + g->p.cy = cy; + g->p.x1 = srcx; + g->p.y1 = srcy; + g->p.x2 = srccx; + g->p.ptr = (void *)buffer; + gdisp_lld_blit_area(g); #elif GDISP_HARDWARE_STREAM_WRITE // Next best is hardware streaming @@ -682,21 +729,21 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, srcy = y + cy; srccx -= cx; - GC->p.x = x; - GC->p.y = y; - GC->p.cx = cx; - GC->p.cy = cy; - gdisp_lld_write_start(GC); + g->p.x = x; + g->p.y = y; + g->p.cx = cx; + g->p.cy = cy; + gdisp_lld_write_start(g); #if GDISP_HARDWARE_STREAM_POS - gdisp_lld_write_pos(GC); + gdisp_lld_write_pos(g); #endif - for(GC->p.y = y; GC->p.y < srcy; GC->p.y++, buffer += srccx) { - for(GC->p.x = x; GC->p.x < srcx; GC->p.x++) { - GC->p.color = *buffer++; - gdisp_lld_write_color(GC); + for(g->p.y = y; g->p.y < srcy; g->p.y++, buffer += srccx) { + for(g->p.x = x; g->p.x < srcx; g->p.x++) { + g->p.color = *buffer++; + gdisp_lld_write_color(g); } } - gdisp_lld_write_stop(GC); + gdisp_lld_write_stop(g); #elif GDISP_HARDWARE_FILLS // Only slightly better than drawing pixels is to look for runs and use fill area @@ -706,19 +753,19 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, srcy = y + cy; srccx -= cx; - GC->p.cy = 1; - for(GC->p.y = y; GC->p.y < srcy; GC->p.y++, buffer += srccx) { - for(GC->p.x=x; GC->p.x < srcx; GC->p.x += GC->p.cx) { - GC->p.cx=1; - GC->p.color = *buffer++; - while(GC->p.x+GC->p.cx < srcx && *buffer == GC->p.color) { - GC->p.cx++; + g->p.cy = 1; + for(g->p.y = y; g->p.y < srcy; g->p.y++, buffer += srccx) { + for(g->p.x=x; g->p.x < srcx; g->p.x += g->p.cx) { + g->p.cx=1; + g->p.color = *buffer++; + while(g->p.x+g->p.cx < srcx && *buffer == g->p.color) { + g->p.cx++; buffer++; } - if (GC->p.cx == 1) { - gdisp_lld_draw_pixel(GC); + if (g->p.cx == 1) { + gdisp_lld_draw_pixel(g); } else { - gdisp_lld_fill_area(GC); + gdisp_lld_fill_area(g); } } } @@ -731,135 +778,135 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, srcy = y + cy; srccx -= cx; - for(GC->p.y = y; GC->p.y < srcy; GC->p.y++, buffer += srccx) { - for(GC->p.x=x; GC->p.x < srcx; GC->p.x++) { - GC->p.color = *buffer++; - gdisp_lld_draw_pixel(GC); + for(g->p.y = y; g->p.y < srcy; g->p.y++, buffer += srccx) { + for(g->p.x=x; g->p.x < srcx; g->p.x++) { + g->p.color = *buffer++; + gdisp_lld_draw_pixel(g); } } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #if GDISP_NEED_CLIP - void gdispSetClip(coord_t x, coord_t y, coord_t cx, coord_t cy) { - MUTEX_ENTER(); + void gdispGSetClip(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy) { + MUTEX_ENTER(g); #if GDISP_HARDWARE_CLIP // Best is using hardware clipping - GC->p.x = x; - GC->p.y = y; - GC->p.cx = cx; - GC->p.cy = cy; - gdisp_lld_set_clip(GC); + g->p.x = x; + g->p.y = y; + g->p.cx = cx; + g->p.cy = cy; + gdisp_lld_set_clip(g); #else // Worst is using software clipping if (x < 0) { cx += x; x = 0; } if (y < 0) { cy += y; y = 0; } - if (cx <= 0 || cy <= 0 || x >= GC->g.Width || y >= GC->g.Height) { MUTEX_EXIT(); return; } - GC->clipx0 = x; - GC->clipy0 = y; - GC->clipx1 = x+cx; if (GC->clipx1 > GC->g.Width) GC->clipx1 = GC->g.Width; - GC->clipy1 = y+cy; if (GC->clipy1 > GC->g.Height) GC->clipy1 = GC->g.Height; + if (cx <= 0 || cy <= 0 || x >= g->g.Width || y >= g->g.Height) { MUTEX_EXIT(g); return; } + g->clipx0 = x; + g->clipy0 = y; + g->clipx1 = x+cx; if (g->clipx1 > g->g.Width) g->clipx1 = g->g.Width; + g->clipy1 = y+cy; if (g->clipy1 > g->g.Height) g->clipy1 = g->g.Height; #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #endif #if GDISP_NEED_CIRCLE - void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color) { + void gdispGDrawCircle(GDisplay *g, coord_t x, coord_t y, coord_t radius, color_t color) { coord_t a, b, P; - MUTEX_ENTER(); + MUTEX_ENTER(g); // Calculate intermediates a = 1; b = radius; P = 4 - radius; - GC->p.color = color; + g->p.color = color; // Away we go using Bresenham's circle algorithm // Optimized to prevent double drawing - GC->p.x = x; GC->p.y = y + b; drawpixel_clip(); - GC->p.x = x; GC->p.y = y - b; drawpixel_clip(); - GC->p.x = x + b; GC->p.y = y; drawpixel_clip(); - GC->p.x = x - b; GC->p.y = y; drawpixel_clip(); + g->p.x = x; g->p.y = y + b; drawpixel_clip(g); + g->p.x = x; g->p.y = y - b; drawpixel_clip(g); + g->p.x = x + b; g->p.y = y; drawpixel_clip(g); + g->p.x = x - b; g->p.y = y; drawpixel_clip(g); do { - GC->p.x = x + a; GC->p.y = y + b; drawpixel_clip(); - GC->p.x = x + a; GC->p.y = y - b; drawpixel_clip(); - GC->p.x = x + b; GC->p.y = y + a; drawpixel_clip(); - GC->p.x = x - b; GC->p.y = y + a; drawpixel_clip(); - GC->p.x = x - a; GC->p.y = y + b; drawpixel_clip(); - GC->p.x = x - a; GC->p.y = y - b; drawpixel_clip(); - GC->p.x = x + b; GC->p.y = y - a; drawpixel_clip(); - GC->p.x = x - b; GC->p.y = y - a; drawpixel_clip(); + g->p.x = x + a; g->p.y = y + b; drawpixel_clip(g); + g->p.x = x + a; g->p.y = y - b; drawpixel_clip(g); + g->p.x = x + b; g->p.y = y + a; drawpixel_clip(g); + g->p.x = x - b; g->p.y = y + a; drawpixel_clip(g); + g->p.x = x - a; g->p.y = y + b; drawpixel_clip(g); + g->p.x = x - a; g->p.y = y - b; drawpixel_clip(g); + g->p.x = x + b; g->p.y = y - a; drawpixel_clip(g); + g->p.x = x - b; g->p.y = y - a; drawpixel_clip(g); if (P < 0) P += 3 + 2*a++; else P += 5 + 2*(a++ - b--); } while(a < b); - GC->p.x = x + a; GC->p.y = y + b; drawpixel_clip(); - GC->p.x = x + a; GC->p.y = y - b; drawpixel_clip(); - GC->p.x = x - a; GC->p.y = y + b; drawpixel_clip(); - GC->p.x = x - a; GC->p.y = y - b; drawpixel_clip(); + g->p.x = x + a; g->p.y = y + b; drawpixel_clip(g); + g->p.x = x + a; g->p.y = y - b; drawpixel_clip(g); + g->p.x = x - a; g->p.y = y + b; drawpixel_clip(g); + g->p.x = x - a; g->p.y = y - b; drawpixel_clip(g); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #endif #if GDISP_NEED_CIRCLE - void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color) { + void gdispGFillCircle(GDisplay *g, coord_t x, coord_t y, coord_t radius, color_t color) { coord_t a, b, P; - MUTEX_ENTER(); + MUTEX_ENTER(g); // Calculate intermediates a = 1; b = radius; P = 4 - radius; - GC->p.color = color; + g->p.color = color; // Away we go using Bresenham's circle algorithm // This is optimized to prevent overdrawing by drawing a line only when a variable is about to change value - GC->p.y = y; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); - GC->p.y = y+b; GC->p.x = x; drawpixel_clip(); - GC->p.y = y-b; GC->p.x = x; drawpixel_clip(); + g->p.y = y; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); + g->p.y = y+b; g->p.x = x; drawpixel_clip(g); + g->p.y = y-b; g->p.x = x; drawpixel_clip(g); do { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); if (P < 0) { P += 3 + 2*a++; } else { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); P += 5 + 2*(a++ - b--); } } while(a < b); - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #endif #if GDISP_NEED_ELLIPSE - void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + void gdispGDrawEllipse(GDisplay *g, coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { coord_t dx, dy; int32_t a2, b2; int32_t err, e2; - MUTEX_ENTER(); + MUTEX_ENTER(g); // Calculate intermediates dx = 0; @@ -867,14 +914,14 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, a2 = a*a; b2 = b*b; err = b2-(2*b-1)*a2; - GC->p.color = color; + g->p.color = color; // Away we go using Bresenham's ellipse algorithm do { - GC->p.x = x + dx; GC->p.y = y + dy; drawpixel_clip(); - GC->p.x = x - dx; GC->p.y = y + dy; drawpixel_clip(); - GC->p.x = x - dx; GC->p.y = y - dy; drawpixel_clip(); - GC->p.x = x + dx; GC->p.y = y - dy; drawpixel_clip(); + g->p.x = x + dx; g->p.y = y + dy; drawpixel_clip(g); + g->p.x = x - dx; g->p.y = y + dy; drawpixel_clip(g); + g->p.x = x - dx; g->p.y = y - dy; drawpixel_clip(g); + g->p.x = x + dx; g->p.y = y - dy; drawpixel_clip(g); e2 = 2*err; if(e2 < (2*dx+1)*b2) { @@ -888,22 +935,22 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, } while(dy >= 0); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #endif #if GDISP_NEED_ELLIPSE - void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + void gdispGFillEllipse(GDisplay *g, coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { coord_t dx, dy; int32_t a2, b2; int32_t err, e2; - MUTEX_ENTER(); + MUTEX_ENTER(g); // Calculate intermediates dx = 0; @@ -911,7 +958,7 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, a2 = a*a; b2 = b*b; err = b2-(2*b-1)*a2; - GC->p.color = color; + g->p.color = color; // Away we go using Bresenham's ellipse algorithm // This is optimized to prevent overdrawing by drawing a line only when a y is about to change value @@ -922,20 +969,20 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, err += (2*dx+1)*b2; } if(e2 > -(2*dy-1)*a2) { - GC->p.y = y + dy; GC->p.x = x - dx; GC->p.x1 = x + dx; hline_clip(); - if (y) { GC->p.y = y - dy; GC->p.x = x - dx; GC->p.x1 = x + dx; hline_clip(); } + g->p.y = y + dy; g->p.x = x - dx; g->p.x1 = x + dx; hline_clip(g); + if (y) { g->p.y = y - dy; g->p.x = x - dx; g->p.x1 = x + dx; hline_clip(g); } dy--; err -= (2*dy-1)*a2; } } while(dy >= 0); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #endif @@ -944,7 +991,7 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, #include <math.h> #endif - void gdispDrawArc(coord_t x, coord_t y, coord_t radius, coord_t start, coord_t end, color_t color) { + void gdispGDrawArc(GDisplay *g, coord_t x, coord_t y, coord_t radius, coord_t start, coord_t end, color_t color) { coord_t a, b, P, sedge, eedge; uint8_t full, sbit, ebit, tbit; @@ -970,8 +1017,8 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, for(tbit=sbit<<1; tbit < ebit; tbit<<=1) full |= tbit; } - MUTEX_ENTER(); - GC->p.color = color; + MUTEX_ENTER(g); + g->p.color = color; if (full) { // Draw full sectors @@ -979,33 +1026,33 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, a = 1; b = radius; P = 4 - radius; - if (full & 0x60) { GC->p.y = y+b; GC->p.x = x; drawpixel_clip(); } - if (full & 0x06) { GC->p.y = y-b; GC->p.x = x; drawpixel_clip(); } - if (full & 0x81) { GC->p.y = y; GC->p.x = x+b; drawpixel_clip(); } - if (full & 0x18) { GC->p.y = y; GC->p.x = x-b; drawpixel_clip(); } + if (full & 0x60) { g->p.y = y+b; g->p.x = x; drawpixel_clip(g); } + if (full & 0x06) { g->p.y = y-b; g->p.x = x; drawpixel_clip(g); } + if (full & 0x81) { g->p.y = y; g->p.x = x+b; drawpixel_clip(g); } + if (full & 0x18) { g->p.y = y; g->p.x = x-b; drawpixel_clip(g); } do { - if (full & 0x01) { GC->p.x = x+b; GC->p.y = y-a; drawpixel_clip(); } - if (full & 0x02) { GC->p.x = x+a; GC->p.y = y-b; drawpixel_clip(); } - if (full & 0x04) { GC->p.x = x-a; GC->p.y = y-b; drawpixel_clip(); } - if (full & 0x08) { GC->p.x = x-b; GC->p.y = y-a; drawpixel_clip(); } - if (full & 0x10) { GC->p.x = x-b; GC->p.y = y+a; drawpixel_clip(); } - if (full & 0x20) { GC->p.x = x-a; GC->p.y = y+b; drawpixel_clip(); } - if (full & 0x40) { GC->p.x = x+a; GC->p.y = y+b; drawpixel_clip(); } - if (full & 0x80) { GC->p.x = x+b; GC->p.y = y+a; drawpixel_clip(); } + if (full & 0x01) { g->p.x = x+b; g->p.y = y-a; drawpixel_clip(g); } + if (full & 0x02) { g->p.x = x+a; g->p.y = y-b; drawpixel_clip(g); } + if (full & 0x04) { g->p.x = x-a; g->p.y = y-b; drawpixel_clip(g); } + if (full & 0x08) { g->p.x = x-b; g->p.y = y-a; drawpixel_clip(g); } + if (full & 0x10) { g->p.x = x-b; g->p.y = y+a; drawpixel_clip(g); } + if (full & 0x20) { g->p.x = x-a; g->p.y = y+b; drawpixel_clip(g); } + if (full & 0x40) { g->p.x = x+a; g->p.y = y+b; drawpixel_clip(g); } + if (full & 0x80) { g->p.x = x+b; g->p.y = y+a; drawpixel_clip(g); } if (P < 0) P += 3 + 2*a++; else P += 5 + 2*(a++ - b--); } while(a < b); - if (full & 0xC0) { GC->p.x = x+a; GC->p.y = y+b; drawpixel_clip(); } - if (full & 0x0C) { GC->p.x = x-a; GC->p.y = y-b; drawpixel_clip(); } - if (full & 0x03) { GC->p.x = x+a; GC->p.y = y-b; drawpixel_clip(); } - if (full & 0x30) { GC->p.x = x-a; GC->p.y = y+b; drawpixel_clip(); } + if (full & 0xC0) { g->p.x = x+a; g->p.y = y+b; drawpixel_clip(g); } + if (full & 0x0C) { g->p.x = x-a; g->p.y = y-b; drawpixel_clip(g); } + if (full & 0x03) { g->p.x = x+a; g->p.y = y-b; drawpixel_clip(g); } + if (full & 0x30) { g->p.x = x-a; g->p.y = y+b; drawpixel_clip(g); } if (full == 0xFF) { #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif MUTEX_EXIT; @@ -1032,116 +1079,116 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, a = 1; b = radius; P = 4 - radius; - if ((sbit & 0x20) || (ebit & 0x40)) { GC->p.x = x; GC->p.y = y+b; drawpixel_clip(); } - if ((sbit & 0x02) || (ebit & 0x04)) { GC->p.x = x; GC->p.y = y-b; drawpixel_clip(); } - if ((sbit & 0x80) || (ebit & 0x01)) { GC->p.x = x+b; GC->p.y = y; drawpixel_clip(); } - if ((sbit & 0x08) || (ebit & 0x10)) { GC->p.x = x-b; GC->p.y = y; drawpixel_clip(); } + if ((sbit & 0x20) || (ebit & 0x40)) { g->p.x = x; g->p.y = y+b; drawpixel_clip(g); } + if ((sbit & 0x02) || (ebit & 0x04)) { g->p.x = x; g->p.y = y-b; drawpixel_clip(g); } + if ((sbit & 0x80) || (ebit & 0x01)) { g->p.x = x+b; g->p.y = y; drawpixel_clip(g); } + if ((sbit & 0x08) || (ebit & 0x10)) { g->p.x = x-b; g->p.y = y; drawpixel_clip(g); } do { - if (((sbit & 0x01) && a >= sedge) || ((ebit & 0x01) && a <= eedge)) { GC->p.x = x+b; GC->p.y = y-a; drawpixel_clip(); } - if (((sbit & 0x02) && a <= sedge) || ((ebit & 0x02) && a >= eedge)) { GC->p.x = x+a; GC->p.y = y-b; drawpixel_clip(); } - if (((sbit & 0x04) && a >= sedge) || ((ebit & 0x04) && a <= eedge)) { GC->p.x = x-a; GC->p.y = y-b; drawpixel_clip(); } - if (((sbit & 0x08) && a <= sedge) || ((ebit & 0x08) && a >= eedge)) { GC->p.x = x-b; GC->p.y = y-a; drawpixel_clip(); } - if (((sbit & 0x10) && a >= sedge) || ((ebit & 0x10) && a <= eedge)) { GC->p.x = x-b; GC->p.y = y+a; drawpixel_clip(); } - if (((sbit & 0x20) && a <= sedge) || ((ebit & 0x20) && a >= eedge)) { GC->p.x = x-a; GC->p.y = y+b; drawpixel_clip(); } - if (((sbit & 0x40) && a >= sedge) || ((ebit & 0x40) && a <= eedge)) { GC->p.x = x+a; GC->p.y = y+b; drawpixel_clip(); } - if (((sbit & 0x80) && a <= sedge) || ((ebit & 0x80) && a >= eedge)) { GC->p.x = x+b; GC->p.y = y+a; drawpixel_clip(); } + if (((sbit & 0x01) && a >= sedge) || ((ebit & 0x01) && a <= eedge)) { g->p.x = x+b; g->p.y = y-a; drawpixel_clip(g); } + if (((sbit & 0x02) && a <= sedge) || ((ebit & 0x02) && a >= eedge)) { g->p.x = x+a; g->p.y = y-b; drawpixel_clip(g); } + if (((sbit & 0x04) && a >= sedge) || ((ebit & 0x04) && a <= eedge)) { g->p.x = x-a; g->p.y = y-b; drawpixel_clip(g); } + if (((sbit & 0x08) && a <= sedge) || ((ebit & 0x08) && a >= eedge)) { g->p.x = x-b; g->p.y = y-a; drawpixel_clip(g); } + if (((sbit & 0x10) && a >= sedge) || ((ebit & 0x10) && a <= eedge)) { g->p.x = x-b; g->p.y = y+a; drawpixel_clip(g); } + if (((sbit & 0x20) && a <= sedge) || ((ebit & 0x20) && a >= eedge)) { g->p.x = x-a; g->p.y = y+b; drawpixel_clip(g); } + if (((sbit & 0x40) && a >= sedge) || ((ebit & 0x40) && a <= eedge)) { g->p.x = x+a; g->p.y = y+b; drawpixel_clip(g); } + if (((sbit & 0x80) && a <= sedge) || ((ebit & 0x80) && a >= eedge)) { g->p.x = x+b; g->p.y = y+a; drawpixel_clip(g); } if (P < 0) P += 3 + 2*a++; else P += 5 + 2*(a++ - b--); } while(a < b); if (((sbit & 0x40) && a >= sedge) || ((ebit & 0x40) && a <= eedge) || ((sbit & 0x80) && a <= sedge) || ((ebit & 0x80) && a >= eedge)) - { GC->p.x = x+a; GC->p.y = y+b; drawpixel_clip(); } + { g->p.x = x+a; g->p.y = y+b; drawpixel_clip(g); } if (((sbit & 0x04) && a >= sedge) || ((ebit & 0x04) && a <= eedge) || ((sbit & 0x08) && a <= sedge) || ((ebit & 0x08) && a >= eedge)) - { GC->p.x = x-a; GC->p.y = y-b; drawpixel_clip(); } + { g->p.x = x-a; g->p.y = y-b; drawpixel_clip(g); } if (((sbit & 0x01) && a >= sedge) || ((ebit & 0x01) && a <= eedge) || ((sbit & 0x02) && a <= sedge) || ((ebit & 0x02) && a >= eedge)) - { GC->p.x = x+a; GC->p.y = y-b; drawpixel_clip(); } + { g->p.x = x+a; g->p.y = y-b; drawpixel_clip(g); } if (((sbit & 0x10) && a >= sedge) || ((ebit & 0x10) && a <= eedge) || ((sbit & 0x20) && a <= sedge) || ((ebit & 0x20) && a >= eedge)) - { GC->p.x = x-a; GC->p.y = y+b; drawpixel_clip(); } + { g->p.x = x-a; g->p.y = y+b; drawpixel_clip(g); } } else if (end < start) { // Draw start/end sector where it is a non-internal angle // Optimized to prevent double drawing a = 1; b = radius; P = 4 - radius; - if (sbit & 0x60) { GC->p.x = x; GC->p.y = y+b; drawpixel_clip(); } - if (sbit & 0x06) { GC->p.x = x; GC->p.y = y-b; drawpixel_clip(); } - if (sbit & 0x81) { GC->p.x = x+b; GC->p.y = y; drawpixel_clip(); } - if (sbit & 0x18) { GC->p.x = x-b; GC->p.y = y; drawpixel_clip(); } + if (sbit & 0x60) { g->p.x = x; g->p.y = y+b; drawpixel_clip(g); } + if (sbit & 0x06) { g->p.x = x; g->p.y = y-b; drawpixel_clip(g); } + if (sbit & 0x81) { g->p.x = x+b; g->p.y = y; drawpixel_clip(g); } + if (sbit & 0x18) { g->p.x = x-b; g->p.y = y; drawpixel_clip(g); } do { - if ((sbit & 0x01) && (a >= sedge || a <= eedge)) { GC->p.x = x+b; GC->p.y = y-a; drawpixel_clip(); } - if ((sbit & 0x02) && (a <= sedge || a >= eedge)) { GC->p.x = x+a; GC->p.y = y-b; drawpixel_clip(); } - if ((sbit & 0x04) && (a >= sedge || a <= eedge)) { GC->p.x = x-a; GC->p.y = y-b; drawpixel_clip(); } - if ((sbit & 0x08) && (a <= sedge || a >= eedge)) { GC->p.x = x-b; GC->p.y = y-a; drawpixel_clip(); } - if ((sbit & 0x10) && (a >= sedge || a <= eedge)) { GC->p.x = x-b; GC->p.y = y+a; drawpixel_clip(); } - if ((sbit & 0x20) && (a <= sedge || a >= eedge)) { GC->p.x = x-a; GC->p.y = y+b; drawpixel_clip(); } - if ((sbit & 0x40) && (a >= sedge || a <= eedge)) { GC->p.x = x+a; GC->p.y = y+b; drawpixel_clip(); } - if ((sbit & 0x80) && (a <= sedge || a >= eedge)) { GC->p.x = x+b; GC->p.y = y+a; drawpixel_clip(); } + if ((sbit & 0x01) && (a >= sedge || a <= eedge)) { g->p.x = x+b; g->p.y = y-a; drawpixel_clip(g); } + if ((sbit & 0x02) && (a <= sedge || a >= eedge)) { g->p.x = x+a; g->p.y = y-b; drawpixel_clip(g); } + if ((sbit & 0x04) && (a >= sedge || a <= eedge)) { g->p.x = x-a; g->p.y = y-b; drawpixel_clip(g); } + if ((sbit & 0x08) && (a <= sedge || a >= eedge)) { g->p.x = x-b; g->p.y = y-a; drawpixel_clip(g); } + if ((sbit & 0x10) && (a >= sedge || a <= eedge)) { g->p.x = x-b; g->p.y = y+a; drawpixel_clip(g); } + if ((sbit & 0x20) && (a <= sedge || a >= eedge)) { g->p.x = x-a; g->p.y = y+b; drawpixel_clip(g); } + if ((sbit & 0x40) && (a >= sedge || a <= eedge)) { g->p.x = x+a; g->p.y = y+b; drawpixel_clip(g); } + if ((sbit & 0x80) && (a <= sedge || a >= eedge)) { g->p.x = x+b; g->p.y = y+a; drawpixel_clip(g); } if (P < 0) P += 3 + 2*a++; else P += 5 + 2*(a++ - b--); } while(a < b); if (((sbit & 0x04) && (a >= sedge || a <= eedge)) || ((sbit & 0x08) && (a <= sedge || a >= eedge))) - { GC->p.x = x-a; GC->p.y = y-b; drawpixel_clip(); } + { g->p.x = x-a; g->p.y = y-b; drawpixel_clip(g); } if (((sbit & 0x40) && (a >= sedge || a <= eedge)) || ((sbit & 0x80) && (a <= sedge || a >= eedge))) - { GC->p.x = x+a; GC->p.y = y+b; drawpixel_clip(); } + { g->p.x = x+a; g->p.y = y+b; drawpixel_clip(g); } if (((sbit & 0x01) && (a >= sedge || a <= eedge)) || ((sbit & 0x02) && (a <= sedge || a >= eedge))) - { GC->p.x = x+a; GC->p.y = y-b; drawpixel_clip(); } + { g->p.x = x+a; g->p.y = y-b; drawpixel_clip(g); } if (((sbit & 0x10) && (a >= sedge || a <= eedge)) || ((sbit & 0x20) && (a <= sedge || a >= eedge))) - { GC->p.x = x-a; GC->p.y = y+b; drawpixel_clip(); } + { g->p.x = x-a; g->p.y = y+b; drawpixel_clip(g); } } else { // Draw start/end sector where it is a internal angle // Optimized to prevent double drawing a = 1; b = radius; P = 4 - radius; - if (((sbit & 0x20) && !eedge) || ((sbit & 0x40) && !sedge)) { GC->p.x = x; GC->p.y = y+b; drawpixel_clip(); } - if (((sbit & 0x02) && !eedge) || ((sbit & 0x04) && !sedge)) { GC->p.x = x; GC->p.y = y-b; drawpixel_clip(); } - if (((sbit & 0x80) && !eedge) || ((sbit & 0x01) && !sedge)) { GC->p.x = x+b; GC->p.y = y; drawpixel_clip(); } - if (((sbit & 0x08) && !eedge) || ((sbit & 0x10) && !sedge)) { GC->p.x = x-b; GC->p.y = y; drawpixel_clip(); } + if (((sbit & 0x20) && !eedge) || ((sbit & 0x40) && !sedge)) { g->p.x = x; g->p.y = y+b; drawpixel_clip(g); } + if (((sbit & 0x02) && !eedge) || ((sbit & 0x04) && !sedge)) { g->p.x = x; g->p.y = y-b; drawpixel_clip(g); } + if (((sbit & 0x80) && !eedge) || ((sbit & 0x01) && !sedge)) { g->p.x = x+b; g->p.y = y; drawpixel_clip(g); } + if (((sbit & 0x08) && !eedge) || ((sbit & 0x10) && !sedge)) { g->p.x = x-b; g->p.y = y; drawpixel_clip(g); } do { - if (((sbit & 0x01) && a >= sedge && a <= eedge)) { GC->p.x = x+b; GC->p.y = y-a; drawpixel_clip(); } - if (((sbit & 0x02) && a <= sedge && a >= eedge)) { GC->p.x = x+a; GC->p.y = y-b; drawpixel_clip(); } - if (((sbit & 0x04) && a >= sedge && a <= eedge)) { GC->p.x = x-a; GC->p.y = y-b; drawpixel_clip(); } - if (((sbit & 0x08) && a <= sedge && a >= eedge)) { GC->p.x = x-b; GC->p.y = y-a; drawpixel_clip(); } - if (((sbit & 0x10) && a >= sedge && a <= eedge)) { GC->p.x = x-b; GC->p.y = y+a; drawpixel_clip(); } - if (((sbit & 0x20) && a <= sedge && a >= eedge)) { GC->p.x = x-a; GC->p.y = y+b; drawpixel_clip(); } - if (((sbit & 0x40) && a >= sedge && a <= eedge)) { GC->p.x = x+a; GC->p.y = y+b; drawpixel_clip(); } - if (((sbit & 0x80) && a <= sedge && a >= eedge)) { GC->p.x = x+b; GC->p.y = y+a; drawpixel_clip(); } + if (((sbit & 0x01) && a >= sedge && a <= eedge)) { g->p.x = x+b; g->p.y = y-a; drawpixel_clip(g); } + if (((sbit & 0x02) && a <= sedge && a >= eedge)) { g->p.x = x+a; g->p.y = y-b; drawpixel_clip(g); } + if (((sbit & 0x04) && a >= sedge && a <= eedge)) { g->p.x = x-a; g->p.y = y-b; drawpixel_clip(g); } + if (((sbit & 0x08) && a <= sedge && a >= eedge)) { g->p.x = x-b; g->p.y = y-a; drawpixel_clip(g); } + if (((sbit & 0x10) && a >= sedge && a <= eedge)) { g->p.x = x-b; g->p.y = y+a; drawpixel_clip(g); } + if (((sbit & 0x20) && a <= sedge && a >= eedge)) { g->p.x = x-a; g->p.y = y+b; drawpixel_clip(g); } + if (((sbit & 0x40) && a >= sedge && a <= eedge)) { g->p.x = x+a; g->p.y = y+b; drawpixel_clip(g); } + if (((sbit & 0x80) && a <= sedge && a >= eedge)) { g->p.x = x+b; g->p.y = y+a; drawpixel_clip(g); } if (P < 0) P += 3 + 2*a++; else P += 5 + 2*(a++ - b--); } while(a < b); if (((sbit & 0x04) && a >= sedge && a <= eedge) || ((sbit & 0x08) && a <= sedge && a >= eedge)) - { GC->p.x = x-a; GC->p.y = y-b; drawpixel_clip(); } + { g->p.x = x-a; g->p.y = y-b; drawpixel_clip(g); } if (((sbit & 0x40) && a >= sedge && a <= eedge) || ((sbit & 0x80) && a <= sedge && a >= eedge)) - { GC->p.x = x+a; GC->p.y = y+b; drawpixel_clip(); } + { g->p.x = x+a; g->p.y = y+b; drawpixel_clip(g); } if (((sbit & 0x01) && a >= sedge && a <= eedge) || ((sbit & 0x02) && a <= sedge && a >= eedge)) - { GC->p.x = x+a; GC->p.y = y-b; drawpixel_clip(); } + { g->p.x = x+a; g->p.y = y-b; drawpixel_clip(g); } if (((sbit & 0x10) && a >= sedge && a <= eedge) || ((sbit & 0x20) && a <= sedge && a >= eedge)) - { GC->p.x = x-a; GC->p.y = y+b; drawpixel_clip(); } + { g->p.x = x-a; g->p.y = y+b; drawpixel_clip(g); } } #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #endif #if GDISP_NEED_ARC - void gdispFillArc(coord_t x, coord_t y, coord_t radius, coord_t start, coord_t end, color_t color) { + void gdispGFillArc(GDisplay *g, coord_t x, coord_t y, coord_t radius, coord_t start, coord_t end, color_t color) { coord_t a, b, P; coord_t sy, ey; fixed sxa, sxb, sxd, exa, exb, exd; uint8_t qtr; - MUTEX_ENTER(); + MUTEX_ENTER(g); // Do the trig to get the formulas for the start and end lines. sxa = exa = FIXED(x)+FIXED0_5; @@ -1170,7 +1217,7 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, a = 1; b = radius; P = 4 - radius; - GC->p.color = color; + g->p.color = color; sxb += sxa; exb += exa; @@ -1181,50 +1228,50 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, case 0: // S2E2 sy <= ey case 1: // S1E2 sy <= ey if (ey && sy) { - GC->p.x = x; GC->p.x1 = x; // E2S + g->p.x = x; g->p.x1 = x; // E2S sxa -= sxd; exa -= exd; } else if (sy) { - GC->p.x = x-b; GC->p.x1 = x; // C2S + g->p.x = x-b; g->p.x1 = x; // C2S sxa -= sxd; } else if (ey) { - GC->p.x = x; GC->p.x1 = x+b; // E2C + g->p.x = x; g->p.x1 = x+b; // E2C exa -= exd; } else { - GC->p.x = x-b; GC->p.x1 = x+b; // C2C + g->p.x = x-b; g->p.x1 = x+b; // C2C } - GC->p.y = y; - hline_clip(); + g->p.y = y; + hline_clip(g); do { if (-a >= ey) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = NONFIXED(sxa); hline_clip(); // E2S + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = NONFIXED(sxa); hline_clip(g); // E2S sxa -= sxd; exa -= exd; } else if (-a >= sy) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S sxa -= sxd; } else if (qtr & 1) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (P < 0) { P += 3 + 2*a++; } else { if (-b >= ey) { - GC->p.y = y-b; GC->p.x = NONFIXED(exb); GC->p.x1 = NONFIXED(sxb); hline_clip(); // E2S + g->p.y = y-b; g->p.x = NONFIXED(exb); g->p.x1 = NONFIXED(sxb); hline_clip(g); // E2S sxb += sxd; exb += exd; } else if (-b >= sy) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = NONFIXED(sxb); hline_clip(); // C2S + g->p.y = y-b; g->p.x = x-a; g->p.x1 = NONFIXED(sxb); hline_clip(g); // C2S sxb += sxd; } else if (qtr & 1) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } P += 5 + 2*(a++ - b--); } } while(a < b); if (-a >= ey) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = NONFIXED(sxa); hline_clip(); // E2S + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = NONFIXED(sxa); hline_clip(g); // E2S } else if (-a >= sy) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S } else if (qtr & 1) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } break; @@ -1236,92 +1283,92 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, case 19: // S4E2 sy > ey case 22: // S3E1 sy > ey case 23: // S4E1 sy > ey - GC->p.y = y; GC->p.x = x; GC->p.x1 = x+b; hline_clip(); // SE2C + g->p.y = y; g->p.x = x; g->p.x1 = x+b; hline_clip(g); // SE2C sxa += sxd; exa -= exd; do { if (-a >= ey) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C exa -= exd; } else if (!(qtr & 4)) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (a <= sy) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C sxa += sxd; } else if (!(qtr & 1)) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (P < 0) { P += 3 + 2*a++; } else { if (-b >= ey) { - GC->p.y = y-b; GC->p.x = NONFIXED(exb); GC->p.x1 = x+a; hline_clip(); // E2C + g->p.y = y-b; g->p.x = NONFIXED(exb); g->p.x1 = x+a; hline_clip(g); // E2C exb += exd; } else if (!(qtr & 4)) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } if (b <= sy) { - GC->p.y = y+b; GC->p.x = NONFIXED(sxb); GC->p.x1 = x+a; hline_clip(); // S2C + g->p.y = y+b; g->p.x = NONFIXED(sxb); g->p.x1 = x+a; hline_clip(g); // S2C sxb -= sxd; } else if (!(qtr & 1)) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } P += 5 + 2*(a++ - b--); } } while(a < b); if (-a >= ey) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C } else if (!(qtr & 4)) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (a <= sy) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+a; hline_clip(); // S2C + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+a; hline_clip(g); // S2C } else if (!(qtr & 1)) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+a; hline_clip(g); // C2C } break; case 4: // S2E1 sy <= ey case 5: // S1E1 sy <= ey - GC->p.y = y; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C do { if (-a >= ey) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C sxa -= sxd; exa -= exd; } else if (-a >= sy) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S sxa -= sxd; } else if (qtr & 1) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C if (P < 0) { P += 3 + 2*a++; } else { if (-b >= ey) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = NONFIXED(sxb); hline_clip(); // C2S - GC->p.y = y-b; GC->p.x = NONFIXED(exb); GC->p.x1 = x+a; hline_clip(); // E2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = NONFIXED(sxb); hline_clip(g); // C2S + g->p.y = y-b; g->p.x = NONFIXED(exb); g->p.x1 = x+a; hline_clip(g); // E2C sxb += sxd; exb += exd; } else if (-b >= sy) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = NONFIXED(sxb); hline_clip(); // C2S + g->p.y = y-b; g->p.x = x-a; g->p.x1 = NONFIXED(sxb); hline_clip(g); // C2S sxb += sxd; } else if (qtr & 1) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C P += 5 + 2*(a++ - b--); } } while(a < b); if (-a >= ey) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C } else if (-a >= sy) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S } else if (qtr & 1) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C break; case 8: // S2E3 sy <= ey @@ -1332,261 +1379,261 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, case 25: // S1E3 sy > ey case 28: // S2E3 sy > ey case 29: // S1E3 sy > ey - GC->p.y = y; GC->p.x = x-b; GC->p.x1 = x; hline_clip(); // C2SE + g->p.y = y; g->p.x = x-b; g->p.x1 = x; hline_clip(g); // C2SE sxa -= sxd; exa += exd; do { if (-a >= sy) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S sxa -= sxd; } else if (qtr & 1) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (a <= ey) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E exa += exd; } else if (qtr & 4) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (P < 0) { P += 3 + 2*a++; } else { if (-b >= sy) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = NONFIXED(sxb); hline_clip(); // C2S + g->p.y = y-b; g->p.x = x-a; g->p.x1 = NONFIXED(sxb); hline_clip(g); // C2S sxb += sxd; } else if (qtr & 1) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } if (b <= ey) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = NONFIXED(exb); hline_clip(); // C2E + g->p.y = y+b; g->p.x = x-a; g->p.x1 = NONFIXED(exb); hline_clip(g); // C2E exb -= exd; } else if (qtr & 4) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } P += 5 + 2*(a++ - b--); } } while(a < b); if (-a >= sy) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S } else if (qtr & 1) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (a <= ey) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E } else if (qtr & 4) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+a; hline_clip(g); // C2C } break; case 10: // S3E3 sy <= ey case 14: // S3E4 sy <= ey - GC->p.y = y; GC->p.x = x; drawpixel_clip(); // S2E + g->p.y = y; g->p.x = x; drawpixel_clip(g); // S2E sxa += sxd; exa += exd; do { if (a <= sy) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = NONFIXED(exa); hline_clip(); // S2E + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = NONFIXED(exa); hline_clip(g); // S2E sxa += sxd; exa += exd; } else if (a <= ey) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E exa += exd; } else if (qtr & 4) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (P < 0) { P += 3 + 2*a++; } else { if (b <= sy) { - GC->p.y = y+b; GC->p.x = NONFIXED(sxb); GC->p.x1 = NONFIXED(exb); hline_clip(); // S2E + g->p.y = y+b; g->p.x = NONFIXED(sxb); g->p.x1 = NONFIXED(exb); hline_clip(g); // S2E sxb -= sxd; exb -= exd; } else if (b <= ey) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = NONFIXED(exb); hline_clip(); // C2E + g->p.y = y+b; g->p.x = x-a; g->p.x1 = NONFIXED(exb); hline_clip(g); // C2E exb -= exd; } else if (qtr & 4) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } P += 5 + 2*(a++ - b--); } } while(a < b); if (a <= sy) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = NONFIXED(exa); hline_clip(); // S2E + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = NONFIXED(exa); hline_clip(g); // S2E } else if (a <= ey) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E } else if (qtr & 4) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } break; case 11: // S4E3 sy <= ey case 15: // S4E4 sy <= ey - GC->p.y = y; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C do { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C if (a <= sy) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C sxa += sxd; exa += exd; } else if (a <= ey) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E exa += exd; } else if (qtr & 4) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (P < 0) { P += 3 + 2*a++; } else { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C if (b <= sy) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = NONFIXED(exb); hline_clip(); // C2E - GC->p.y = y+b; GC->p.x = NONFIXED(sxb); GC->p.x1 = x+a; hline_clip(); // S2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = NONFIXED(exb); hline_clip(g); // C2E + g->p.y = y+b; g->p.x = NONFIXED(sxb); g->p.x1 = x+a; hline_clip(g); // S2C sxb -= sxd; exb -= exd; } else if (b <= ey) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = NONFIXED(exb); hline_clip(); // C2E + g->p.y = y+b; g->p.x = x-a; g->p.x1 = NONFIXED(exb); hline_clip(g); // C2E exb -= exd; } else if (qtr & 4) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } P += 5 + 2*(a++ - b--); } } while(a < b); - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C if (a <= sy) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C } else if (a <= ey) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E } else if (qtr & 4) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } break; case 16: // S2E2 sy > ey case 20: // S2E1 sy > ey - GC->p.y = y; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C sxa -= sxd; exa -= exd; do { if (-a >= sy) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C sxa -= sxd; exa -= exd; } else if (-a >= ey) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C exa -= exd; } else if (!(qtr & 4)){ - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C if (P < 0) { P += 3 + 2*a++; } else { if (-b >= sy) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = NONFIXED(sxb); hline_clip(); // C2S - GC->p.y = y-b; GC->p.x = NONFIXED(exb); GC->p.x1 = x+a; hline_clip(); // E2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = NONFIXED(sxb); hline_clip(g); // C2S + g->p.y = y-b; g->p.x = NONFIXED(exb); g->p.x1 = x+a; hline_clip(g); // E2C sxb += sxd; exb += exd; } else if (-b >= ey) { - GC->p.y = y-b; GC->p.x = NONFIXED(exb); GC->p.x1 = x+a; hline_clip(); // E2C + g->p.y = y-b; g->p.x = NONFIXED(exb); g->p.x1 = x+a; hline_clip(g); // E2C exb += exd; } else if (!(qtr & 4)){ - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C P += 5 + 2*(a++ - b--); } } while(a < b); if (-a >= sy) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = NONFIXED(sxa); hline_clip(); // C2S - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = NONFIXED(sxa); hline_clip(g); // C2S + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C } else if (-a >= ey) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C } else if (!(qtr & 4)){ - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C break; case 17: // S1E2 sy > ey case 21: // S1E1 sy > ey if (sy) { - GC->p.x = x; GC->p.x1 = x; // E2S + g->p.x = x; g->p.x1 = x; // E2S sxa -= sxd; exa -= exd; } else { - GC->p.x = x; GC->p.x1 = x+b; // E2C + g->p.x = x; g->p.x1 = x+b; // E2C exa -= exd; } - GC->p.y = y; - hline_clip(); + g->p.y = y; + hline_clip(g); do { if (-a >= sy) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = NONFIXED(sxa); hline_clip(); // E2S + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = NONFIXED(sxa); hline_clip(g); // E2S sxa -= sxd; exa -= exd; } else if (-a >= ey) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C exa -= exd; } else if (!(qtr & 4)) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (P < 0) { P += 3 + 2*a++; } else { if (-b >= sy) { - GC->p.y = y-b; GC->p.x = NONFIXED(exb); GC->p.x1 = NONFIXED(sxb); hline_clip(); // E2S + g->p.y = y-b; g->p.x = NONFIXED(exb); g->p.x1 = NONFIXED(sxb); hline_clip(g); // E2S sxb += sxd; exb += exd; } else if (-b >= ey) { - GC->p.y = y-b; GC->p.x = NONFIXED(exb); GC->p.x1 = x+a; hline_clip(); // E2C + g->p.y = y-b; g->p.x = NONFIXED(exb); g->p.x1 = x+a; hline_clip(g); // E2C exb += exd; } else if (!(qtr & 4)) { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } P += 5 + 2*(a++ - b--); } } while(a < b); if (-a >= sy) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = NONFIXED(sxa); hline_clip(); // E2S + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = NONFIXED(sxa); hline_clip(g); // E2S } else if (-a >= ey) { - GC->p.y = y-a; GC->p.x = NONFIXED(exa); GC->p.x1 = x+b; hline_clip(); // E2C + g->p.y = y-a; g->p.x = NONFIXED(exa); g->p.x1 = x+b; hline_clip(g); // E2C } else if (!(qtr & 4)) { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } break; case 26: // S3E3 sy > ey case 27: // S4E3 sy > ey - GC->p.y = y; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C do { - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C if (a <= ey) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C sxa += sxd; exa += exd; } else if (a <= sy) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C sxa += sxd; } else if (!(qtr & 1)) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (P < 0) { P += 3 + 2*a++; } else { - GC->p.y = y-b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y-b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C if (b <= ey) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = NONFIXED(exb); hline_clip(); // C2E - GC->p.y = y+b; GC->p.x = NONFIXED(sxb); GC->p.x1 = x+a; hline_clip(); // S2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = NONFIXED(exb); hline_clip(g); // C2E + g->p.y = y+b; g->p.x = NONFIXED(sxb); g->p.x1 = x+a; hline_clip(g); // S2C sxb -= sxd; exb -= exd; } else if (b <= sy) { - GC->p.y = y+b; GC->p.x = NONFIXED(sxb); GC->p.x1 = x+a; hline_clip(); // S2C + g->p.y = y+b; g->p.x = NONFIXED(sxb); g->p.x1 = x+a; hline_clip(g); // S2C sxb -= sxd; } else if (!(qtr & 1)) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } P += 5 + 2*(a++ - b--); } } while(a < b); - GC->p.y = y-a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y-a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C if (a <= ey) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = NONFIXED(exa); hline_clip(); // C2E - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = NONFIXED(exa); hline_clip(g); // C2E + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C } else if (a <= sy) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C } else if (!(qtr & 4)) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } break; @@ -1594,52 +1641,52 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, case 31: // S4E4 sy > ey do { if (a <= ey) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = NONFIXED(exa); hline_clip(); // S2E + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = NONFIXED(exa); hline_clip(g); // S2E sxa += sxd; exa += exd; } else if (a <= sy) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C sxa += sxd; } else if (!(qtr & 1)) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } if (P < 0) { P += 3 + 2*a++; } else { if (b <= ey) { - GC->p.y = y+b; GC->p.x = NONFIXED(sxb); GC->p.x1 = NONFIXED(exb); hline_clip(); // S2E + g->p.y = y+b; g->p.x = NONFIXED(sxb); g->p.x1 = NONFIXED(exb); hline_clip(g); // S2E sxb -= sxd; exb -= exd; } else if (b <= sy) { - GC->p.y = y+b; GC->p.x = NONFIXED(sxb); GC->p.x1 = x+a; hline_clip(); // S2C + g->p.y = y+b; g->p.x = NONFIXED(sxb); g->p.x1 = x+a; hline_clip(g); // S2C sxb -= sxd; } else if (!(qtr & 1)) { - GC->p.y = y+b; GC->p.x = x-a; GC->p.x1 = x+a; hline_clip(); // C2C + g->p.y = y+b; g->p.x = x-a; g->p.x1 = x+a; hline_clip(g); // C2C } P += 5 + 2*(a++ - b--); } } while(a < b); if (a <= ey) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C } else if (a <= sy) { - GC->p.y = y+a; GC->p.x = NONFIXED(sxa); GC->p.x1 = x+b; hline_clip(); // S2C + g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C } else if (!(qtr & 4)) { - GC->p.y = y+a; GC->p.x = x-b; GC->p.x1 = x+b; hline_clip(); // C2C + g->p.y = y+a; g->p.x = x-b; g->p.x1 = x+b; hline_clip(g); // C2C } break; } #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #endif #if GDISP_NEED_ARC - void gdispDrawRoundedBox(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color) { + void gdispGDrawRoundedBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color) { if (2*radius > cx || 2*radius > cy) { gdispDrawBox(x, y, cx, cy, color); return; @@ -1656,7 +1703,7 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, #endif #if GDISP_NEED_ARC - void gdispFillRoundedBox(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color) { + void gdispGFillRoundedBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color) { coord_t radius2; radius2 = radius*2; @@ -1675,49 +1722,49 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, #endif #if GDISP_NEED_PIXELREAD - color_t gdispGetPixelColor(coord_t x, coord_t y) { + color_t gdispGGetPixelColor(GDisplay *g, coord_t x, coord_t y) { color_t c; /* Always synchronous as it must return a value */ - MUTEX_ENTER(); + MUTEX_ENTER(g); #if GDISP_HARDWARE_PIXELREAD // Best is direct pixel read - GC->p.x = x; - GC->p.y = y; - c = gdisp_lld_get_pixel_color(GC); + g->p.x = x; + g->p.y = y; + c = gdisp_lld_get_pixel_color(g); #elif GDISP_HARDWARE_STREAM_READ // Next best is hardware streaming - GC->p.x = x; - GC->p.y = y; - GC->p.cx = 1; - GC->p.cy = 1; - gdisp_lld_read_start(GC); - c = gdisp_lld_read_color(GC); - gdisp_lld_read_stop(GC); + g->p.x = x; + g->p.y = y; + g->p.cx = 1; + g->p.cy = 1; + gdisp_lld_read_start(g); + c = gdisp_lld_read_color(g); + gdisp_lld_read_stop(g); #else // Worst is "not possible" #error "GDISP: GDISP_NEED_PIXELREAD has been set but there is no hardware support for reading the display" #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); return c; } #endif #if GDISP_NEED_SCROLL - void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + void gdispGVerticalScroll(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { coord_t abslines; #if !GDISP_HARDWARE_SCROLL coord_t fy, dy, ix, fx, i, j; #endif - MUTEX_ENTER(); + MUTEX_ENTER(g); #if NEED_CLIPPING - if (x < GC->clipx0) { cx -= GC->clipx0 - x; x = GC->clipx0; } - if (y < GC->clipy0) { cy -= GC->clipy0 - y; y = GC->clipy0; } - if (!lines || cx <= 0 || cy <= 0 || x >= GC->clipx1 || y >= GC->clipy1) { MUTEX_EXIT(); return; } - if (x+cx > GC->clipx1) cx = GC->clipx1 - x; - if (y+cy > GC->clipy1) cy = GC->clipy1 - y; + if (x < g->clipx0) { cx -= g->clipx0 - x; x = g->clipx0; } + if (y < g->clipy0) { cy -= g->clipy0 - y; y = g->clipy0; } + if (!lines || cx <= 0 || cy <= 0 || x >= g->clipx1 || y >= g->clipy1) { MUTEX_EXIT(g); return; } + if (x+cx > g->clipx1) cx = g->clipx1 - x; + if (y+cy > g->clipy1) cy = g->clipy1 - y; #endif abslines = lines < 0 ? -lines : lines; @@ -1726,13 +1773,13 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, cy = 0; } else { #if GDISP_HARDWARE_SCROLL - GC->p.x = x; - GC->p.y = y; - GC->p.cx = cx; - GC->p.cy = cy; - GC->p.y1 = lines; - GC->p.color = bgcolor; - gdisp_lld_vertical_scroll(GC); + g->p.x = x; + g->p.y = y; + g->p.cx = cx; + g->p.cy = cy; + g->p.y1 = lines; + g->p.color = bgcolor; + gdisp_lld_vertical_scroll(g); cy -= abslines; #elif GDISP_LINEBUF_SIZE == 0 #error "GDISP: GDISP_NEED_SCROLL is set but there is no hardware support and GDISP_LINEBUF_SIZE is zero." @@ -1759,20 +1806,20 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, // Read one line of data from the screen #if GDISP_HARDWARE_STREAM_READ // Best is hardware streaming - GC->p.x = x+ix; - GC->p.y = fy+lines; - GC->p.cx = fx; - GC->p.cy = 1; - gdisp_lld_read_start(GC); + g->p.x = x+ix; + g->p.y = fy+lines; + g->p.cx = fx; + g->p.cy = 1; + gdisp_lld_read_start(g); for(j=0; j < fx; j++) - GC->linebuf[j] = gdisp_lld_read_color(GC); - gdisp_lld_read_stop(GC); + g->linebuf[j] = gdisp_lld_read_color(g); + gdisp_lld_read_stop(g); #elif GDISP_HARDWARE_PIXELREAD // Next best is single pixel reads for(j=0; j < fx; j++) { - GC->p.x = x+ix+j; - GC->p.y = fy+lines; - GC->linebuf[j] = gdisp_lld_get_pixel_color(GC); + g->p.x = x+ix+j; + g->p.y = fy+lines; + g->linebuf[j] = gdisp_lld_get_pixel_color(g); } #else // Worst is "not possible" @@ -1782,36 +1829,36 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, // Write that line to the new location #if GDISP_HARDWARE_BITFILLS // Best is hardware bitfills - GC->p.x = x+ix; - GC->p.y = fy; - GC->p.cx = fx; - GC->p.cy = 1; - GC->p.x1 = 0; - GC->p.y1 = 0; - GC->p.x2 = fx; - GC->p.ptr = (void *)GC->linebuf; - gdisp_lld_blit_area(GC); + g->p.x = x+ix; + g->p.y = fy; + g->p.cx = fx; + g->p.cy = 1; + g->p.x1 = 0; + g->p.y1 = 0; + g->p.x2 = fx; + g->p.ptr = (void *)g->linebuf; + gdisp_lld_blit_area(g); #elif GDISP_HARDWARE_STREAM_WRITE // Next best is hardware streaming - GC->p.x = x+ix; - GC->p.y = fy; - GC->p.cx = fx; - GC->p.cy = 1; - gdisp_lld_write_start(GC); + g->p.x = x+ix; + g->p.y = fy; + g->p.cx = fx; + g->p.cy = 1; + gdisp_lld_write_start(g); #if GDISP_HARDWARE_STREAM_POS - gdisp_lld_write_pos(GC); + gdisp_lld_write_pos(g); #endif for(j = 0; j < fx; j++) { - GC->p.color = GC->linebuf[j]; - gdisp_lld_write_color(GC); + g->p.color = g->linebuf[j]; + gdisp_lld_write_color(g); } - gdisp_lld_write_stop(GC); + gdisp_lld_write_stop(g); #else // Worst is drawing pixels - GC->p.y = fy; - for(GC->p.x = x+ix, j = 0; j < fx; GC->p.x++, j++) { - GC->p.color = GC->linebuf[j]; - gdisp_lld_draw_pixel(GC); + g->p.y = fy; + for(g->p.x = x+ix, j = 0; j < fx; g->p.x++, j++) { + g->p.color = g->linebuf[j]; + gdisp_lld_draw_pixel(g); } #endif } @@ -1820,45 +1867,45 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, } /* fill the remaining gap */ - GC->p.x = x; - GC->p.y = lines > 0 ? (y+cy) : y; - GC->p.cx = cx; - GC->p.cy = abslines; - GC->p.color = bgcolor; - fillarea(); - MUTEX_EXIT(); + g->p.x = x; + g->p.y = lines > 0 ? (y+cy) : y; + g->p.cx = cx; + g->p.cy = abslines; + g->p.color = bgcolor; + fillarea(g); + MUTEX_EXIT(g); } #endif #if GDISP_NEED_CONTROL #if GDISP_HARDWARE_CONTROL - void gdispControl(unsigned what, void *value) { - MUTEX_ENTER(); - GC->p.x = what; - GC->p.ptr = value; - gdisp_lld_control(GC); + void gdispGControl(GDisplay *g, unsigned what, void *value) { + MUTEX_ENTER(g); + g->p.x = what; + g->p.ptr = value; + gdisp_lld_control(g); #if GDISP_NEED_CLIP || GDISP_NEED_VALIDATION if (what == GDISP_CONTROL_ORIENTATION) { #if GDISP_HARDWARE_CLIP // Best is hardware clipping - GC->p.x = 0; - GC->p.y = 0; - GC->p.cx = GC->g.Width; - GC->p.cy = GC->g.Height; - gdisp_lld_set_clip(GC); + g->p.x = 0; + g->p.y = 0; + g->p.cx = g->g.Width; + g->p.cy = g->g.Height; + gdisp_lld_set_clip(g); #else // Worst is software clipping - GC->clipx0 = 0; - GC->clipy0 = 0; - GC->clipx1 = GC->g.Width; - GC->clipy1 = GC->g.Height; + g->clipx0 = 0; + g->clipy0 = 0; + g->clipx1 = g->g.Width; + g->clipy1 = g->g.Height; #endif } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #else - void gdispControl(unsigned what, void *value) { + void gdispGControl(GDisplay *g, unsigned what, void *value) { (void)what; (void)value; /* Ignore everything */ @@ -1868,17 +1915,17 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, #if GDISP_NEED_QUERY #if GDISP_HARDWARE_QUERY - void *gdispQuery(unsigned what) { + void *gdispGQuery(GDisplay *g, unsigned what) { void *res; - MUTEX_ENTER(); - GC->p.x = (coord_t)what; - res = gdisp_lld_query(GC); - MUTEX_EXIT(); + MUTEX_ENTER(g); + g->p.x = (coord_t)what; + res = gdisp_lld_query(g); + MUTEX_EXIT(g); return res; } #else - void *gdispQuery(unsigned what) { + void *gdispGQuery(GDisplay *g, unsigned what) { (void) what; return (void *)-1; } @@ -1889,63 +1936,63 @@ void gdispBlitAreaEx(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, /* High Level Driver Routines. */ /*===========================================================================*/ -void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { +void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { if (cx <= 0 || cy <= 0) return; cx = x+cx-1; cy = y+cy-1; // cx, cy are now the end point. - MUTEX_ENTER(); + MUTEX_ENTER(g); - GC->p.color = color; + g->p.color = color; if (cx - x > 2) { - GC->p.x = x; GC->p.y = y; GC->p.x1 = cx; hline_clip(); + g->p.x = x; g->p.y = y; g->p.x1 = cx; hline_clip(g); if (y != cy) { - GC->p.x = x; GC->p.y = cy; GC->p.x1 = cx; hline_clip(); + g->p.x = x; g->p.y = cy; g->p.x1 = cx; hline_clip(g); if (cy - y > 2) { y++; cy--; - GC->p.x = x; GC->p.y = y; GC->p.y1 = cy; vline_clip(); - GC->p.x = cx; GC->p.y = y; GC->p.y1 = cy; vline_clip(); + g->p.x = x; g->p.y = y; g->p.y1 = cy; vline_clip(g); + g->p.x = cx; g->p.y = y; g->p.y1 = cy; vline_clip(g); } } } else { - GC->p.x = x; GC->p.y = y; GC->p.y1 = cy; vline_clip(); + g->p.x = x; g->p.y = y; g->p.y1 = cy; vline_clip(g); if (x != cx) { - GC->p.x = cx; GC->p.y = y; GC->p.y1 = cy; vline_clip(); + g->p.x = cx; g->p.y = y; g->p.y1 = cy; vline_clip(g); } } #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } #if GDISP_NEED_CONVEX_POLYGON - void gdispDrawPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color) { + void gdispGDrawPoly(GDisplay *g, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color) { const point *epnt, *p; epnt = &pntarray[cnt-1]; - MUTEX_ENTER(); - GC->p.color = color; + MUTEX_ENTER(g); + g->p.color = color; for(p = pntarray; p < epnt; p++) { - GC->p.x=tx+p->x; GC->p.y=ty+p->y; GC->p.x1=tx+p[1].x; GC->p.y1=ty+p[1].y; line_clip(); + g->p.x=tx+p->x; g->p.y=ty+p->y; g->p.x1=tx+p[1].x; g->p.y1=ty+p[1].y; line_clip(g); } - GC->p.x=tx+p->x; GC->p.y=ty+p->y; GC->p.x1=tx+pntarray->x; GC->p.y1=ty+pntarray->y; line_clip(); + g->p.x=tx+p->x; g->p.y=ty+p->y; g->p.x1=tx+pntarray->x; g->p.y1=ty+pntarray->y; line_clip(g); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } - void gdispFillConvexPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color) { + void gdispGFillConvexPoly(GDisplay *g, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color) { const point *lpnt, *rpnt, *epnts; fixed lx, rx, lk, rk; coord_t y, ymax, lxc, rxc; @@ -1975,8 +2022,8 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { lk = (FIXED(lpnt->x) - lx) / (lpnt->y - y); rk = (FIXED(rpnt->x) - rx) / (rpnt->y - y); - MUTEX_ENTER(); - GC->p.color = color; + MUTEX_ENTER(g); + g->p.color = color; while(1) { /* Determine our boundary */ ymax = rpnt->y < lpnt->y ? rpnt->y : lpnt->y; @@ -1991,9 +2038,9 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { * of pixels. */ if (lxc < rxc) { - GC->p.x=tx+lxc; GC->p.y=ty+y; GC->p.x1=tx+rxc-1; hline_clip(); + g->p.x=tx+lxc; g->p.y=ty+y; g->p.x1=tx+rxc-1; hline_clip(g); } else if (lxc > rxc) { - GC->p.x=tx+rxc; GC->p.y=ty+y; GC->p.x1=tx+lxc-1; hline_clip(); + g->p.x=tx+rxc; g->p.y=ty+y; g->p.x1=tx+lxc-1; hline_clip(g); } lx += lk; @@ -2002,12 +2049,12 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { if (!cnt) { #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); return; } cnt--; @@ -2017,12 +2064,12 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { for (lpnt = lpnt <= pntarray ? epnts : lpnt-1; lpnt->y == y; cnt--) { if (!cnt) { #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); return; } lx = FIXED(lpnt->x); @@ -2033,12 +2080,12 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { for (rpnt = rpnt >= epnts ? pntarray : rpnt+1; rpnt->y == y; cnt--) { if (!cnt) { #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); return; } rx = FIXED(rpnt->x); @@ -2055,27 +2102,27 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { #if GDISP_NEED_ANTIALIAS && GDISP_HARDWARE_PIXELREAD static void drawcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) { - #define GD ((GDISPDriver *)state) + #define GD ((GDisplay *)state) if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x < GD->t.clipx0 || x+count > GD->t.clipx1) return; if (alpha == 255) { GD->p.x = x; GD->p.y = y; GD->p.x1 = x+count-1; GD->p.color = GD->t.color; - hline_clip(); + hline_clip(g); } else { for (; count; count--, x++) { GD->p.x = x; GD->p.y = y; GD->p.color = gdispBlendColor(GD->t.color, gdisp_lld_get_pixel_color(GD), alpha); - drawpixel_clip(); + drawpixel_clip(g); } } #undef GD } #else static void drawcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) { - #define GD ((GDISPDriver *)state) + #define GD ((GDisplay *)state) if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x < GD->t.clipx0 || x+count > GD->t.clipx1) return; if (alpha > 0x80) { // A best approximation when using anti-aliased fonts but we can't actually draw them anti-aliased GD->p.x = x; GD->p.y = y; GD->p.x1 = x+count-1; GD->p.color = GD->t.color; - hline_clip(); + hline_clip(g); } #undef GD } @@ -2083,7 +2130,7 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { #if GDISP_NEED_ANTIALIAS static void fillcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) { - #define GD ((GDISPDriver *)state) + #define GD ((GDisplay *)state) if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x < GD->t.clipx0 || x+count > GD->t.clipx1) return; if (alpha == 255) { GD->p.color = GD->t.color; @@ -2091,7 +2138,7 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { GD->p.color = gdispBlendColor(GD->t.color, GD->t.bgcolor, alpha); } GD->p.x = x; GD->p.y = y; GD->p.x1 = x+count-1; - hline_clip(); + hline_clip(g); #undef GD } #else @@ -2100,110 +2147,110 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { /* Callback to render characters. */ static uint8_t drawcharglyph(int16_t x, int16_t y, mf_char ch, void *state) { - return mf_render_character(GC->t.font, x, y, ch, drawcharline, state); + return mf_render_character(g->t.font, x, y, ch, drawcharline, state); } /* Callback to render characters. */ static uint8_t fillcharglyph(int16_t x, int16_t y, mf_char ch, void *state) { - return mf_render_character(GC->t.font, x, y, ch, fillcharline, state); + return mf_render_character(g->t.font, x, y, ch, fillcharline, state); } - void gdispDrawChar(coord_t x, coord_t y, uint16_t c, font_t font, color_t color) { - MUTEX_ENTER(); - GC->t.font = font; - GC->t.clipx0 = x; - GC->t.clipy0 = y; - GC->t.clipx1 = x + mf_character_width(font, c) + font->baseline_x; - GC->t.clipy1 = y + font->height; - GC->t.color = color; - mf_render_character(font, x, y, c, drawcharline, GC); + void gdispGDrawChar(GDisplay *g, coord_t x, coord_t y, uint16_t c, font_t font, color_t color) { + MUTEX_ENTER(g); + g->t.font = font; + g->t.clipx0 = x; + g->t.clipy0 = y; + g->t.clipx1 = x + mf_character_width(font, c) + font->baseline_x; + g->t.clipy1 = y + font->height; + g->t.color = color; + mf_render_character(font, x, y, c, drawcharline, g); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } - void gdispFillChar(coord_t x, coord_t y, uint16_t c, font_t font, color_t color, color_t bgcolor) { - MUTEX_ENTER(); - GC->p.cx = mf_character_width(font, c) + font->baseline_x; - GC->p.cy = font->height; - GC->t.font = font; - GC->t.clipx0 = GC->p.x = x; - GC->t.clipy0 = GC->p.y = y; - GC->t.clipx1 = GC->p.x+GC->p.cx; - GC->t.clipy1 = GC->p.y+GC->p.cy; - GC->t.color = color; - GC->t.bgcolor = GC->p.color = bgcolor; - - TEST_CLIP_AREA(GC->p.x, GC->p.y, GC->p.cx, GC->p.cy) { - fillarea(); - mf_render_character(font, x, y, c, fillcharline, GC); + void gdispGFillChar(GDisplay *g, coord_t x, coord_t y, uint16_t c, font_t font, color_t color, color_t bgcolor) { + MUTEX_ENTER(g); + g->p.cx = mf_character_width(font, c) + font->baseline_x; + g->p.cy = font->height; + g->t.font = font; + g->t.clipx0 = g->p.x = x; + g->t.clipy0 = g->p.y = y; + g->t.clipx1 = g->p.x+g->p.cx; + g->t.clipy1 = g->p.y+g->p.cy; + g->t.color = color; + g->t.bgcolor = g->p.color = bgcolor; + + TEST_CLIP_AREA(g) { + fillarea(g); + mf_render_character(font, x, y, c, fillcharline, g); } #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } - void gdispDrawString(coord_t x, coord_t y, const char *str, font_t font, color_t color) { - MUTEX_ENTER(); - GC->t.font = font; - GC->t.clipx0 = x; - GC->t.clipy0 = y; - GC->t.clipx1 = x + mf_get_string_width(font, str, 0, 0); - GC->t.clipy1 = y + font->height; - GC->t.color = color; + void gdispGDrawString(GDisplay *g, coord_t x, coord_t y, const char *str, font_t font, color_t color) { + MUTEX_ENTER(g); + g->t.font = font; + g->t.clipx0 = x; + g->t.clipy0 = y; + g->t.clipx1 = x + mf_get_string_width(font, str, 0, 0); + g->t.clipy1 = y + font->height; + g->t.color = color; - mf_render_aligned(font, x+font->baseline_x, y, MF_ALIGN_LEFT, str, 0, drawcharglyph, GC); + mf_render_aligned(font, x+font->baseline_x, y, MF_ALIGN_LEFT, str, 0, drawcharglyph, g); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } - void gdispFillString(coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor) { - MUTEX_ENTER(); - GC->p.cx = mf_get_string_width(font, str, 0, 0); - GC->p.cy = font->height; - GC->t.font = font; - GC->t.clipx0 = GC->p.x = x; - GC->t.clipy0 = GC->p.y = y; - GC->t.clipx1 = GC->p.x+GC->p.cx; - GC->t.clipy1 = GC->p.y+GC->p.cy; - GC->t.color = color; - GC->t.bgcolor = GC->p.color = bgcolor; - - TEST_CLIP_AREA(GC->p.x, GC->p.y, GC->p.cx, GC->p.cy) { - fillarea(); - mf_render_aligned(font, x+font->baseline_x, y, MF_ALIGN_LEFT, str, 0, fillcharglyph, GC); + void gdispGFillString(GDisplay *g, coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor) { + MUTEX_ENTER(g); + g->p.cx = mf_get_string_width(font, str, 0, 0); + g->p.cy = font->height; + g->t.font = font; + g->t.clipx0 = g->p.x = x; + g->t.clipy0 = g->p.y = y; + g->t.clipx1 = g->p.x+g->p.cx; + g->t.clipy1 = g->p.y+g->p.cy; + g->t.color = color; + g->t.bgcolor = g->p.color = bgcolor; + + TEST_CLIP_AREA(g) { + fillarea(g); + mf_render_aligned(font, x+font->baseline_x, y, MF_ALIGN_LEFT, str, 0, fillcharglyph, g); } #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } - void gdispDrawStringBox(coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, justify_t justify) { - MUTEX_ENTER(); - GC->t.font = font; - GC->t.clipx0 = x; - GC->t.clipy0 = y; - GC->t.clipx1 = x+cx; - GC->t.clipy1 = y+cy; - GC->t.color = color; + void gdispGDrawStringBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, justify_t justify) { + MUTEX_ENTER(g); + g->t.font = font; + g->t.clipx0 = x; + g->t.clipy0 = y; + g->t.clipx1 = x+cx; + g->t.clipy1 = y+cy; + g->t.color = color; /* Select the anchor position */ switch(justify) { @@ -2219,33 +2266,33 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { } y += (cy+1 - font->height)/2; - mf_render_aligned(font, x, y, justify, str, 0, drawcharglyph, GC); + mf_render_aligned(font, x, y, justify, str, 0, drawcharglyph, g); #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } - void gdispFillStringBox(coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, color_t bgcolor, justify_t justify) { - MUTEX_ENTER(); - GC->p.cx = cx; - GC->p.cy = cy; - GC->t.font = font; - GC->t.clipx0 = GC->p.x = x; - GC->t.clipy0 = GC->p.y = y; - GC->t.clipx1 = x+cx; - GC->t.clipy1 = y+cy; - GC->t.color = color; - GC->t.bgcolor = GC->p.color = bgcolor; + void gdispGFillStringBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, color_t bgcolor, justify_t justify) { + MUTEX_ENTER(g); + g->p.cx = cx; + g->p.cy = cy; + g->t.font = font; + g->t.clipx0 = g->p.x = x; + g->t.clipy0 = g->p.y = y; + g->t.clipx1 = x+cx; + g->t.clipy1 = y+cy; + g->t.color = color; + g->t.bgcolor = g->p.color = bgcolor; - TEST_CLIP_AREA(GC->p.x, GC->p.y, GC->p.cx, GC->p.cy) { + TEST_CLIP_AREA(g) { // background fill - fillarea(); + fillarea(g); /* Select the anchor position */ switch(justify) { @@ -2262,16 +2309,16 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { y += (cy+1 - font->height)/2; /* Render */ - mf_render_aligned(font, x, y, justify, str, 0, fillcharglyph, GC); + mf_render_aligned(font, x, y, justify, str, 0, fillcharglyph, g); } #if GDISP_HARDWARE_STREAM_POS && GDISP_HARDWARE_STREAM_WRITE - if ((GC->flags & GDISP_FLG_SCRSTREAM)) { - gdisp_lld_write_stop(GC); - GC->flags &= ~GDISP_FLG_SCRSTREAM; + if ((g->flags & GDISP_FLG_SCRSTREAM)) { + gdisp_lld_write_stop(g); + g->flags &= ~GDISP_FLG_SCRSTREAM; } #endif - MUTEX_EXIT(); + MUTEX_EXIT(g); } coord_t gdispGetFontMetric(font_t font, fontmetric_t metric) { @@ -71,7 +71,6 @@ void gfxInit(void) { #endif #if GFX_USE_GDISP _gdispInit(); - gdispClear(Black); #endif #if GFX_USE_GWIN _gwinInit(); |