diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-11-05 14:40:14 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-11-05 14:40:14 +0000 |
commit | 32c69452d699ce4dbf35e843b2f69507321e1b71 (patch) | |
tree | e0c977f82ba7e985cd9ac09a00ea3ce4497896e1 /apps/plugins/lib/gray_draw.c | |
parent | 0b9e266b1e436ac34b9e2c2df4f3cea393b65cbd (diff) | |
download | rockbox-32c69452d699ce4dbf35e843b2f69507321e1b71.tar.gz rockbox-32c69452d699ce4dbf35e843b2f69507321e1b71.zip |
Grayscale lib: Using a 32x32->32 bit multiplication is better on ARM, as 16x16->32 bit isn't a single instruction. Renamed the macro for pointing out that it's not necessarily 16 bit anymore, and to avoid collisions with similar macros in plugins.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11436 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib/gray_draw.c')
-rw-r--r-- | apps/plugins/lib/gray_draw.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/apps/plugins/lib/gray_draw.c b/apps/plugins/lib/gray_draw.c index e501618e8d..b66b8d708a 100644 --- a/apps/plugins/lib/gray_draw.c +++ b/apps/plugins/lib/gray_draw.c | |||
@@ -65,7 +65,7 @@ void gray_clear_display(void) | |||
65 | _gray_info.fg_index : _gray_info.bg_index; | 65 | _gray_info.fg_index : _gray_info.bg_index; |
66 | 66 | ||
67 | _gray_rb->memset(_gray_info.cur_buffer, brightness, | 67 | _gray_rb->memset(_gray_info.cur_buffer, brightness, |
68 | MULU16(_gray_info.width, _gray_info.height)); | 68 | _GRAY_MULUQ(_gray_info.width, _gray_info.height)); |
69 | } | 69 | } |
70 | 70 | ||
71 | /* Set a single pixel */ | 71 | /* Set a single pixel */ |
@@ -74,10 +74,10 @@ void gray_drawpixel(int x, int y) | |||
74 | if (((unsigned)x < (unsigned)_gray_info.width) | 74 | if (((unsigned)x < (unsigned)_gray_info.width) |
75 | && ((unsigned)y < (unsigned)_gray_info.height)) | 75 | && ((unsigned)y < (unsigned)_gray_info.height)) |
76 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 76 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
77 | _gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[MULU16(y, | 77 | _gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[_GRAY_MULUQ(y, |
78 | _gray_info.width) + x]); | 78 | _gray_info.width) + x]); |
79 | #else | 79 | #else |
80 | _gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[MULU16(x, | 80 | _gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[_GRAY_MULUQ(x, |
81 | _gray_info.height) + y]); | 81 | _gray_info.height) + y]); |
82 | #endif | 82 | #endif |
83 | } | 83 | } |
@@ -138,9 +138,9 @@ void gray_drawline(int x1, int y1, int x2, int y2) | |||
138 | if (((unsigned)x < (unsigned)_gray_info.width) | 138 | if (((unsigned)x < (unsigned)_gray_info.width) |
139 | && ((unsigned)y < (unsigned)_gray_info.height)) | 139 | && ((unsigned)y < (unsigned)_gray_info.height)) |
140 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 140 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
141 | pfunc(&_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]); | 141 | pfunc(&_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x]); |
142 | #else | 142 | #else |
143 | pfunc(&_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]); | 143 | pfunc(&_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y]); |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | if (d < 0) | 146 | if (d < 0) |
@@ -205,7 +205,7 @@ void gray_hline(int x1, int x2, int y) | |||
205 | } | 205 | } |
206 | } | 206 | } |
207 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; | 207 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; |
208 | dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x1]; | 208 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x1]; |
209 | 209 | ||
210 | if (fillopt) | 210 | if (fillopt) |
211 | _gray_rb->memset(dst, bits, x2 - x1 + 1); | 211 | _gray_rb->memset(dst, bits, x2 - x1 + 1); |
@@ -245,9 +245,9 @@ void gray_vline(int x, int y1, int y2) | |||
245 | y2 = _gray_info.height - 1; | 245 | y2 = _gray_info.height - 1; |
246 | 246 | ||
247 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; | 247 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; |
248 | dst = &_gray_info.cur_buffer[MULU16(y1, _gray_info.width) + x]; | 248 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y1, _gray_info.width) + x]; |
249 | 249 | ||
250 | dst_end = dst + MULU16(y2 - y1, _gray_info.width); | 250 | dst_end = dst + _GRAY_MULUQ(y2 - y1, _gray_info.width); |
251 | do | 251 | do |
252 | { | 252 | { |
253 | pfunc(dst); | 253 | pfunc(dst); |
@@ -354,9 +354,9 @@ void gray_hline(int x1, int x2, int y) | |||
354 | x2 = _gray_info.width - 1; | 354 | x2 = _gray_info.width - 1; |
355 | 355 | ||
356 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; | 356 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; |
357 | dst = &_gray_info.cur_buffer[MULU16(x1, _gray_info.height) + y]; | 357 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x1, _gray_info.height) + y]; |
358 | 358 | ||
359 | dst_end = dst + MULU16(x2 - x1, _gray_info.height); | 359 | dst_end = dst + _GRAY_MULUQ(x2 - x1, _gray_info.height); |
360 | do | 360 | do |
361 | { | 361 | { |
362 | pfunc(dst); | 362 | pfunc(dst); |
@@ -410,7 +410,7 @@ void gray_vline(int x, int y1, int y2) | |||
410 | } | 410 | } |
411 | } | 411 | } |
412 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; | 412 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; |
413 | dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y1]; | 413 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y1]; |
414 | 414 | ||
415 | if (fillopt) | 415 | if (fillopt) |
416 | _gray_rb->memset(dst, bits, y2 - y1 + 1); | 416 | _gray_rb->memset(dst, bits, y2 - y1 + 1); |
@@ -556,8 +556,8 @@ void gray_fillrect(int x, int y, int width, int height) | |||
556 | } | 556 | } |
557 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; | 557 | pfunc = _gray_pixelfuncs[_gray_info.drawmode]; |
558 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 558 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
559 | dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]; | 559 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x]; |
560 | dst_end = dst + MULU16(height, _gray_info.width); | 560 | dst_end = dst + _GRAY_MULUQ(height, _gray_info.width); |
561 | 561 | ||
562 | do | 562 | do |
563 | { | 563 | { |
@@ -576,8 +576,8 @@ void gray_fillrect(int x, int y, int width, int height) | |||
576 | } | 576 | } |
577 | while (dst < dst_end); | 577 | while (dst < dst_end); |
578 | #else | 578 | #else |
579 | dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]; | 579 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y]; |
580 | dst_end = dst + MULU16(width, _gray_info.height); | 580 | dst_end = dst + _GRAY_MULUQ(width, _gray_info.height); |
581 | 581 | ||
582 | do | 582 | do |
583 | { | 583 | { |
@@ -639,14 +639,14 @@ void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
639 | if (y + height > _gray_info.height) | 639 | if (y + height > _gray_info.height) |
640 | height = _gray_info.height - y; | 640 | height = _gray_info.height - y; |
641 | 641 | ||
642 | src += MULU16(stride, src_y >> 3) + src_x; /* move starting point */ | 642 | src += _GRAY_MULUQ(stride, src_y >> 3) + src_x; /* move starting point */ |
643 | src_y &= 7; | 643 | src_y &= 7; |
644 | src_end = src + width; | 644 | src_end = src + width; |
645 | 645 | ||
646 | fgfunc = _gray_pixelfuncs[_gray_info.drawmode]; | 646 | fgfunc = _gray_pixelfuncs[_gray_info.drawmode]; |
647 | bgfunc = _gray_pixelfuncs[_gray_info.drawmode ^ DRMODE_INVERSEVID]; | 647 | bgfunc = _gray_pixelfuncs[_gray_info.drawmode ^ DRMODE_INVERSEVID]; |
648 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 648 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
649 | dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]; | 649 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x]; |
650 | 650 | ||
651 | do | 651 | do |
652 | { | 652 | { |
@@ -655,7 +655,7 @@ void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
655 | unsigned data = *src_col >> src_y; | 655 | unsigned data = *src_col >> src_y; |
656 | int numbits = 8 - src_y; | 656 | int numbits = 8 - src_y; |
657 | 657 | ||
658 | dst_end = dst_col + MULU16(height, _gray_info.width); | 658 | dst_end = dst_col + _GRAY_MULUQ(height, _gray_info.width); |
659 | do | 659 | do |
660 | { | 660 | { |
661 | if (data & 0x01) | 661 | if (data & 0x01) |
@@ -677,7 +677,7 @@ void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
677 | } | 677 | } |
678 | while (src < src_end); | 678 | while (src < src_end); |
679 | #else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ | 679 | #else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ |
680 | dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]; | 680 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y]; |
681 | 681 | ||
682 | do | 682 | do |
683 | { | 683 | { |
@@ -745,10 +745,10 @@ void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
745 | if (y + height > _gray_info.height) | 745 | if (y + height > _gray_info.height) |
746 | height = _gray_info.height - y; | 746 | height = _gray_info.height - y; |
747 | 747 | ||
748 | src += MULU16(stride, src_y) + src_x; /* move starting point */ | 748 | src += _GRAY_MULUQ(stride, src_y) + src_x; /* move starting point */ |
749 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 749 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
750 | dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]; | 750 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x]; |
751 | dst_end = dst + MULU16(height, _gray_info.width); | 751 | dst_end = dst + _GRAY_MULUQ(height, _gray_info.width); |
752 | 752 | ||
753 | do | 753 | do |
754 | { | 754 | { |
@@ -765,14 +765,14 @@ void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
765 | } | 765 | } |
766 | while (dst < dst_end); | 766 | while (dst < dst_end); |
767 | #else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ | 767 | #else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ |
768 | dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]; | 768 | dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y]; |
769 | dst_end = dst + height; | 769 | dst_end = dst + height; |
770 | 770 | ||
771 | do | 771 | do |
772 | { | 772 | { |
773 | const unsigned char *src_row = src; | 773 | const unsigned char *src_row = src; |
774 | unsigned char *dst_row = dst++; | 774 | unsigned char *dst_row = dst++; |
775 | unsigned char *row_end = dst_row + MULU16(width, _gray_info.height); | 775 | unsigned char *row_end = dst_row + _GRAY_MULUQ(width, _gray_info.height); |
776 | 776 | ||
777 | do | 777 | do |
778 | { | 778 | { |
@@ -843,7 +843,7 @@ void gray_putsxy(int x, int y, const unsigned char *str) | |||
843 | void gray_ub_clear_display(void) | 843 | void gray_ub_clear_display(void) |
844 | { | 844 | { |
845 | _gray_rb->memset(_gray_info.cur_buffer, _gray_info.depth, | 845 | _gray_rb->memset(_gray_info.cur_buffer, _gray_info.depth, |
846 | MULU16(_gray_info.width, _gray_info.height)); | 846 | _GRAY_MULUQ(_gray_info.width, _gray_info.height)); |
847 | gray_update(); | 847 | gray_update(); |
848 | } | 848 | } |
849 | 849 | ||
@@ -860,7 +860,7 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
860 | /* Clear the greyscale display (sets all pixels to white) */ | 860 | /* Clear the greyscale display (sets all pixels to white) */ |
861 | void gray_ub_clear_display(void) | 861 | void gray_ub_clear_display(void) |
862 | { | 862 | { |
863 | _gray_rb->memset(_gray_info.plane_data, 0, MULU16(_gray_info.depth, | 863 | _gray_rb->memset(_gray_info.plane_data, 0, _GRAY_MULUQ(_gray_info.depth, |
864 | _gray_info.plane_size)); | 864 | _gray_info.plane_size)); |
865 | } | 865 | } |
866 | 866 | ||
@@ -1172,7 +1172,7 @@ static void _writearray(unsigned char *address, const unsigned char *src, | |||
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | addr = address; | 1174 | addr = address; |
1175 | end = addr + MULU16(_gray_info.depth, _gray_info.plane_size); | 1175 | end = addr + _GRAY_MULUQ(_gray_info.depth, _gray_info.plane_size); |
1176 | 1176 | ||
1177 | /* set the bits for all 8 pixels in all bytes according to the | 1177 | /* set the bits for all 8 pixels in all bytes according to the |
1178 | * precalculated patterns on the pattern stack */ | 1178 | * precalculated patterns on the pattern stack */ |
@@ -1243,14 +1243,14 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
1243 | height = _gray_info.height - y; | 1243 | height = _gray_info.height - y; |
1244 | 1244 | ||
1245 | shift = x & 7; | 1245 | shift = x & 7; |
1246 | src += MULU16(stride, src_y) + src_x - shift; | 1246 | src += _GRAY_MULUQ(stride, src_y) + src_x - shift; |
1247 | dst = _gray_info.plane_data + (x >> 3) + MULU16(_gray_info.bwidth, y); | 1247 | dst = _gray_info.plane_data + (x >> 3) + _GRAY_MULUQ(_gray_info.bwidth, y); |
1248 | nx = width - 1 + shift; | 1248 | nx = width - 1 + shift; |
1249 | 1249 | ||
1250 | mask = 0xFFu >> shift; | 1250 | mask = 0xFFu >> shift; |
1251 | mask_right = 0xFFu << (~nx & 7); | 1251 | mask_right = 0xFFu << (~nx & 7); |
1252 | 1252 | ||
1253 | dst_end = dst + MULU16(_gray_info.bwidth, height); | 1253 | dst_end = dst + _GRAY_MULUQ(_gray_info.bwidth, height); |
1254 | do | 1254 | do |
1255 | { | 1255 | { |
1256 | const unsigned char *src_row = src; | 1256 | const unsigned char *src_row = src; |
@@ -2038,7 +2038,7 @@ static void _writearray(unsigned char *address, const unsigned char *src, | |||
2038 | } | 2038 | } |
2039 | 2039 | ||
2040 | addr = address; | 2040 | addr = address; |
2041 | end = addr + MULU16(_gray_info.depth, _gray_info.plane_size); | 2041 | end = addr + _GRAY_MULUQ(_gray_info.depth, _gray_info.plane_size); |
2042 | 2042 | ||
2043 | /* set the bits for all 8 pixels in all bytes according to the | 2043 | /* set the bits for all 8 pixels in all bytes according to the |
2044 | * precalculated patterns on the pattern stack */ | 2044 | * precalculated patterns on the pattern stack */ |
@@ -2109,9 +2109,9 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
2109 | height = _gray_info.height - y; | 2109 | height = _gray_info.height - y; |
2110 | 2110 | ||
2111 | shift = y & 7; | 2111 | shift = y & 7; |
2112 | src += MULU16(stride, src_y) + src_x - MULU16(stride, shift); | 2112 | src += _GRAY_MULUQ(stride, src_y) + src_x - _GRAY_MULUQ(stride, shift); |
2113 | dst = _gray_info.plane_data + x | 2113 | dst = _gray_info.plane_data + x |
2114 | + MULU16(_gray_info.width, y >> 3); | 2114 | + _GRAY_MULUQ(_gray_info.width, y >> 3); |
2115 | ny = height - 1 + shift; | 2115 | ny = height - 1 + shift; |
2116 | 2116 | ||
2117 | mask = 0xFFu << shift; | 2117 | mask = 0xFFu << shift; |