lcd_fillrect(): Unify 16bit implementations (move to 16bit-common.c)

Change-Id: I457ea9fcb67869fdac7f1201a059a362b087e908
This commit is contained in:
Thomas Martitz 2012-03-20 23:04:05 +01:00
parent bae2470758
commit 1f83d2c6d2
3 changed files with 116 additions and 224 deletions

View file

@ -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:
*

View file

@ -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,

View file

@ -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,