summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-03-20 23:04:05 +0100
committerThomas Martitz <kugel@rockbox.org>2012-03-20 23:04:43 +0100
commit1f83d2c6d2256e78a2940e52125ae44c57691904 (patch)
treeb9f5c15711b287e15bf1c37d0ac5b1748b755689
parentbae247075868986910dd426909370f2230b9331d (diff)
downloadrockbox-1f83d2c6d2256e78a2940e52125ae44c57691904.tar.gz
rockbox-1f83d2c6d2256e78a2940e52125ae44c57691904.zip
lcd_fillrect(): Unify 16bit implementations (move to 16bit-common.c)
Change-Id: I457ea9fcb67869fdac7f1201a059a362b087e908
-rw-r--r--firmware/drivers/lcd-16bit-common.c116
-rw-r--r--firmware/drivers/lcd-16bit-vert.c112
-rw-r--r--firmware/drivers/lcd-16bit.c112
3 files changed, 116 insertions, 224 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index bd6a0da956..7ce4202a1b 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -462,6 +462,122 @@ void lcd_drawrect(int x, int y, int width, int height)
lcd_hline(x, x2, y2);
}
+/* Fill a rectangular area */
+void lcd_fillrect(int x, int y, int width, int height)
+{
+ unsigned bits = 0;
+ enum fill_opt fillopt = OPT_NONE;
+ fb_data *dst, *dst_end;
+ int len, step;
+ debugf("%s()\n", __func__);
+
+ /******************** In viewport clipping **********************/
+ /* nothing to draw? */
+ if ((width <= 0) || (height <= 0) || (x >= current_vp->width) ||
+ (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0))
+ return;
+
+ if (x < 0)
+ {
+ width += x;
+ x = 0;
+ }
+ if (y < 0)
+ {
+ height += y;
+ y = 0;
+ }
+ if (x + width > current_vp->width)
+ width = current_vp->width - 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;
+ 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
+
+ /* drawmode and optimisation */
+ if (current_vp->drawmode & DRMODE_INVERSEVID)
+ {
+ if (current_vp->drawmode & DRMODE_BG)
+ {
+ if (!lcd_backdrop)
+ {
+ fillopt = OPT_SET;
+ bits = current_vp->bg_pattern;
+ }
+ else
+ fillopt = OPT_COPY;
+ }
+ }
+ else
+ {
+ if (current_vp->drawmode & DRMODE_FG)
+ {
+ fillopt = OPT_SET;
+ bits = current_vp->fg_pattern;
+ }
+ }
+ if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT)
+ return;
+
+ dst = FBADDR(x, y);
+ dst_end = FBADDR(x + width - 1, y + height - 1);
+
+ len = STRIDE_MAIN(width, height);
+ step = STRIDE_MAIN(ROW_INC, COL_INC);
+
+ do
+ {
+ switch (fillopt)
+ {
+ case OPT_SET:
+ memset16(dst, bits, len);
+ break;
+
+ case OPT_COPY:
+ memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
+ len * sizeof(fb_data));
+ break;
+
+ case OPT_NONE: /* DRMODE_COMPLEMENT */
+ {
+ fb_data *start = dst;
+ fb_data *end = start + len;
+ do
+ *start = ~(*start);
+ while (++start < end);
+ break;
+ }
+ }
+ dst += step;
+ }
+ while (dst < dst_end);
+}
/* About Rockbox' internal monochrome bitmap format:
*
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c
index 2ebd6a366e..1222c12455 100644
--- a/firmware/drivers/lcd-16bit-vert.c
+++ b/firmware/drivers/lcd-16bit-vert.c
@@ -199,118 +199,6 @@ void lcd_vline(int x, int y1, int y2)
}
}
-/* Fill a rectangular area */
-void lcd_fillrect(int x, int y, int width, int height)
-{
- unsigned bits = 0;
- enum fill_opt fillopt = OPT_NONE;
- fb_data *dst, *dst_end;
-
- /******************** In viewport clipping **********************/
- /* nothing to draw? */
- if ((width <= 0) || (height <= 0) || (x >= current_vp->width) ||
- (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0))
- return;
-
- if (x < 0)
- {
- width += x;
- x = 0;
- }
- if (y < 0)
- {
- height += y;
- y = 0;
- }
- if (x + width > current_vp->width)
- width = current_vp->width - 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;
- 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
-
- /* drawmode and optimisation */
- if (current_vp->drawmode & DRMODE_INVERSEVID)
- {
- if (current_vp->drawmode & DRMODE_BG)
- {
- if (!lcd_backdrop)
- {
- fillopt = OPT_SET;
- bits = current_vp->bg_pattern;
- }
- else
- fillopt = OPT_COPY;
- }
- }
- else
- {
- if (current_vp->drawmode & DRMODE_FG)
- {
- fillopt = OPT_SET;
- bits = current_vp->fg_pattern;
- }
- }
- if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT)
- return;
-
- dst = FBADDR(x, y);
- dst_end = dst + width * LCD_HEIGHT;
-
- do
- {
- fb_data *dst_col, *col_end;
-
- switch (fillopt)
- {
- case OPT_SET:
- memset16(dst, bits, height);
- break;
-
- case OPT_COPY:
- memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
- height * sizeof(fb_data));
- break;
-
- case OPT_NONE: /* DRMODE_COMPLEMENT */
- dst_col = dst;
- col_end = dst_col + height;
- do
- *dst_col = ~(*dst_col);
- while (++dst_col < col_end);
- break;
- }
- dst+=LCD_HEIGHT;
- }
- while (dst < dst_end);
-}
-
/* Draw a partial native bitmap */
void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
int stride, int x, int y, int width,
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index bf850f18d5..4d4166a384 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -199,118 +199,6 @@ void lcd_vline(int x, int y1, int y2)
while (dst <= dst_end);
}
-/* Fill a rectangular area */
-void lcd_fillrect(int x, int y, int width, int height)
-{
- unsigned bits = 0;
- enum fill_opt fillopt = OPT_NONE;
- fb_data *dst, *dst_end;
-
- /******************** In viewport clipping **********************/
- /* nothing to draw? */
- if ((width <= 0) || (height <= 0) || (x >= current_vp->width) ||
- (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0))
- return;
-
- if (x < 0)
- {
- width += x;
- x = 0;
- }
- if (y < 0)
- {
- height += y;
- y = 0;
- }
- if (x + width > current_vp->width)
- width = current_vp->width - 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;
- 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
-
- /* drawmode and optimisation */
- if (current_vp->drawmode & DRMODE_INVERSEVID)
- {
- if (current_vp->drawmode & DRMODE_BG)
- {
- if (!lcd_backdrop)
- {
- fillopt = OPT_SET;
- bits = current_vp->bg_pattern;
- }
- else
- fillopt = OPT_COPY;
- }
- }
- else
- {
- if (current_vp->drawmode & DRMODE_FG)
- {
- fillopt = OPT_SET;
- bits = current_vp->fg_pattern;
- }
- }
- if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT)
- return;
-
- dst = FBADDR(x, y);
- dst_end = dst + height * LCD_WIDTH;
-
- do
- {
- fb_data *dst_row, *row_end;
-
- switch (fillopt)
- {
- case OPT_SET:
- memset16(dst, bits, width);
- break;
-
- case OPT_COPY:
- memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
- width * sizeof(fb_data));
- break;
-
- case OPT_NONE: /* DRMODE_COMPLEMENT */
- dst_row = dst;
- row_end = dst_row + width;
- do
- *dst_row = ~(*dst_row);
- while (++dst_row < row_end);
- break;
- }
- dst += LCD_WIDTH;
- }
- while (dst < dst_end);
-}
-
/* Draw a partial native bitmap */
void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
int stride, int x, int y, int width,