summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/lcd-16bit.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-03-05 20:09:41 +0000
committerThomas Martitz <kugel@rockbox.org>2011-03-05 20:09:41 +0000
commitedea12b21e986a2439bcb8fe786e6ff992a22ca7 (patch)
treee3252cedf2e98077407d5f0774a01d233a1d5f9e /firmware/drivers/lcd-16bit.c
parent222e1ad84591f3aac29dac297924b16eb390f3e7 (diff)
downloadrockbox-edea12b21e986a2439bcb8fe786e6ff992a22ca7.tar.gz
rockbox-edea12b21e986a2439bcb8fe786e6ff992a22ca7.zip
Add viewport clipping to lcd_alpha_bitmap_part as lcd_mono_bitmap_part also has.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29526 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-16bit.c')
-rw-r--r--firmware/drivers/lcd-16bit.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index a2eb3e630c..2017a7e5ab 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -989,6 +989,36 @@ void ICODE_ATTR lcd_alpha_bitmap_part(const unsigned char *src, int src_x,
if (y + height > current_vp->height)
height = current_vp->height - y;
+ /* adjust for viewport */
+ x += current_vp->x;
+ y += current_vp->y;
+
+#if defined(HAVE_VIEWPORT_CLIP)
+ /********************* Viewport on screen clipping ********************/
+ /* nothing to draw? */
+ if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
+ || (x + width <= 0) || (y + height <= 0))
+ return;
+
+ /* clip image in viewport in screen */
+ if (x < 0)
+ {
+ width += x;
+ src_x -= x;
+ x = 0;
+ }
+ if (y < 0)
+ {
+ height += y;
+ src_y -= y;
+ y = 0;
+ }
+ if (x + width > LCD_WIDTH)
+ width = LCD_WIDTH - x;
+ if (y + height > LCD_HEIGHT)
+ height = LCD_HEIGHT - y;
+#endif
+
if (drmode & DRMODE_INVERSEVID)
{
dmask = 0xffffffff;
@@ -999,7 +1029,7 @@ void ICODE_ATTR lcd_alpha_bitmap_part(const unsigned char *src, int src_x,
dmask = ~dmask;
}
- dst = LCDADDR(current_vp->x + x, current_vp->y + y);
+ dst = LCDADDR(x, y);
int col, row = height;
unsigned data, pixels;