From 00ac809cc71e3747c81bf01be95d5cf21d93d9a0 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sat, 12 Apr 2008 07:53:33 +0000 Subject: LCD drivers: * Automatically optimise horizontal and vertical lines drawn via _drawline(), with debug message to show possible optimisations in the caller. * Get rid of the extra ICODE function declarations by putting the attribute into the definition. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17081 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-2bit-horz.c | 90 +++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 47 deletions(-) (limited to 'firmware/drivers/lcd-2bit-horz.c') diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index 195885c072..30901efb98 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c @@ -239,43 +239,38 @@ lcd_pixelfunc_type* const * lcd_pixelfuncs = lcd_pixelfuncs_bgcolor; /* 'mask' and 'bits' contain 2 bits per pixel */ -static void flipblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void flipblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR flipblock(fb_data *address, unsigned mask, + unsigned bits) { *address ^= bits & mask; } -static void bgblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void bgblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR bgblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; *address = data ^ ((data ^ bg_pattern) & mask & ~bits); } -static void bgimgblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void bgimgblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR bgimgblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; *address = data ^ ((data ^ *(address + lcd_backdrop_offset)) & mask & ~bits); } -static void fgblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void fgblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR fgblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; *address = data ^ ((data ^ fg_pattern) & mask & bits); } -static void solidblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void solidblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR solidblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; unsigned bgp = bg_pattern; @@ -284,9 +279,8 @@ static void solidblock(fb_data *address, unsigned mask, unsigned bits) *address = data ^ ((data ^ bits) & mask); } -static void solidimgblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void solidimgblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR solidimgblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; unsigned bgp = *(address + lcd_backdrop_offset); @@ -295,43 +289,38 @@ static void solidimgblock(fb_data *address, unsigned mask, unsigned bits) *address = data ^ ((data ^ bits) & mask); } -static void flipinvblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void flipinvblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR flipinvblock(fb_data *address, unsigned mask, + unsigned bits) { *address ^= ~bits & mask; } -static void bginvblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void bginvblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR bginvblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; *address = data ^ ((data ^ bg_pattern) & mask & bits); } -static void bgimginvblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void bgimginvblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR bgimginvblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; *address = data ^ ((data ^ *(address + lcd_backdrop_offset)) & mask & bits); } -static void fginvblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void fginvblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR fginvblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; *address = data ^ ((data ^ fg_pattern) & mask & ~bits); } -static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR solidinvblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; unsigned fgp = fg_pattern; @@ -340,9 +329,8 @@ static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) *address = data ^ ((data ^ bits) & mask); } -static void solidimginvblock(fb_data *address, unsigned mask, unsigned bits) - ICODE_ATTR; -static void solidimginvblock(fb_data *address, unsigned mask, unsigned bits) +static void ICODE_ATTR solidimginvblock(fb_data *address, unsigned mask, + unsigned bits) { unsigned data = *address; unsigned fgp = fg_pattern; @@ -459,8 +447,20 @@ void lcd_drawline(int x1, int y1, int x2, int y2) int y, yinc1, yinc2; lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[current_vp->drawmode]; - deltax = abs(x2 - x1); 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; @@ -702,11 +702,9 @@ void lcd_fillrect(int x, int y, int width, int height) * 0..7, the second row defines pixel row 8..15 etc. */ /* Draw a partial monochrome bitmap */ -void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) - ICODE_ATTR; -void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) +void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, + int src_y, int stride, int x, int y, + int width, int height) { int ny, nx, ymax; const unsigned char * src_end; @@ -795,11 +793,9 @@ void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int heig * This is the same as the internal lcd hw format. */ /* Draw a partial native bitmap */ -void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) - ICODE_ATTR; -void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) +void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, + int src_y, int stride, int x, int y, + int width, int height) { int shift, nx; unsigned char *dst, *dst_end; -- cgit v1.2.3