diff options
Diffstat (limited to 'firmware/drivers/lcd-24bit.c')
-rw-r--r-- | firmware/drivers/lcd-24bit.c | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/firmware/drivers/lcd-24bit.c b/firmware/drivers/lcd-24bit.c index d95415e957..be0d3e239c 100644 --- a/firmware/drivers/lcd-24bit.c +++ b/firmware/drivers/lcd-24bit.c | |||
@@ -61,14 +61,15 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
61 | /* Clear the current viewport */ | 61 | /* Clear the current viewport */ |
62 | void lcd_clear_viewport(void) | 62 | void lcd_clear_viewport(void) |
63 | { | 63 | { |
64 | struct viewport *vp = lcd_current_viewport; | ||
64 | fb_data *dst, *dst_end; | 65 | fb_data *dst, *dst_end; |
65 | int x, y, width, height; | 66 | int x, y, width, height; |
66 | int len, step; | 67 | int len, step; |
67 | 68 | ||
68 | x = lcd_current_viewport->x; | 69 | x = vp->x; |
69 | y = lcd_current_viewport->y; | 70 | y = vp->y; |
70 | width = lcd_current_viewport->width; | 71 | width = vp->width; |
71 | height = lcd_current_viewport->height; | 72 | height = vp->height; |
72 | 73 | ||
73 | len = STRIDE_MAIN(width, height); | 74 | len = STRIDE_MAIN(width, height); |
74 | step = STRIDE_MAIN(ROW_INC, COL_INC); | 75 | step = STRIDE_MAIN(ROW_INC, COL_INC); |
@@ -76,9 +77,9 @@ void lcd_clear_viewport(void) | |||
76 | dst = FBADDR(x, y); | 77 | dst = FBADDR(x, y); |
77 | dst_end = FBADDR(x + width - 1 , y + height - 1); | 78 | dst_end = FBADDR(x + width - 1 , y + height - 1); |
78 | 79 | ||
79 | if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) | 80 | if (vp->drawmode & DRMODE_INVERSEVID) |
80 | { | 81 | { |
81 | fb_data px = FB_SCALARPACK(lcd_current_viewport->fg_pattern); | 82 | fb_data px = FB_SCALARPACK(vp->fg_pattern); |
82 | do | 83 | do |
83 | { | 84 | { |
84 | fb_data *end = dst + len; | 85 | fb_data *end = dst + len; |
@@ -93,7 +94,7 @@ void lcd_clear_viewport(void) | |||
93 | { | 94 | { |
94 | if (!lcd_backdrop) | 95 | if (!lcd_backdrop) |
95 | { | 96 | { |
96 | fb_data px = FB_SCALARPACK(lcd_current_viewport->bg_pattern); | 97 | fb_data px = FB_SCALARPACK(vp->bg_pattern); |
97 | do | 98 | do |
98 | { | 99 | { |
99 | fb_data *end = dst + len; | 100 | fb_data *end = dst + len; |
@@ -116,12 +117,12 @@ void lcd_clear_viewport(void) | |||
116 | } | 117 | } |
117 | } | 118 | } |
118 | 119 | ||
119 | if (lcd_current_viewport == &default_vp) | 120 | if (vp == &default_vp) |
120 | lcd_scroll_stop(); | 121 | lcd_scroll_stop(); |
121 | else | 122 | else |
122 | lcd_scroll_stop_viewport(lcd_current_viewport); | 123 | lcd_scroll_stop_viewport(vp); |
123 | 124 | ||
124 | lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN); | 125 | vp->flags &= ~(VP_FLAG_VP_SET_CLEAN); |
125 | } | 126 | } |
126 | 127 | ||
127 | /*** low-level drawing functions ***/ | 128 | /*** low-level drawing functions ***/ |
@@ -167,6 +168,7 @@ lcd_fastpixelfunc_type* const * lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor; | |||
167 | /* Fill a rectangular area */ | 168 | /* Fill a rectangular area */ |
168 | void lcd_fillrect(int x, int y, int width, int height) | 169 | void lcd_fillrect(int x, int y, int width, int height) |
169 | { | 170 | { |
171 | struct viewport *vp = lcd_current_viewport; | ||
170 | enum fill_opt fillopt = OPT_NONE; | 172 | enum fill_opt fillopt = OPT_NONE; |
171 | fb_data *dst, *dst_end; | 173 | fb_data *dst, *dst_end; |
172 | int len, step; | 174 | int len, step; |
@@ -177,14 +179,14 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
177 | return; | 179 | return; |
178 | 180 | ||
179 | /* drawmode and optimisation */ | 181 | /* drawmode and optimisation */ |
180 | if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) | 182 | if (vp->drawmode & DRMODE_INVERSEVID) |
181 | { | 183 | { |
182 | if (lcd_current_viewport->drawmode & DRMODE_BG) | 184 | if (vp->drawmode & DRMODE_BG) |
183 | { | 185 | { |
184 | if (!lcd_backdrop) | 186 | if (!lcd_backdrop) |
185 | { | 187 | { |
186 | fillopt = OPT_SET; | 188 | fillopt = OPT_SET; |
187 | bits = FB_SCALARPACK(lcd_current_viewport->bg_pattern); | 189 | bits = FB_SCALARPACK(vp->bg_pattern); |
188 | } | 190 | } |
189 | else | 191 | else |
190 | fillopt = OPT_COPY; | 192 | fillopt = OPT_COPY; |
@@ -192,13 +194,13 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
192 | } | 194 | } |
193 | else | 195 | else |
194 | { | 196 | { |
195 | if (lcd_current_viewport->drawmode & DRMODE_FG) | 197 | if (vp->drawmode & DRMODE_FG) |
196 | { | 198 | { |
197 | fillopt = OPT_SET; | 199 | fillopt = OPT_SET; |
198 | bits = FB_SCALARPACK(lcd_current_viewport->fg_pattern); | 200 | bits = FB_SCALARPACK(vp->fg_pattern); |
199 | } | 201 | } |
200 | } | 202 | } |
201 | if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT) | 203 | if (fillopt == OPT_NONE && vp->drawmode != DRMODE_COMPLEMENT) |
202 | return; | 204 | return; |
203 | 205 | ||
204 | dst = FBADDR(x, y); | 206 | dst = FBADDR(x, y); |
@@ -259,10 +261,11 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
259 | int src_y, int stride, int x, int y, | 261 | int src_y, int stride, int x, int y, |
260 | int width, int height) | 262 | int width, int height) |
261 | { | 263 | { |
264 | struct viewport *vp = lcd_current_viewport; | ||
262 | const unsigned char *src_end; | 265 | const unsigned char *src_end; |
263 | fb_data *dst, *dst_col; | 266 | fb_data *dst, *dst_col; |
264 | unsigned dmask = 0x100; /* bit 8 == sentinel */ | 267 | unsigned dmask = 0x100; /* bit 8 == sentinel */ |
265 | int drmode = lcd_current_viewport->drawmode; | 268 | int drmode = vp->drawmode; |
266 | int row; | 269 | int row; |
267 | 270 | ||
268 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 271 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) |
@@ -332,7 +335,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
332 | break; | 335 | break; |
333 | 336 | ||
334 | case DRMODE_BG: | 337 | case DRMODE_BG: |
335 | bg = FB_SCALARPACK(lcd_current_viewport->bg_pattern); | 338 | bg = FB_SCALARPACK(vp->bg_pattern); |
336 | do | 339 | do |
337 | { | 340 | { |
338 | if (!(data & 0x01)) | 341 | if (!(data & 0x01)) |
@@ -345,7 +348,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
345 | break; | 348 | break; |
346 | 349 | ||
347 | case DRMODE_FG: | 350 | case DRMODE_FG: |
348 | fg = FB_SCALARPACK(lcd_current_viewport->fg_pattern); | 351 | fg = FB_SCALARPACK(vp->fg_pattern); |
349 | do | 352 | do |
350 | { | 353 | { |
351 | if (data & 0x01) | 354 | if (data & 0x01) |
@@ -358,7 +361,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
358 | break; | 361 | break; |
359 | 362 | ||
360 | case DRMODE_SOLID|DRMODE_INT_BD: | 363 | case DRMODE_SOLID|DRMODE_INT_BD: |
361 | fg = FB_SCALARPACK(lcd_current_viewport->fg_pattern); | 364 | fg = FB_SCALARPACK(vp->fg_pattern); |
362 | bo = lcd_backdrop_offset; | 365 | bo = lcd_backdrop_offset; |
363 | do | 366 | do |
364 | { | 367 | { |
@@ -371,8 +374,8 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
371 | break; | 374 | break; |
372 | 375 | ||
373 | case DRMODE_SOLID: | 376 | case DRMODE_SOLID: |
374 | fg = FB_SCALARPACK(lcd_current_viewport->fg_pattern); | 377 | fg = FB_SCALARPACK(vp->fg_pattern); |
375 | bg = FB_SCALARPACK(lcd_current_viewport->bg_pattern); | 378 | bg = FB_SCALARPACK(vp->bg_pattern); |
376 | do | 379 | do |
377 | { | 380 | { |
378 | *dst = (data & 0x01) ? fg : bg; | 381 | *dst = (data & 0x01) ? fg : bg; |
@@ -442,9 +445,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
442 | int width, int height, | 445 | int width, int height, |
443 | int stride_image, int stride_src) | 446 | int stride_image, int stride_src) |
444 | { | 447 | { |
448 | struct viewport *vp = lcd_current_viewport; | ||
445 | fb_data *dst, *dst_row; | 449 | fb_data *dst, *dst_row; |
446 | unsigned dmask = 0x00000000; | 450 | unsigned dmask = 0x00000000; |
447 | int drmode = lcd_current_viewport->drawmode; | 451 | int drmode = vp->drawmode; |
448 | 452 | ||
449 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 453 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) |
450 | return; | 454 | return; |
@@ -570,7 +574,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
570 | while (--col); | 574 | while (--col); |
571 | break; | 575 | break; |
572 | case DRMODE_BG: | 576 | case DRMODE_BG: |
573 | bg = lcd_current_viewport->bg_pattern; | 577 | bg = vp->bg_pattern; |
574 | do | 578 | do |
575 | { | 579 | { |
576 | unsigned px = FB_UNPACK_SCALAR_LCD(*dst); | 580 | unsigned px = FB_UNPACK_SCALAR_LCD(*dst); |
@@ -593,7 +597,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
593 | while (--col); | 597 | while (--col); |
594 | break; | 598 | break; |
595 | case DRMODE_FG: | 599 | case DRMODE_FG: |
596 | fg = lcd_current_viewport->fg_pattern; | 600 | fg = vp->fg_pattern; |
597 | do | 601 | do |
598 | { | 602 | { |
599 | unsigned px = FB_UNPACK_SCALAR_LCD(*dst); | 603 | unsigned px = FB_UNPACK_SCALAR_LCD(*dst); |
@@ -605,7 +609,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
605 | break; | 609 | break; |
606 | case DRMODE_SOLID|DRMODE_INT_BD: | 610 | case DRMODE_SOLID|DRMODE_INT_BD: |
607 | bo = lcd_backdrop_offset; | 611 | bo = lcd_backdrop_offset; |
608 | fg = lcd_current_viewport->fg_pattern; | 612 | fg = vp->fg_pattern; |
609 | do | 613 | do |
610 | { | 614 | { |
611 | unsigned c = FB_UNPACK_SCALAR_LCD(*(fb_data *)((uintptr_t)dst + bo)); | 615 | unsigned c = FB_UNPACK_SCALAR_LCD(*(fb_data *)((uintptr_t)dst + bo)); |
@@ -616,7 +620,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
616 | while (--col); | 620 | while (--col); |
617 | break; | 621 | break; |
618 | case DRMODE_SOLID|DRMODE_INT_IMG: | 622 | case DRMODE_SOLID|DRMODE_INT_IMG: |
619 | bg = lcd_current_viewport->bg_pattern; | 623 | bg = vp->bg_pattern; |
620 | img_offset = image - dst; | 624 | img_offset = image - dst; |
621 | do | 625 | do |
622 | { | 626 | { |
@@ -641,8 +645,8 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
641 | while (--col); | 645 | while (--col); |
642 | break; | 646 | break; |
643 | case DRMODE_SOLID: | 647 | case DRMODE_SOLID: |
644 | bg = lcd_current_viewport->bg_pattern; | 648 | bg = vp->bg_pattern; |
645 | fg = lcd_current_viewport->fg_pattern; | 649 | fg = vp->fg_pattern; |
646 | do | 650 | do |
647 | { | 651 | { |
648 | *dst = blend_two_colors(bg, fg, data & ALPHA_COLOR_LOOKUP_SIZE ); | 652 | *dst = blend_two_colors(bg, fg, data & ALPHA_COLOR_LOOKUP_SIZE ); |
@@ -689,9 +693,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
689 | /* Draw a horizontal line (optimised) */ | 693 | /* Draw a horizontal line (optimised) */ |
690 | void lcd_hline(int x1, int x2, int y) | 694 | void lcd_hline(int x1, int x2, int y) |
691 | { | 695 | { |
696 | struct viewport *vp = lcd_current_viewport; | ||
692 | int width; | 697 | int width; |
693 | fb_data *dst, *dst_end; | 698 | fb_data *dst, *dst_end; |
694 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; | 699 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; |
695 | 700 | ||
696 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) | 701 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) |
697 | return; | 702 | return; |
@@ -710,8 +715,9 @@ void lcd_hline(int x1, int x2, int y) | |||
710 | /* Draw a vertical line (optimised) */ | 715 | /* Draw a vertical line (optimised) */ |
711 | void lcd_vline(int x, int y1, int y2) | 716 | void lcd_vline(int x, int y1, int y2) |
712 | { | 717 | { |
718 | struct viewport *vp = lcd_current_viewport; | ||
713 | fb_data *dst, *dst_end; | 719 | fb_data *dst, *dst_end; |
714 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; | 720 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; |
715 | 721 | ||
716 | if (!lcd_clip_viewport_vline(&x, &y1, &y2)) | 722 | if (!lcd_clip_viewport_vline(&x, &y1, &y2)) |
717 | return; | 723 | return; |
@@ -754,6 +760,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
754 | int src_y, int stride, int x, | 760 | int src_y, int stride, int x, |
755 | int y, int width, int height) | 761 | int y, int width, int height) |
756 | { | 762 | { |
763 | struct viewport *vp = lcd_current_viewport; | ||
757 | fb_data *dst; | 764 | fb_data *dst; |
758 | fb_data fg, transparent, replacewithfg; | 765 | fb_data fg, transparent, replacewithfg; |
759 | 766 | ||
@@ -765,7 +772,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
765 | 772 | ||
766 | transparent = FB_SCALARPACK(TRANSPARENT_COLOR); | 773 | transparent = FB_SCALARPACK(TRANSPARENT_COLOR); |
767 | replacewithfg = FB_SCALARPACK(REPLACEWITHFG_COLOR); | 774 | replacewithfg = FB_SCALARPACK(REPLACEWITHFG_COLOR); |
768 | fg = FB_SCALARPACK(lcd_current_viewport->fg_pattern); | 775 | fg = FB_SCALARPACK(vp->fg_pattern); |
769 | #define CMP(c1, c2) (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b) | 776 | #define CMP(c1, c2) (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b) |
770 | 777 | ||
771 | do | 778 | do |