From 77649a7a2cc84911d7945a32092b1ec1964c6e3d Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Mon, 12 Jan 2009 02:15:04 +0000 Subject: [PATCH] Fix FS#9782 - lcd_bitmap_transparent_part clipping but keep smaller clipping code. The bitmap coordinates were not being adjusted when clipping left and top. Also fix for Gigabeat S. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19752 a1c6a512-1295-4272-9138-f99709370657 --- .../target/arm/imx31/gigabeat-s/lcd-imx31.c | 20 +++++++++++++++---- .../arm/s3c2440/gigabeat-fx/lcd-meg-fx.c | 20 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c b/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c index 5ebc3bd573..eb14152775 100644 --- a/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c @@ -127,15 +127,27 @@ void lcd_bitmap_transparent_part(const fb_data *src, int src_x, int src_y, if (x + width > current_vp->width) width = current_vp->width - x; /* Clip right */ - if (x < 0) - width += x, x = 0; /* Clip left */ + + if (x < 0) /* Clip left */ + { + width += x; + src_x -= x; + x = 0; + } + if (width <= 0) return; /* nothing left to do */ if (y + height > current_vp->height) height = current_vp->height - y; /* Clip bottom */ - if (y < 0) - height += y, y = 0; /* Clip top */ + + if (y < 0) /* Clip top */ + { + height += y; + src_y -= y; + y = 0; + } + if (height <= 0) return; /* nothing left to do */ diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c index f3461cfe91..62880790d1 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c @@ -421,15 +421,27 @@ void lcd_bitmap_transparent_part(const fb_data *src, int src_x, int src_y, if (x + width > current_vp->width) width = current_vp->width - x; /* Clip right */ - if (x < 0) - width += x, x = 0; /* Clip left */ + + if (x < 0) /* Clip left */ + { + width += x; + src_x -= x; + x = 0; + } + if (width <= 0) return; /* nothing left to do */ if (y + height > current_vp->height) height = current_vp->height - y; /* Clip bottom */ - if (y < 0) - height += y, y = 0; /* Clip top */ + + if (y < 0) /* Clip top */ + { + height += y; + src_y -= y; + y = 0; + } + if (height <= 0) return; /* nothing left to do */