diff options
author | ergosys <ergosys@gmail.com> | 2014-12-13 14:44:53 -0800 |
---|---|---|
committer | ergosys <ergosys@gmail.com> | 2014-12-13 15:09:37 -0800 |
commit | 555fda21708519de00dd10a213e346d084c50023 (patch) | |
tree | bfda2007e4fccda9bf6a805986701dccd45d6139 /drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c | |
parent | d3b3020a078fff9607fd169c32210888ee6b0c5c (diff) | |
download | uGFX-555fda21708519de00dd10a213e346d084c50023.tar.gz uGFX-555fda21708519de00dd10a213e346d084c50023.tar.bz2 uGFX-555fda21708519de00dd10a213e346d084c50023.zip |
Implement "hardware" fills
Implement hardware fills by drawing on the framebuffer. This provides a
significant performance boost for filled geometric primitives and a
small one for font drawing. Tested at all orientations.
Diffstat (limited to 'drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c')
-rw-r--r-- | drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c index 1885ffac..a13b82a8 100644 --- a/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c +++ b/drivers/gdisp/SSD1306/gdisp_lld_SSD1306.c @@ -166,6 +166,46 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { } #endif +#if GDISP_HARDWARE_FILLS + LLDSPEC void gdisp_lld_fill_area(GDisplay *g) { + coord_t sy = g->p.y; + coord_t ey = sy + g->p.cy - 1; + coord_t sx = g->p.x; + coord_t ex = g->p.x + g->p.cx - 1; + if (g->g.Orientation == GDISP_ROTATE_90 || g->g.Orientation == GDISP_ROTATE_270) { + coord_t tmp; + tmp = sx; sx = sy; sy = tmp; + tmp = ex; ex = ey; ey = tmp; + } + unsigned spage = sy / 8; + uint8_t * base = RAM(g) + GDISP_SCREEN_WIDTH * spage; + uint8_t mask = 0xff << (sy&7); + unsigned zpages = (ey / 8) - spage; + coord_t col; + if (gdispColor2Native(g->p.color)==Black) { + while (zpages--) { + for (col = sx; col <= ex; col++) + base[col] &= ~mask; + mask = 0xff; + base += GDISP_SCREEN_WIDTH; + } + mask &= (0xff >> (7 - (ey&7))); + for (col = sx; col <= ex; col++) + base[col] &= ~mask; + } else { + while (zpages--) { + for (col = sx; col <= ex; col++) + base[col] |= mask; + mask = 0xff; + base += GDISP_SCREEN_WIDTH; + } + mask &= (0xff >> (7 - (ey&7))); + for (col = sx; col <= ex; col++) + base[col] |= mask; + } + } +#endif + #if GDISP_HARDWARE_DRAWPIXEL LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { coord_t x = g->p.x; |