summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-03-20 22:39:48 +0100
committerThomas Martitz <kugel@rockbox.org>2012-03-20 22:42:31 +0100
commitbae247075868986910dd426909370f2230b9331d (patch)
tree34b5741fcd39638baad8cf9ae26e3457abd10d6d
parent94139ac0bd3e1ca5d384ac8ac5ad2a915d633a82 (diff)
downloadrockbox-bae247075868986910dd426909370f2230b9331d.tar.gz
rockbox-bae247075868986910dd426909370f2230b9331d.tar.bz2
rockbox-bae247075868986910dd426909370f2230b9331d.zip
Refactor lcd_clear_viewport().
* Unify 16bit implementaitons (move to 16bit-common.c). * Add viewport clipping (within #ifdef HAVE_VIEWPORT_CLIP) like other lcd_* functions have. Change-Id: I4e96b2efdb94d2f7bc5bcdb710554117989579ec
-rw-r--r--firmware/drivers/lcd-16bit-common.c84
-rw-r--r--firmware/drivers/lcd-16bit-vert.c50
-rw-r--r--firmware/drivers/lcd-16bit.c50
3 files changed, 84 insertions, 100 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index c9e88b2137..bd6a0da956 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -111,6 +111,90 @@ void lcd_update_viewport_rect(int x, int y, int width, int height)
lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height);
}
+/* Clear the current viewport */
+void lcd_clear_viewport(void)
+{
+ fb_data *dst, *dst_end;
+ int x, y, width, height;
+ int len, step;
+
+ x = current_vp->x;
+ y = current_vp->y;
+ width = current_vp->width;
+ height = current_vp->height;
+
+#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;
+ x = 0;
+ }
+ if (y < 0)
+ {
+ height += y;
+ y = 0;
+ }
+ if (x + width > LCD_WIDTH)
+ width = LCD_WIDTH - x;
+ if (y + height > LCD_HEIGHT)
+ height = LCD_HEIGHT - y;
+#endif
+
+ len = STRIDE_MAIN(width, height);
+ step = STRIDE_MAIN(ROW_INC, COL_INC);
+
+ dst = FBADDR(x, y);
+ dst_end = FBADDR(x + width - 1 , y + height - 1);
+
+ if (current_vp->drawmode & DRMODE_INVERSEVID)
+ {
+ do
+ {
+ memset16(dst, current_vp->fg_pattern, len);
+ dst += step;
+ }
+ while (dst < dst_end);
+ }
+ else
+ {
+ if (!lcd_backdrop)
+ {
+ do
+ {
+ memset16(dst, current_vp->bg_pattern, len);
+ dst += step;
+ }
+ while (dst < dst_end);
+ }
+ else
+ {
+ do
+ {
+ memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
+ len * sizeof(fb_data));
+ dst += step;
+ }
+ while (dst < dst_end);
+ }
+ }
+
+ if (current_vp == &default_vp)
+ {
+ lcd_scroll_info.lines = 0;
+ }
+ else
+ {
+ lcd_scroll_stop(current_vp);
+ }
+}
+
/*** parameter handling ***/
void lcd_set_drawmode(int mode)
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c
index 6f59af9f70..2ebd6a366e 100644
--- a/firmware/drivers/lcd-16bit-vert.c
+++ b/firmware/drivers/lcd-16bit-vert.c
@@ -46,56 +46,6 @@
/*** drawing functions ***/
-/* Clear the current viewport */
-void lcd_clear_viewport(void)
-{
- fb_data *dst, *dst_end;
-
- dst = FBADDR(current_vp->x, current_vp->y);
- dst_end = dst + current_vp->width * LCD_HEIGHT;
-
- if (current_vp->drawmode & DRMODE_INVERSEVID)
- {
- do
- {
- memset16(dst, current_vp->fg_pattern, current_vp->height);
- dst += LCD_HEIGHT;
- }
- while (dst < dst_end);
- }
- else
- {
- if (!lcd_backdrop)
- {
- do
- {
- memset16(dst, current_vp->bg_pattern, current_vp->height);
- dst += LCD_HEIGHT;
- }
- while (dst < dst_end);
- }
- else
- {
- do
- {
- memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
- current_vp->height * sizeof(fb_data));
- dst += LCD_HEIGHT;
- }
- while (dst < dst_end);
- }
- }
-
- if (current_vp == &default_vp)
- {
- lcd_scroll_info.lines = 0;
- }
- else
- {
- lcd_scroll_stop(current_vp);
- }
-}
-
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index 71768b6744..bf850f18d5 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -46,56 +46,6 @@
/*** drawing functions ***/
-/* Clear the current viewport */
-void lcd_clear_viewport(void)
-{
- fb_data *dst, *dst_end;
-
- dst = FBADDR(current_vp->x, current_vp->y);
- dst_end = dst + current_vp->height * LCD_WIDTH;
-
- if (current_vp->drawmode & DRMODE_INVERSEVID)
- {
- do
- {
- memset16(dst, current_vp->fg_pattern, current_vp->width);
- dst += LCD_WIDTH;
- }
- while (dst < dst_end);
- }
- else
- {
- if (!lcd_backdrop)
- {
- do
- {
- memset16(dst, current_vp->bg_pattern, current_vp->width);
- dst += LCD_WIDTH;
- }
- while (dst < dst_end);
- }
- else
- {
- do
- {
- memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
- current_vp->width * sizeof(fb_data));
- dst += LCD_WIDTH;
- }
- while (dst < dst_end);
- }
- }
-
- if (current_vp == &default_vp)
- {
- lcd_scroll_info.lines = 0;
- }
- else
- {
- lcd_scroll_stop(current_vp);
- }
-}
-
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{