summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/lcd-color-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-color-common.c')
-rw-r--r--firmware/drivers/lcd-color-common.c188
1 files changed, 10 insertions, 178 deletions
diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c
index a867583d36..5f83160dab 100644
--- a/firmware/drivers/lcd-color-common.c
+++ b/firmware/drivers/lcd-color-common.c
@@ -76,7 +76,7 @@ static void *lcd_frameaddress_default(int x, int y)
/* the default expects a buffer the same size as the screen */
struct frame_buffer_t *fb = lcd_current_viewport->buffer;
-#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
+#if LCD_STRIDEFORMAT == VERTICAL_STRIDE
size_t element = (x * LCD_NATIVE_STRIDE(fb->stride)) + y;
#else
size_t element = (y * LCD_NATIVE_STRIDE(fb->stride)) + x;
@@ -111,16 +111,6 @@ void lcd_clear_display(void)
/*** parameter handling ***/
-void lcd_set_drawmode(int mode)
-{
- lcd_current_viewport->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
-}
-
-int lcd_get_drawmode(void)
-{
- return lcd_current_viewport->drawmode;
-}
-
void lcd_set_foreground(unsigned color)
{
lcd_current_viewport->fg_pattern = color;
@@ -141,37 +131,6 @@ unsigned lcd_get_background(void)
return lcd_current_viewport->bg_pattern;
}
-void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color)
-{
- lcd_set_drawmode(mode);
- lcd_current_viewport->fg_pattern = fg_color;
- lcd_current_viewport->bg_pattern = bg_color;
-}
-
-int lcd_getwidth(void)
-{
- return lcd_current_viewport->width;
-}
-
-int lcd_getheight(void)
-{
- return lcd_current_viewport->height;
-}
-
-void lcd_setfont(int newfont)
-{
- lcd_current_viewport->font = newfont;
-}
-
-int lcd_getfont(void)
-{
- return lcd_current_viewport->font;
-}
-
-int lcd_getstringsize(const unsigned char *str, int *w, int *h)
-{
- return font_getstringsize(str, w, h, lcd_current_viewport->font);
-}
void lcd_set_backdrop(fb_data* backdrop)
{
@@ -193,132 +152,6 @@ fb_data* lcd_get_backdrop(void)
return lcd_backdrop;
}
-/* Set a single pixel */
-void lcd_drawpixel(int x, int y)
-{
- if ( ((unsigned)x < (unsigned)lcd_current_viewport->width)
- && ((unsigned)y < (unsigned)lcd_current_viewport->height)
-#if defined(HAVE_VIEWPORT_CLIP)
- && ((unsigned)x < (unsigned)LCD_WIDTH)
- && ((unsigned)y < (unsigned)LCD_HEIGHT)
-#endif
- )
- lcd_fastpixelfuncs[lcd_current_viewport->drawmode](FBADDR(lcd_current_viewport->x+x, lcd_current_viewport->y+y));
-}
-
-/* Draw a line */
-void lcd_drawline(int x1, int y1, int x2, int y2)
-{
- int numpixels;
- int i;
- int deltax, deltay;
- int d, dinc1, dinc2;
- int x, xinc1, xinc2;
- int y, yinc1, yinc2;
- int x_vp, y_vp, w_vp, h_vp;
- lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
-
- deltay = abs(y2 - y1);
- if (deltay == 0)
- {
- /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */
- lcd_hline(x1, x2, y1);
- return;
- }
- deltax = abs(x2 - x1);
- if (deltax == 0)
- {
- /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */
- lcd_vline(x1, y1, y2);
- return;
- }
- xinc2 = 1;
- yinc2 = 1;
-
- if (deltax >= deltay)
- {
- numpixels = deltax;
- d = 2 * deltay - deltax;
- dinc1 = deltay * 2;
- dinc2 = (deltay - deltax) * 2;
- xinc1 = 1;
- yinc1 = 0;
- }
- else
- {
- numpixels = deltay;
- d = 2 * deltax - deltay;
- dinc1 = deltax * 2;
- dinc2 = (deltax - deltay) * 2;
- xinc1 = 0;
- yinc1 = 1;
- }
- numpixels++; /* include endpoints */
-
- if (x1 > x2)
- {
- xinc1 = -xinc1;
- xinc2 = -xinc2;
- }
-
- if (y1 > y2)
- {
- yinc1 = -yinc1;
- yinc2 = -yinc2;
- }
-
- x = x1;
- y = y1;
-
- void *(*fbaddr)(int x, int y) = FB_CURRENTVP_BUFFER->get_address_fn;
- x_vp = lcd_current_viewport->x;
- y_vp = lcd_current_viewport->y;
- w_vp = lcd_current_viewport->width;
- h_vp = lcd_current_viewport->height;
-
- for (i = 0; i < numpixels; i++)
- {
- if ((x >= 0 && y >= 0)
- && (x < w_vp)
- && (y < h_vp)
-#if defined(HAVE_VIEWPORT_CLIP)
- && (x < LCD_WIDTH)
- && (y < LCD_HEIGHT)
-#endif
- )
- pfunc(fbaddr( x + x_vp, y + y_vp));
-
- if (d < 0)
- {
- d += dinc1;
- x += xinc1;
- y += yinc1;
- }
- else
- {
- d += dinc2;
- x += xinc2;
- y += yinc2;
- }
- }
-}
-
-/* Draw a rectangular box */
-void lcd_drawrect(int x, int y, int width, int height)
-{
- if ((width <= 0) || (height <= 0))
- return;
-
- int x2 = x + width - 1;
- int y2 = y + height - 1;
-
- lcd_vline(x, y, y2);
- lcd_vline(x2, y, y2);
- lcd_hline(x, x2, y);
- lcd_hline(x, x2, y2);
-}
-
-
/* Draw a full native bitmap */
void lcd_bitmap(const fb_data *src, int x, int y, int width, int height)
{
@@ -406,9 +239,10 @@ __attribute__((weak))
#endif
void lcd_blit_yuv(unsigned char * const src[3],
int src_x, int src_y, int stride,
- int x, int y, int width, int height)
+ int dst_x, int dst_y, int width, int height)
{
const unsigned char *ysrc, *usrc, *vsrc;
+
int linecounter;
fb_data *dst, *row_end;
long z;
@@ -418,10 +252,10 @@ void lcd_blit_yuv(unsigned char * const src[3],
linecounter = height >> 1;
#if LCD_WIDTH >= LCD_HEIGHT
- dst = FBADDR(x, y);
+ dst = FBADDR(dst_x, dst_y);
row_end = dst + width;
#else
- dst = FBADDR(LCD_WIDTH - y - 1, x);
+ dst = FBADDR(LCD_WIDTH - dst_y - 1, dst_x);
row_end = dst + LCD_WIDTH * width;
#endif
@@ -437,10 +271,10 @@ void lcd_blit_yuv(unsigned char * const src[3],
do
{
+ int y, cb, cr, rv, guv, bu, r, g, b;
+
do
{
- int y, cb, cr, rv, guv, bu, r, g, b;
-
y = YFAC*(*ysrc++ - 16);
cb = *usrc++ - 128;
cr = *vsrc++ - 128;
@@ -504,8 +338,6 @@ void lcd_blit_yuv(unsigned char * const src[3],
do
{
- int y, cb, cr, rv, guv, bu, r, g, b;
-
y = YFAC*(*ysrc++ - 16);
cb = *usrc++ - 128;
cr = *vsrc++ - 128;
@@ -570,9 +402,9 @@ void lcd_blit_yuv(unsigned char * const src[3],
while (--linecounter > 0);
#if LCD_WIDTH >= LCD_HEIGHT
- lcd_update_rect(x, y, width, height);
+ lcd_update_rect(dst_x, dst_y, width, height);
#else
- lcd_update_rect(LCD_WIDTH - y - height, x, height, width);
+ lcd_update_rect(LCD_WIDTH - dst_y - height, dst_x, height, width);
#endif
}
@@ -598,7 +430,7 @@ void lcd_gradient_fillrect_part(int x, int y, int width, int height,
x1 = x;
x2 = x + width;
- if (height == 0) return;
+ if (height <= 0) return;
step_mul = (1 << 16) / src_height;
int h_r = RGB_UNPACK_RED(start_rgb);