aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-02-03 17:58:43 +1000
committerinmarket <andrewh@inmarket.com.au>2014-02-03 17:58:43 +1000
commitde7aafe785e5641115aa4b3f5a900515d8d36a28 (patch)
tree48dcc8a4a7344621ff01740803dd0ea2eb588863 /src
parent71818b29429b6de41d8e24955ec6e22026fc0ad7 (diff)
downloaduGFX-de7aafe785e5641115aa4b3f5a900515d8d36a28.tar.gz
uGFX-de7aafe785e5641115aa4b3f5a900515d8d36a28.tar.bz2
uGFX-de7aafe785e5641115aa4b3f5a900515d8d36a28.zip
Fix font clipping properly. Previous fix did not bound the font display in the x direction.
Diffstat (limited to 'src')
-rw-r--r--src/gdisp/gdisp.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c
index 3031c455..949bedaf 100644
--- a/src/gdisp/gdisp.c
+++ b/src/gdisp/gdisp.c
@@ -2769,8 +2769,14 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
#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 ((GDisplay *)state)
- if (y < GD->t.clipy0 || y >= GD->t.clipy1)
+ if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x+count <= GD->t.clipx0 || x >= GD->t.clipx1)
return;
+ if (x < GD->t.clipx0) {
+ count -= GD->t.clipx0 - x;
+ x = GD->t.clipx0;
+ }
+ if (x+count > GD->t.clipx1)
+ count = GD->t.clipx1 - x;
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(GD);
@@ -2786,8 +2792,14 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
#else
static void drawcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) {
#define GD ((GDisplay *)state)
- if (y < GD->t.clipy0 || y >= GD->t.clipy1)
+ if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x+count <= GD->t.clipx0 || x >= GD->t.clipx1)
return;
+ if (x < GD->t.clipx0) {
+ count -= GD->t.clipx0 - x;
+ x = GD->t.clipx0;
+ }
+ if (x+count > GD->t.clipx1)
+ count = GD->t.clipx1 - x;
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(GD);
@@ -2799,8 +2811,14 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
#if GDISP_NEED_ANTIALIAS
static void fillcharline(int16_t x, int16_t y, uint8_t count, uint8_t alpha, void *state) {
#define GD ((GDisplay *)state)
- if (y < GD->t.clipy0 || y >= GD->t.clipy1)
+ if (y < GD->t.clipy0 || y >= GD->t.clipy1 || x+count <= GD->t.clipx0 || x >= GD->t.clipx1)
return;
+ if (x < GD->t.clipx0) {
+ count -= GD->t.clipx0 - x;
+ x = GD->t.clipx0;
+ }
+ if (x+count > GD->t.clipx1)
+ count = GD->t.clipx1 - x;
if (alpha == 255) {
GD->p.color = GD->t.color;
} else {