1
0
Fork 0
forked from len0rd/rockbox

A couple of optimisations.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6981 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2005-07-02 07:21:21 +00:00
parent 876a044ae0
commit 3291ae6bfa
4 changed files with 87 additions and 44 deletions

View file

@ -317,7 +317,7 @@ void pgfx_hline(int x1, int x2, int y)
void pgfx_vline(int x, int y1, int y2) void pgfx_vline(int x, int y1, int y2)
{ {
int y; int y;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask; unsigned mask;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -344,8 +344,10 @@ void pgfx_vline(int x, int y1, int y2)
dst = &gfx_buffer[pixel_height * (x/5) + y1]; dst = &gfx_buffer[pixel_height * (x/5) + y1];
mask = 0x10 >> (x % 5); mask = 0x10 >> (x % 5);
for (y = y1; y <= y2; y++) dst_end = dst + y2 - y1;
do
bfunc(dst++, mask, 0x1F); bfunc(dst++, mask, 0x1F);
while (dst <= dst_end);
} }
/* Draw a rectangular box */ /* Draw a rectangular box */
@ -366,8 +368,8 @@ void pgfx_drawrect(int x, int y, int width, int height)
/* Fill a rectangular area */ /* Fill a rectangular area */
void pgfx_fillrect(int x, int y, int width, int height) void pgfx_fillrect(int x, int y, int width, int height)
{ {
int nx, i; int nx;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask, mask_right; unsigned mask, mask_right;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -402,16 +404,20 @@ void pgfx_fillrect(int x, int y, int width, int height)
{ {
unsigned char *dst_col = dst; unsigned char *dst_col = dst;
for (i = height; i > 0; i--) dst_end = dst_col + height;
do
bfunc(dst_col++, mask, 0x1F); bfunc(dst_col++, mask, 0x1F);
while (dst_col < dst_end);
dst += pixel_height; dst += pixel_height;
mask = 0x1F; mask = 0x1F;
} }
mask &= mask_right; mask &= mask_right;
for (i = height; i > 0; i--) dst_end = dst + height;
do
bfunc(dst++, mask, 0x1F); bfunc(dst++, mask, 0x1F);
while (dst < dst_end);
} }
/* About PlayerGFX internal bitmap format: /* About PlayerGFX internal bitmap format:
@ -429,7 +435,7 @@ void pgfx_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height) int stride, int x, int y, int width, int height)
{ {
int nx, shift; int nx, shift;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask, mask_right; unsigned mask, mask_right;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -465,10 +471,11 @@ void pgfx_bitmap_part(const unsigned char *src, int src_x, int src_y,
mask = 0x1F >> (x % 5); mask = 0x1F >> (x % 5);
mask_right = 0x1F0 >> (nx % 5); mask_right = 0x1F0 >> (nx % 5);
for (y = 0; y < height; y++) dst_end = dst + height;
do
{ {
const unsigned char *src_row = src; const unsigned char *src_row = src;
unsigned char *dst_row = dst; unsigned char *dst_row = dst++;
unsigned mask_row = mask; unsigned mask_row = mask;
unsigned data = *src_row++; unsigned data = *src_row++;
int extrabits = shift; int extrabits = shift;
@ -493,8 +500,8 @@ void pgfx_bitmap_part(const unsigned char *src, int src_x, int src_y,
bfunc(dst_row, mask_row & mask_right, data >> extrabits); bfunc(dst_row, mask_row & mask_right, data >> extrabits);
src += stride; src += stride;
dst++;
} }
while (dst < dst_end);
} }
/* Draw a full bitmap */ /* Draw a full bitmap */

View file

@ -653,7 +653,7 @@ void lcd_remote_drawline(int x1, int y1, int x2, int y2)
void lcd_remote_hline(int x1, int x2, int y) void lcd_remote_hline(int x1, int x2, int y)
{ {
int x; int x;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask; unsigned mask;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -680,8 +680,10 @@ void lcd_remote_hline(int x1, int x2, int y)
dst = &lcd_remote_framebuffer[y>>3][x1]; dst = &lcd_remote_framebuffer[y>>3][x1];
mask = 1 << (y & 7); mask = 1 << (y & 7);
for (x = x1; x <= x2; x++) dst_end = dst + x2 - x1;
do
bfunc(dst++, mask, 0xFFu); bfunc(dst++, mask, 0xFFu);
while (dst <= dst_end);
} }
/* Draw a vertical line (optimised) */ /* Draw a vertical line (optimised) */
@ -745,8 +747,8 @@ void lcd_remote_drawrect(int x, int y, int width, int height)
/* Fill a rectangular area */ /* Fill a rectangular area */
void lcd_remote_fillrect(int x, int y, int width, int height) void lcd_remote_fillrect(int x, int y, int width, int height)
{ {
int ny, i; int ny;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask, mask_bottom; unsigned mask, mask_bottom;
unsigned bits = 0xFFu; unsigned bits = 0xFFu;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -791,8 +793,10 @@ void lcd_remote_fillrect(int x, int y, int width, int height)
{ {
unsigned char *dst_row = dst; unsigned char *dst_row = dst;
for (i = width; i > 0; i--) dst_end = dst_row + width;
do
bfunc(dst_row++, mask, 0xFFu); bfunc(dst_row++, mask, 0xFFu);
while (dst_row < dst_end);
} }
dst += LCD_REMOTE_WIDTH; dst += LCD_REMOTE_WIDTH;
@ -804,8 +808,10 @@ void lcd_remote_fillrect(int x, int y, int width, int height)
memset(dst, bits, width); memset(dst, bits, width);
else else
{ {
for (i = width; i > 0; i--) dst_end = dst + width;
do
bfunc(dst++, mask, 0xFFu); bfunc(dst++, mask, 0xFFu);
while (dst < dst_end);
} }
} }
@ -827,8 +833,8 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y, void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height) int stride, int x, int y, int width, int height)
{ {
int shift, ny, i; int shift, ny;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask, mask_bottom; unsigned mask, mask_bottom;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -879,8 +885,10 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
const unsigned char *src_row = src; const unsigned char *src_row = src;
unsigned char *dst_row = dst; unsigned char *dst_row = dst;
for (i = width; i > 0; i--) dst_end = dst_row + width;
do
bfunc(dst_row++, mask, *src_row++); bfunc(dst_row++, mask, *src_row++);
while (dst_row < dst_end);
} }
src += stride; src += stride;
@ -893,13 +901,16 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
memcpy(dst, src, width); memcpy(dst, src, width);
else else
{ {
for (i = width; i > 0; i--) dst_end = dst + width;
do
bfunc(dst++, mask, *src++); bfunc(dst++, mask, *src++);
while (dst < dst_end);
} }
} }
else else
{ {
for (x = 0; x < width; x++) dst_end = dst + width;
do
{ {
const unsigned char *src_col = src++; const unsigned char *src_col = src++;
unsigned char *dst_col = dst++; unsigned char *dst_col = dst++;
@ -925,6 +936,7 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
data |= *src_col << shift; data |= *src_col << shift;
bfunc(dst_col, mask_col & mask_bottom, data); bfunc(dst_col, mask_col & mask_bottom, data);
} }
while (dst < dst_end);
} }
} }

View file

@ -492,7 +492,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
void lcd_hline(int x1, int x2, int y) void lcd_hline(int x1, int x2, int y)
{ {
int x; int x;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask; unsigned mask;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -518,8 +518,10 @@ void lcd_hline(int x1, int x2, int y)
dst = &lcd_framebuffer[y>>3][x1]; dst = &lcd_framebuffer[y>>3][x1];
mask = 1 << (y & 7); mask = 1 << (y & 7);
for (x = x1; x <= x2; x++) dst_end = dst + x2 - x1;
do
bfunc(dst++, mask, 0xFFu); bfunc(dst++, mask, 0xFFu);
while (dst <= dst_end);
} }
/* Draw a vertical line (optimised) */ /* Draw a vertical line (optimised) */
@ -582,8 +584,8 @@ void lcd_drawrect(int x, int y, int width, int height)
/* Fill a rectangular area */ /* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height) void lcd_fillrect(int x, int y, int width, int height)
{ {
int ny, i; int ny;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask, mask_bottom; unsigned mask, mask_bottom;
unsigned bits = 0xFFu; unsigned bits = 0xFFu;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -628,8 +630,10 @@ void lcd_fillrect(int x, int y, int width, int height)
{ {
unsigned char *dst_row = dst; unsigned char *dst_row = dst;
for (i = width; i > 0; i--) dst_end = dst_row + width;
do
bfunc(dst_row++, mask, 0xFFu); bfunc(dst_row++, mask, 0xFFu);
while (dst_row < dst_end);
} }
dst += LCD_WIDTH; dst += LCD_WIDTH;
@ -641,8 +645,10 @@ void lcd_fillrect(int x, int y, int width, int height)
memset(dst, bits, width); memset(dst, bits, width);
else else
{ {
for (i = width; i > 0; i--) dst_end = dst + width;
do
bfunc(dst++, mask, 0xFFu); bfunc(dst++, mask, 0xFFu);
while (dst < dst_end);
} }
} }
@ -664,8 +670,8 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height) int stride, int x, int y, int width, int height)
{ {
int shift, ny, i; int shift, ny;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask, mask_bottom; unsigned mask, mask_bottom;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -716,8 +722,10 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
const unsigned char *src_row = src; const unsigned char *src_row = src;
unsigned char *dst_row = dst; unsigned char *dst_row = dst;
for (i = width; i > 0; i--) dst_end = dst_row + width;
do
bfunc(dst_row++, mask, *src_row++); bfunc(dst_row++, mask, *src_row++);
while (dst_row < dst_end);
} }
src += stride; src += stride;
@ -730,13 +738,16 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
memcpy(dst, src, width); memcpy(dst, src, width);
else else
{ {
for (i = width; i > 0; i--) dst_end = dst + width;
do
bfunc(dst++, mask, *src++); bfunc(dst++, mask, *src++);
while (dst < dst_end);
} }
} }
else else
{ {
for (x = 0; x < width; x++) dst_end = dst + width;
do
{ {
const unsigned char *src_col = src++; const unsigned char *src_col = src++;
unsigned char *dst_col = dst++; unsigned char *dst_col = dst++;
@ -762,6 +773,7 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
data |= *src_col << shift; data |= *src_col << shift;
bfunc(dst_col, mask_col & mask_bottom, data); bfunc(dst_col, mask_col & mask_bottom, data);
} }
while (dst < dst_end);
} }
} }

View file

@ -549,7 +549,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
void lcd_hline(int x1, int x2, int y) void lcd_hline(int x1, int x2, int y)
{ {
int x; int x;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask; unsigned mask;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -575,8 +575,10 @@ void lcd_hline(int x1, int x2, int y)
dst = &lcd_framebuffer[y>>3][x1]; dst = &lcd_framebuffer[y>>3][x1];
mask = 1 << (y & 7); mask = 1 << (y & 7);
for (x = x1; x <= x2; x++) dst_end = dst + x2 - x1;
do
bfunc(dst++, mask, 0xFFu); bfunc(dst++, mask, 0xFFu);
while (dst <= dst_end);
} }
/* Draw a vertical line (optimised) */ /* Draw a vertical line (optimised) */
@ -639,8 +641,8 @@ void lcd_drawrect(int x, int y, int width, int height)
/* Fill a rectangular area */ /* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height) void lcd_fillrect(int x, int y, int width, int height)
{ {
int ny, i; int ny;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask, mask_bottom; unsigned mask, mask_bottom;
unsigned bits = 0xFFu; unsigned bits = 0xFFu;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -685,8 +687,10 @@ void lcd_fillrect(int x, int y, int width, int height)
{ {
unsigned char *dst_row = dst; unsigned char *dst_row = dst;
for (i = width; i > 0; i--) dst_end = dst_row + width;
do
bfunc(dst_row++, mask, 0xFFu); bfunc(dst_row++, mask, 0xFFu);
while (dst_row < dst_end);
} }
dst += LCD_WIDTH; dst += LCD_WIDTH;
@ -698,8 +702,10 @@ void lcd_fillrect(int x, int y, int width, int height)
memset(dst, bits, width); memset(dst, bits, width);
else else
{ {
for (i = width; i > 0; i--) dst_end = dst + width;
do
bfunc(dst++, mask, 0xFFu); bfunc(dst++, mask, 0xFFu);
while (dst < dst_end);
} }
} }
@ -721,8 +727,8 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height) int stride, int x, int y, int width, int height)
{ {
int shift, ny, i; int shift, ny;
unsigned char *dst; unsigned char *dst, *dst_end;
unsigned mask, mask_bottom; unsigned mask, mask_bottom;
lcd_blockfunc_type *bfunc; lcd_blockfunc_type *bfunc;
@ -772,9 +778,11 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
{ {
const unsigned char *src_row = src; const unsigned char *src_row = src;
unsigned char *dst_row = dst; unsigned char *dst_row = dst;
for (i = width; i > 0; i--) dst_end = dst_row + width;
do
bfunc(dst_row++, mask, *src_row++); bfunc(dst_row++, mask, *src_row++);
while (dst_row < dst_end);
} }
src += stride; src += stride;
@ -787,13 +795,16 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
memcpy(dst, src, width); memcpy(dst, src, width);
else else
{ {
for (i = width; i > 0; i--) dst_end = dst + width;
do
bfunc(dst++, mask, *src++); bfunc(dst++, mask, *src++);
while (dst < dst_end);
} }
} }
else else
{ {
for (x = 0; x < width; x++) dst_end = dst + width;
do
{ {
const unsigned char *src_col = src++; const unsigned char *src_col = src++;
unsigned char *dst_col = dst++; unsigned char *dst_col = dst++;
@ -819,6 +830,7 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
data |= *src_col << shift; data |= *src_col << shift;
bfunc(dst_col, mask_col & mask_bottom, data); bfunc(dst_col, mask_col & mask_bottom, data);
} }
while (dst < dst_end);
} }
} }