diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2009-11-07 18:38:46 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2009-11-07 18:38:46 +0000 |
commit | 765ff0130ab58c67e82a2ed17c64c577c6434d57 (patch) | |
tree | c825c50286a468ecb421eca0cc571c1a07dfca24 /firmware/drivers/lcd-charcell.c | |
parent | b1783c3c64d530e77ea2301e70a000f2a624bb74 (diff) | |
download | rockbox-765ff0130ab58c67e82a2ed17c64c577c6434d57.tar.gz rockbox-765ff0130ab58c67e82a2ed17c64c577c6434d57.zip |
Add optional viewport clipping, can be enabled with HAVE_VIEWPORT_CLIP. A simulator check is also added to set_viewport that will show an error/note when DEBUGF is enabled.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23551 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-charcell.c')
-rw-r--r-- | firmware/drivers/lcd-charcell.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/firmware/drivers/lcd-charcell.c b/firmware/drivers/lcd-charcell.c index d02c5eeaad..9fabeb4a22 100644 --- a/firmware/drivers/lcd-charcell.c +++ b/firmware/drivers/lcd-charcell.c | |||
@@ -84,6 +84,28 @@ void lcd_set_viewport(struct viewport* vp) | |||
84 | current_vp = &default_vp; | 84 | current_vp = &default_vp; |
85 | else | 85 | else |
86 | current_vp = vp; | 86 | current_vp = vp; |
87 | |||
88 | #if defined(SIMULATOR) | ||
89 | /* Force the viewport to be within bounds. If this happens it should | ||
90 | * be considered an error - the viewport will not draw as it might be | ||
91 | * expected. | ||
92 | */ | ||
93 | if((unsigned) current_vp->x > (unsigned) LCD_WIDTH | ||
94 | || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT | ||
95 | || current_vp->x + current_vp->width > LCD_WIDTH | ||
96 | || current_vp->y + current_vp->height > LCD_HEIGHT) | ||
97 | { | ||
98 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
99 | DEBUGF("ERROR: " | ||
100 | #else | ||
101 | DEBUGF("NOTE: " | ||
102 | #endif | ||
103 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
104 | current_vp->x, current_vp->y, | ||
105 | current_vp->width, current_vp->height); | ||
106 | } | ||
107 | |||
108 | #endif | ||
87 | } | 109 | } |
88 | 110 | ||
89 | void lcd_update_viewport(void) | 111 | void lcd_update_viewport(void) |
@@ -250,6 +272,11 @@ static void lcd_putxchar(int x, int y, int xchar) | |||
250 | x += current_vp->x; | 272 | x += current_vp->x; |
251 | y += current_vp->y; | 273 | y += current_vp->y; |
252 | 274 | ||
275 | #if defined(HAVE_VIEWPORT_CLIP) | ||
276 | if((unsigned)x > (unsigned)LCD_WIDTH || (unsigned)y > (unsigned)LCD_HEIGHT) | ||
277 | return; | ||
278 | #endif | ||
279 | |||
253 | lcd_char = lcd_charbuffer[y][x]; | 280 | lcd_char = lcd_charbuffer[y][x]; |
254 | 281 | ||
255 | if (lcd_char < lcd_pattern_count) /* old char was soft */ | 282 | if (lcd_char < lcd_pattern_count) /* old char was soft */ |