summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/lcd-16bit.c67
1 files changed, 28 insertions, 39 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index 24f026b290..2d228b6566 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -526,6 +526,27 @@ void lcd_fillrect(int x, int y, int width, int height)
526 while (dst < dst_end); 526 while (dst < dst_end);
527} 527}
528 528
529/* Fill a rectangle with a gradient */
530void lcd_gradient_rect(int x1, int x2, int y, int h)
531{
532 int h_r = RGB_UNPACK_RED(lss_pattern) << 16;
533 int h_b = RGB_UNPACK_BLUE(lss_pattern) << 16;
534 int h_g = RGB_UNPACK_GREEN(lss_pattern) << 16;
535 int rstep = (h_r - ((signed)RGB_UNPACK_RED(lse_pattern) << 16)) / h;
536 int gstep = (h_g - ((signed)RGB_UNPACK_GREEN(lse_pattern) << 16)) / h;
537 int bstep = (h_b - ((signed)RGB_UNPACK_BLUE(lse_pattern) << 16)) / h;
538 int count;
539
540 fg_pattern = lss_pattern;
541 for(count = 0; count < h; count++) {
542 lcd_hline(x1, x2, y + count);
543 h_r -= rstep;
544 h_g -= gstep;
545 h_b -= bstep;
546 fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
547 }
548}
549
529/* About Rockbox' internal monochrome bitmap format: 550/* About Rockbox' internal monochrome bitmap format:
530 * 551 *
531 * A bitmap contains one bit for every pixel that defines if that pixel is 552 * A bitmap contains one bit for every pixel that defines if that pixel is
@@ -829,10 +850,7 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style,
829 ypos = ymargin + y*h; 850 ypos = ymargin + y*h;
830 drawmode = (style & STYLE_INVERT) ? 851 drawmode = (style & STYLE_INVERT) ?
831 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 852 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
832 if (style & STYLE_GRADIENT || style & STYLE_COLORBAR) { 853 if (style & STYLE_COLORED) {
833 fg_pattern = lss_pattern;
834 }
835 else if (style & STYLE_COLORED) {
836 if (drawmode == DRMODE_SOLID) 854 if (drawmode == DRMODE_SOLID)
837 fg_pattern = style & STYLE_COLOR_MASK; 855 fg_pattern = style & STYLE_COLOR_MASK;
838 else 856 else
@@ -842,26 +860,13 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style,
842 xrect = xpos + MAX(w - offset, 0); 860 xrect = xpos + MAX(w - offset, 0);
843 861
844 if (style & STYLE_GRADIENT) { 862 if (style & STYLE_GRADIENT) {
845 int h_r = RGB_UNPACK_RED(lss_pattern) << 16;
846 int h_b = RGB_UNPACK_BLUE(lss_pattern) << 16;
847 int h_g = RGB_UNPACK_GREEN(lss_pattern) << 16;
848 int rstep = (h_r - ((signed)RGB_UNPACK_RED(lse_pattern) << 16)) / h;
849 int gstep = (h_g - ((signed)RGB_UNPACK_GREEN(lse_pattern) << 16)) / h;
850 int bstep = (h_b - ((signed)RGB_UNPACK_BLUE(lse_pattern) << 16)) / h;
851 int count;
852
853 drawmode = DRMODE_FG; 863 drawmode = DRMODE_FG;
854 for(count = 0; count < h; count++) { 864 lcd_gradient_rect(xpos, LCD_WIDTH, ypos, h);
855 lcd_hline(xpos, LCD_WIDTH, ypos + count);
856 h_r -= rstep;
857 h_g -= gstep;
858 h_b -= bstep;
859 fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
860 }
861 fg_pattern = lst_pattern; 865 fg_pattern = lst_pattern;
862 } 866 }
863 else if (style & STYLE_COLORBAR) { 867 else if (style & STYLE_COLORBAR) {
864 drawmode = DRMODE_FG; 868 drawmode = DRMODE_FG;
869 fg_pattern = lss_pattern;
865 lcd_fillrect(xpos, ypos, LCD_WIDTH - xpos, h); 870 lcd_fillrect(xpos, ypos, LCD_WIDTH - xpos, h);
866 fg_pattern = lst_pattern; 871 fg_pattern = lst_pattern;
867 } 872 }
@@ -1023,32 +1028,16 @@ void lcd_scroll_fn(void)
1023 drawmode = s->invert == 1 ? 1028 drawmode = s->invert == 1 ?
1024 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 1029 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
1025 if (s->invert == 2) { 1030 if (s->invert == 2) {
1026 fg_pattern = lss_pattern; 1031 /* Solid colour line selector */
1027 drawmode = DRMODE_FG; 1032 drawmode = DRMODE_FG;
1033 fg_pattern = lss_pattern;
1028 lcd_fillrect(0, ypos, LCD_WIDTH, pf->height); 1034 lcd_fillrect(0, ypos, LCD_WIDTH, pf->height);
1029 fg_pattern = lst_pattern; 1035 fg_pattern = lst_pattern;
1030 } 1036 }
1031 else if (s->invert == 3) { 1037 else if (s->invert == 3) {
1032 int h_r = RGB_UNPACK_RED(lss_pattern) << 16; 1038 /* Gradient line selector */
1033 int h_b = RGB_UNPACK_BLUE(lss_pattern) << 16;
1034 int h_g = RGB_UNPACK_GREEN(lss_pattern) << 16;
1035 int rstep = (h_r - ((signed)RGB_UNPACK_RED(lse_pattern) << 16))
1036 / (signed)pf->height;
1037 int gstep = (h_g - ((signed)RGB_UNPACK_GREEN(lse_pattern) << 16))
1038 / (signed)pf->height;
1039 int bstep = (h_b - ((signed)RGB_UNPACK_BLUE(lse_pattern) << 16))
1040 / (signed)pf->height;
1041 unsigned int count;
1042
1043 fg_pattern = lss_pattern;
1044 drawmode = DRMODE_FG; 1039 drawmode = DRMODE_FG;
1045 for(count = 0; count < pf->height; count++) { 1040 lcd_gradient_rect(0, LCD_WIDTH, ypos, (signed)pf->height);
1046 lcd_hline(0, LCD_WIDTH , ypos + count);
1047 h_r -= rstep;
1048 h_g -= gstep;
1049 h_b -= bstep;
1050 fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
1051 }
1052 fg_pattern = lst_pattern; 1041 fg_pattern = lst_pattern;
1053 } 1042 }
1054 lcd_putsxyofs(xpos, ypos, s->offset, s->line); 1043 lcd_putsxyofs(xpos, ypos, s->offset, s->line);