1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Karl Kurbjun 2009-11-07 18:38:46 +00:00
parent b1783c3c64
commit 765ff0130a
8 changed files with 1100 additions and 174 deletions

View file

@ -84,6 +84,28 @@ void lcd_set_viewport(struct viewport* vp)
current_vp = &default_vp;
else
current_vp = vp;
#if defined(SIMULATOR)
/* Force the viewport to be within bounds. If this happens it should
* be considered an error - the viewport will not draw as it might be
* expected.
*/
if((unsigned) current_vp->x > (unsigned) LCD_WIDTH
|| (unsigned) current_vp->y > (unsigned) LCD_HEIGHT
|| current_vp->x + current_vp->width > LCD_WIDTH
|| current_vp->y + current_vp->height > LCD_HEIGHT)
{
#if !defined(HAVE_VIEWPORT_CLIP)
DEBUGF("ERROR: "
#else
DEBUGF("NOTE: "
#endif
"set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
current_vp->x, current_vp->y,
current_vp->width, current_vp->height);
}
#endif
}
void lcd_update_viewport(void)
@ -250,6 +272,11 @@ static void lcd_putxchar(int x, int y, int xchar)
x += current_vp->x;
y += current_vp->y;
#if defined(HAVE_VIEWPORT_CLIP)
if((unsigned)x > (unsigned)LCD_WIDTH || (unsigned)y > (unsigned)LCD_HEIGHT)
return;
#endif
lcd_char = lcd_charbuffer[y][x];
if (lcd_char < lcd_pattern_count) /* old char was soft */