diff options
author | inmarket <andrewh@inmarket.com.au> | 2013-11-05 19:34:12 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2013-11-05 19:34:12 +1000 |
commit | a8e860678df38fdb44f94cacae52e8d54f4374ff (patch) | |
tree | aa718324e163f6c4b9b06805674655dce17e2c96 /drivers | |
parent | 250adaf028848c0aa0dfa2029b722274cb7a6d6a (diff) | |
download | uGFX-a8e860678df38fdb44f94cacae52e8d54f4374ff.tar.gz uGFX-a8e860678df38fdb44f94cacae52e8d54f4374ff.tar.bz2 uGFX-a8e860678df38fdb44f94cacae52e8d54f4374ff.zip |
New GDISP now supports multiple controllers with different pixel formats.
You can now have a main color display and a secondary monochrome display.
You can now optionally set GDISP_PIXELFORMAT to any color or grayscale format for your application and the driver will internally convert to the display hardware format.
Diffstat (limited to 'drivers')
19 files changed, 123 insertions, 61 deletions
diff --git a/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c b/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c index 14e7f88a..3ab1de79 100644 --- a/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c +++ b/drivers/gdisp/ED060SC4/gdisp_lld_ED060SC4.c @@ -524,7 +524,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { bitpos = (6 - 2 * (dx % EINK_PPB)); byte = block->data[dy][dx / EINK_PPB]; byte &= ~(PIXELMASK << bitpos); - if (g->p.color != Black) + if (COLOR2NATIVE(g->p.color) != Black) byte |= PIXEL_WHITE << bitpos; else byte |= PIXEL_BLACK << bitpos; diff --git a/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c b/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c index fecf115c..4514b495 100644 --- a/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c +++ b/drivers/gdisp/HX8347D/gdisp_lld_HX8347D.c @@ -167,7 +167,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { busmode16(g); } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_ram16(g, g->p.color); + write_ram16(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { busmode8(g); diff --git a/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c b/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c index a18c2d82..e65e0a77 100644 --- a/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c +++ b/drivers/gdisp/ILI9320/gdisp_lld_ILI9320.c @@ -204,7 +204,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #endif } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_data(g, g->p.color); + write_data(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { release_bus(g); @@ -225,7 +225,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { dummy_read(g); } LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) { - return read_data(g); + uint16_t data; + + data = read_data(g); + return NATIVE2COLOR(data); } LLDSPEC void gdisp_lld_read_stop(GDisplay *g) { setwritemode(g); diff --git a/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c b/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c index 75b4cd13..ffd67cf7 100644 --- a/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c +++ b/drivers/gdisp/ILI9325/gdisp_lld_ILI9325.c @@ -200,7 +200,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { set_viewport(g); } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_data(g, g->p.color); + write_data(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { release_bus(g); @@ -219,7 +219,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { dummy_read(g); } LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) { - return read_data(g); + uint16_t data; + + data = read_data(g); + return NATIVE2COLOR(data); } LLDSPEC void gdisp_lld_read_stop(GDisplay *g) { setwritemode(g); diff --git a/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c b/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c index 33ca68d4..2513c48d 100644 --- a/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c +++ b/drivers/gdisp/ILI9341/gdisp_lld_ILI9341.c @@ -246,7 +246,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_index(g, 0x2C); } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_data16(g, g->p.color); + write_data16(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { release_bus(g); @@ -262,7 +262,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { dummy_read(g); } LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) { - return read_data(g); + uint16_t data; + + data = read_data(g); + return NATIVE2COLOR(data); } LLDSPEC void gdisp_lld_read_stop(GDisplay *g) { setwritemode(g); diff --git a/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c b/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c index 49e28b23..2b2f0917 100644 --- a/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c +++ b/drivers/gdisp/ILI9481/gdisp_lld_ILI9481.c @@ -211,7 +211,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { set_viewport(g); } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_data(g, g->p.color); + write_data(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { release_bus(g); @@ -226,7 +226,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { dummy_read(g); } LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) { - return read_data(g); + uint16_t data; + + data = read_data(g); + return NATIVE2COLOR(data); } LLDSPEC void gdisp_lld_read_stop(GDisplay *g) { setwritemode(g); diff --git a/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c b/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c index d1086c46..28a2fceb 100644 --- a/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c +++ b/drivers/gdisp/Nokia6610GE12/gdisp_lld_Nokia6610GE12.c @@ -70,8 +70,8 @@ /*===========================================================================*/ // Use the priv pointer itself to save our color. This save allocating ram for it -// and works provided sizeof(color_t) <= sizeof(void *) -#define savecolor(g) (*(color_t *)&g->priv) +// and works provided sizeof(uint16_t) <= sizeof(void *) +#define savecolor(g) (*(uint16_t *)&g->priv) #define GDISP_FLG_ODDBYTE (GDISP_FLG_DRIVER<<0) @@ -143,14 +143,17 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { g->flags &= ~GDISP_FLG_ODDBYTE; } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { + uint16_t c; + + c = COLOR2NATIVE(g->p.color); if ((g->flags & GDISP_FLG_ODDBYTE)) { // Write the pair of pixels to the display write_data3(g, ((savecolor(g) >> 4) & 0xFF), - (((savecolor(g) << 4) & 0xF0)|((g->p.color >> 8) & 0x0F)), - (g->p.color & 0xFF)); + (((savecolor(g) << 4) & 0xF0)|((c >> 8) & 0x0F)), + (c & 0xFF)); g->flags &= ~GDISP_FLG_ODDBYTE; } else { - savecolor(g) = g->p.color; + savecolor(g) = c; g->flags |= GDISP_FLG_ODDBYTE; } } diff --git a/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c b/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c index e0cfb997..f6ce4278 100644 --- a/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c +++ b/drivers/gdisp/Nokia6610GE8/gdisp_lld_Nokia6610GE8.c @@ -111,9 +111,9 @@ #if GDISP_HARDWARE_STREAM_WRITE typedef struct dvrPriv { - color_t savecolor; + uint16_t savecolor; #if GDISP_GE8_BROKEN_CONTROLLER - color_t firstcolor; + uint16_t firstcolor; #endif } dvrPriv; #define PRIV ((dvrPriv *)g->priv) @@ -231,20 +231,23 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { g->flags &= ~(GDISP_FLG_ODDBYTE|GDISP_FLG_RUNBYTE); } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { + uint16_t c; + + c = COLOR2NATIVE(g->p.color); #if GDISP_GE8_BROKEN_CONTROLLER if (!(g->flags & GDISP_FLG_RUNBYTE)) { - PRIV->firstcolor = g->p.color; + PRIV->firstcolor = c; g->flags |= GDISP_FLG_RUNBYTE; } #endif if ((g->flags & GDISP_FLG_ODDBYTE)) { // Write the pair of pixels to the display write_data3(g, ((PRIV->savecolor >> 4) & 0xFF), - (((PRIV->savecolor << 4) & 0xF0)|((g->p.color >> 8) & 0x0F)), - (g->p.color & 0xFF)); + (((PRIV->savecolor << 4) & 0xF0)|((c >> 8) & 0x0F)), + (c & 0xFF)); g->flags &= ~GDISP_FLG_ODDBYTE; } else { - PRIV->savecolor = g->p.color; + PRIV->savecolor = c; g->flags |= GDISP_FLG_ODDBYTE; } } @@ -284,9 +287,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_DRAWPIXEL LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { + uint16_t c; + + c = COLOR2NATIVE(g->p.color); acquire_bus(g); set_viewport(g); - write_data3(g, 0, (g->p.color>>8) & 0x0F, g->p.color & 0xFF); + write_data3(g, 0, (c>>8) & 0x0F, c & 0xFF); release_bus(g); } #endif @@ -295,15 +301,17 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_FILLS LLDSPEC void gdisp_lld_fill_area(GDisplay *g) { - unsigned tuples; + unsigned tuples; + uint16_t c; tuples = (g->p.cx*g->p.cy+1)>>1; // With an odd sized area we over-print by one pixel. // This extra pixel overwrites the first pixel (harmless as it is the same colour) + c = COLOR2NATIVE(g->p.color); acquire_bus(g); set_viewport(g); while(tuples--) - write_data3(g, ((g->p.color >> 4) & 0xFF), (((g->p.color << 4) & 0xF0)|((g->p.color >> 8) & 0x0F)), (g->p.color & 0xFF)); + write_data3(g, ((c >> 4) & 0xFF), (((c << 4) & 0xF0)|((c >> 8) & 0x0F)), (c & 0xFF)); release_bus(g); } #endif @@ -311,7 +319,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_BITFILLS LLDSPEC void gdisp_lld_blit_area(GDisplay *g) { coord_t lg, x, y; - color_t c1, c2; + uint16_t c1, c2; unsigned tuples; const pixel_t *buffer; #if GDISP_PACKED_PIXELS @@ -328,7 +336,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { acquire_bus(g); set_viewport(g); - /* to surpress compiler warnings */ + /* to suppress compiler warnings */ x = 0; y = 0; @@ -356,7 +364,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { while(tuples--) { /* Get a pixel */ - c1 = *p++; + c1 = COLOR2NATIVE(*p++); /* Check for line or buffer wrapping */ if (++x >= g->p.cx) { @@ -369,7 +377,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } /* Get the next pixel */ - c2 = *p++; + c2 = COLOR2NATIVE(*p++); /* Check for line or buffer wrapping */ if (++x >= g->p.cx) { @@ -385,7 +393,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { write_data3(g, ((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); } - #else + #elif GDISP_PIXELFORMAT == GDISP_LLD_PIXELFORMAT // Although this controller uses packed pixels, we may have to feed it into // the controller with different packing to the source bitmap @@ -440,6 +448,9 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { /* Write the pair of pixels to the display */ write_data3(g, ((c1 >> 4) & 0xFF), (((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)), (c2 & 0xFF)); } + + #else + #error "Packed pixels is broken if you are not running native pixel format" #endif /* All done */ diff --git a/drivers/gdisp/RA8875/gdisp_lld_RA8875.c b/drivers/gdisp/RA8875/gdisp_lld_RA8875.c index fb81c43a..d28670c6 100644 --- a/drivers/gdisp/RA8875/gdisp_lld_RA8875.c +++ b/drivers/gdisp/RA8875/gdisp_lld_RA8875.c @@ -184,7 +184,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { set_viewport(g); } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_data(g, g->p.color); + write_data(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { release_bus(g); diff --git a/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c b/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c index cbaa7199..cca9d67e 100644 --- a/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c +++ b/drivers/gdisp/S6D1121/gdisp_lld_S6D1121.c @@ -221,7 +221,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { set_viewport(g); } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_data(g, g->p.color); + write_data(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { release_bus(g); @@ -240,7 +240,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { dummy_read(g); } LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) { - return read_data(g); + uint16_t data; + + data = read_data(g); + return NATIVE2COLOR(data); } LLDSPEC void gdisp_lld_read_stop(GDisplay *g) { setwritemode(g); diff --git a/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c b/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c index 6692e7d7..a33b6564 100644 --- a/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c +++ b/drivers/gdisp/SSD1289/gdisp_lld_SSD1289.c @@ -200,7 +200,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #endif } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_data(g, g->p.color); + write_data(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { release_bus(g); @@ -221,7 +221,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { dummy_read(g); } LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) { - return read_data(g); + uint16_t data; + + data = read_data(g); + return NATIVE2COLOR(data); } LLDSPEC void gdisp_lld_read_stop(GDisplay *g) { setwritemode(g); @@ -231,15 +234,22 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #if GDISP_HARDWARE_FILLS && defined(GDISP_USE_DMA) LLDSPEC void gdisp_lld_fill_area(GDisplay *g) { + uint16_t c; + + c = COLOR2NATIVE(g->p.color); acquire_bus(g); set_viewport(g); set_cursor(g); - dma_with_noinc(g, &color, g->p.cx*g->p.cy) + dma_with_noinc(g, &c, g->p.cx*g->p.cy) release_bus(g); } #endif #if GDISP_HARDWARE_BITFILLS && defined(GDISP_USE_DMA) + #if GDISP_PIXELFORMAT != GDISP_LLD_PIXELFORMAT + #error "GDISP: SSD1289: BitBlit is only available in RGB565 pixel format" + #endif + LLDSPEC void gdisp_lld_blit_area(GDisplay *g) { pixel_t *buffer; coord_t ycnt; diff --git a/drivers/gdisp/SSD1289/gdisp_lld_config.h b/drivers/gdisp/SSD1289/gdisp_lld_config.h index 4cf5fa5c..a9166553 100644 --- a/drivers/gdisp/SSD1289/gdisp_lld_config.h +++ b/drivers/gdisp/SSD1289/gdisp_lld_config.h @@ -28,8 +28,11 @@ #define GDISP_HARDWARE_CONTROL TRUE #if defined(GDISP_USE_DMA)
- #define GDISP_HARDWARE_FILLS TRUE
- #define GDISP_HARDWARE_BITFILLS TRUE + #define GDISP_HARDWARE_FILLS TRUE + #if !defined(GDISP_PIXELFORMAT) || GDISP_PIXELFORMAT == 0x2565 + // Hardware BitBlts are only supported in native pixel format on this controller
+ #define GDISP_HARDWARE_BITFILLS TRUE + #endif #endif
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
diff --git a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c index bd3e386d..b72ba781 100644 --- a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c +++ b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c @@ -176,7 +176,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { x = g->p.x; break; } - if (g->p.color != Black) + if (COLOR2NATIVE(g->p.color) != Black) RAM(g)[xyaddr(x, y)] |= xybit(y); else RAM(g)[xyaddr(x, y)] &= ~xybit(y); diff --git a/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c b/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c index b94c1a40..eb1b9b15 100644 --- a/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c +++ b/drivers/gdisp/SSD1963/gdisp_lld_SSD1963.c @@ -188,7 +188,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { set_viewport(g); } LLDSPEC void gdisp_lld_write_color(GDisplay *g) { - write_data(g, g->p.color); + write_data(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay *g) { release_bus(g); diff --git a/drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c b/drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c index df05fc2c..9594ff95 100644 --- a/drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c +++ b/drivers/gdisp/SSD2119/gdisp_lld_SSD2119.c @@ -238,7 +238,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay* g) { set_viewport(g); } LLDSPEC void gdisp_lld_write_color(GDisplay* g) { - write_data(g, g->p.color); + write_data(g, COLOR2NATIVE(g->p.color)); } LLDSPEC void gdisp_lld_write_stop(GDisplay* g) { release_bus(g); @@ -257,7 +257,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay* g) { dummy_read(g); } LLDSPEC color_t gdisp_lld_read_color(GDisplay* g) { - return read_data(g); + uint16_t data; + + data = read_data(g); + return NATIVE2COLOR(data); } LLDSPEC void gdisp_lld_read_stop(GDisplay* g) { setwritemode(g); @@ -267,15 +270,22 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay* g) { #if GDISP_HARDWARE_FILLS && defined(GDISP_USE_DMA) LLDSPEC void gdisp_lld_fill_area(GDisplay* g) { + uint16_t c; + + c = COLOR2NATIVE(g->p.color); acquire_bus(g); set_viewport(g); set_cursor(g); - dma_with_noinc(g, &g->p.color, g->p.cx * g->p.cy); + dma_with_noinc(g, &c, g->p.cx * g->p.cy); release_bus(g); } #endif #if GDISP_HARDWARE_BITFILLS && defined(GDISP_USE_DMA) + #if GDISP_PIXELFORMAT != GDISP_LLD_PIXELFORMAT + #error "GDISP: SSD2119: BitBlit is only available in RGB565 pixel format" + #endif + LLDSPEC void gdisp_lld_blit_area(GDisplay* g) { pixel_t* buffer; coord_t ynct; diff --git a/drivers/gdisp/SSD2119/gdisp_lld_config.h b/drivers/gdisp/SSD2119/gdisp_lld_config.h index a974c623..ec034bef 100644 --- a/drivers/gdisp/SSD2119/gdisp_lld_config.h +++ b/drivers/gdisp/SSD2119/gdisp_lld_config.h @@ -29,7 +29,10 @@ #if defined(GDISP_USE_DMA) #define GDISP_HARDWARE_FILLS TRUE - #define GDISP_HARDWARE_BITFILLS TRUE + #if !defined(GDISP_PIXELFORMAT) || GDISP_PIXELFORMAT == 0x2565 + // Hardware BitBlts are only supported in native pixel format on this controller + #define GDISP_HARDWARE_BITFILLS TRUE + #endif #endif #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 diff --git a/drivers/gdisp/ST7565/gdisp_lld_ST7565.c b/drivers/gdisp/ST7565/gdisp_lld_ST7565.c index bd8c7b74..2bb5406f 100644 --- a/drivers/gdisp/ST7565/gdisp_lld_ST7565.c +++ b/drivers/gdisp/ST7565/gdisp_lld_ST7565.c @@ -167,7 +167,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { y = g->p.x; break; } - if (g->p.color != Black) + if (COLOR2NATIVE(g->p.color) != Black) RAM(g)[xyaddr(x, y)] |= xybit(y); else RAM(g)[xyaddr(x, y)] &= ~xybit(y); diff --git a/drivers/multiple/Win32/gdisp_lld_Win32.c b/drivers/multiple/Win32/gdisp_lld_Win32.c index 6cbf9cd4..9484c823 100644 --- a/drivers/multiple/Win32/gdisp_lld_Win32.c +++ b/drivers/multiple/Win32/gdisp_lld_Win32.c @@ -23,9 +23,7 @@ #ifndef GDISP_SCREEN_HEIGHT #define GDISP_SCREEN_HEIGHT 480 #endif -#if GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB888 - #error "GDISP Win32: This driver currently only supports the RGB888 pixel format." -#endif + // Setting this to TRUE delays updating the screen // to the windows paint routine. Due to the // drawing lock this does not add as much speed @@ -89,9 +87,6 @@ static HANDLE drawMutex; #define APP_NAME "uGFX" -#define COLOR2BGR(c) ((((c) & 0xFF)<<16)|((c) & 0xFF00)|(((c)>>16) & 0xFF)) -#define BGR2COLOR(c) COLOR2BGR(c) - typedef struct winPriv { HWND hwnd; HDC dcBuffer; @@ -291,9 +286,9 @@ static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) // Paint the toggle area #if GINPUT_NEED_TOGGLE if (ps.rcPaint.bottom >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) { - pen = CreatePen(PS_SOLID, 1, COLOR2BGR(Black)); - hbrOn = CreateSolidBrush(COLOR2BGR(Blue)); - hbrOff = CreateSolidBrush(COLOR2BGR(Gray)); + pen = CreatePen(PS_SOLID, 1, COLOR2NATIVE(Black)); + hbrOn = CreateSolidBrush(COLOR2NATIVE(Blue)); + hbrOff = CreateSolidBrush(COLOR2NATIVE(Gray)); old = SelectObject(dc, pen); MoveToEx(dc, 0, GDISP_SCREEN_HEIGHT, &p); LineTo(dc, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); @@ -519,7 +514,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { COLORREF color; priv = g->priv; - color = COLOR2BGR(g->p.color); + color = COLOR2NATIVE(g->p.color); if (!(g->flags & GDISP_FLG_WSTREAM)) BAD_PARAMETER("write_color: not in streaming mode"); @@ -667,7 +662,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } } - return BGR2COLOR(color); + return NATIVE2COLOR(color); } LLDSPEC void gdisp_lld_read_stop(GDisplay *g) { if (!(g->flags & GDISP_FLG_WSTREAM)) @@ -683,7 +678,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { COLORREF color; priv = g->priv; - color = COLOR2BGR(g->p.color); + color = COLOR2NATIVE(g->p.color); #if GDISP_NEED_CONTROL switch(g->g.Orientation) { @@ -742,7 +737,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { COLORREF color; priv = g->priv; - color = COLOR2BGR(g->p.color); + color = COLOR2NATIVE(g->p.color); hbr = CreateSolidBrush(color); #if GDISP_NEED_CONTROL @@ -841,6 +836,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #endif #if GDISP_HARDWARE_BITFILLS + #if COLOR_SYSTEM != GDISP_COLORSYSTEM_TRUECOLOR || COLOR_TYPE_BITS <= 8 + #error "GDISP Win32: This driver's bitblit currently only supports true-color with bit depths > 8 bits." + #endif + LLDSPEC void gdisp_lld_blit_area(GDisplay *g) { winPriv * priv; pixel_t * buffer; @@ -855,7 +854,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { memset(&bmpInfo, 0, sizeof(bmpInfo)); bmpInfo.bV4Size = sizeof(bmpInfo); bmpInfo.bV4Planes = 1; - bmpInfo.bV4BitCount = sizeof(pixel_t)*8; + bmpInfo.bV4BitCount = COLOR_TYPE_BITS; bmpInfo.bV4AlphaMask = 0; bmpInfo.bV4RedMask = RGB2COLOR(255,0,0); bmpInfo.bV4GreenMask = RGB2COLOR(0,255,0); @@ -969,7 +968,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { #endif ReleaseMutex(drawMutex); - return BGR2COLOR(color); + return NATIVE2COLOR(color); } #endif diff --git a/drivers/multiple/Win32/gdisp_lld_config.h b/drivers/multiple/Win32/gdisp_lld_config.h index 4985bc43..1554161b 100644 --- a/drivers/multiple/Win32/gdisp_lld_config.h +++ b/drivers/multiple/Win32/gdisp_lld_config.h @@ -41,11 +41,19 @@ #define GDISP_HARDWARE_DRAWPIXEL TRUE #define GDISP_HARDWARE_FILLS TRUE #define GDISP_HARDWARE_PIXELREAD TRUE - #define GDISP_HARDWARE_BITFILLS TRUE #define GDISP_HARDWARE_SCROLL TRUE + + // Bit-blits on Win32 are currently only supported for True-Color bit-depths greater than 8 bits + // Note: At the time this file is included we have not calculated all our color + // definitions so we need to do this by hand. + #if !defined(GDISP_PIXELFORMAT) + #define GDISP_HARDWARE_BITFILLS TRUE + #elif (GDISP_PIXELFORMAT & 0x2000) && (((GDISP_PIXELFORMAT & 0x0F00)>>8)+((GDISP_PIXELFORMAT & 0x00F0)>>4)+((GDISP_PIXELFORMAT & 0x000F))) > 8 + #define GDISP_HARDWARE_BITFILLS TRUE + #endif #endif -#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 +#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_BGR888 #endif /* GFX_USE_GDISP */
|