diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-02 00:54:31 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-10-12 07:34:15 -0400 |
commit | f737e5025d6cb2d3a283aa336c072701d1adc83f (patch) | |
tree | b9dcb0022876346896af5339d5bd7e9da29462c0 | |
parent | 6acc8a81a73114b614102beaaaf732b92f4e6ddd (diff) | |
download | rockbox-f737e5025d6cb2d3a283aa336c072701d1adc83f.tar.gz rockbox-f737e5025d6cb2d3a283aa336c072701d1adc83f.zip |
lcd: Refactor viewport clipping functions
There's no need to generate separate copies of these functions
for main and remote LCDs; we can just pass the viewport directly.
Change-Id: I20aa04a58d327b479a942708e161068bd6a3357b
-rw-r--r-- | firmware/drivers/lcd-16bit-common.c | 6 | ||||
-rw-r--r-- | firmware/drivers/lcd-16bit-vert.c | 8 | ||||
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 8 | ||||
-rw-r--r-- | firmware/drivers/lcd-1bit-vert.c | 8 | ||||
-rw-r--r-- | firmware/drivers/lcd-24bit.c | 15 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-horz.c | 10 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-vert.c | 10 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-vi.c | 10 | ||||
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 23 |
9 files changed, 47 insertions, 51 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c index a3a6dc6663..27e6c23885 100644 --- a/firmware/drivers/lcd-16bit-common.c +++ b/firmware/drivers/lcd-16bit-common.c | |||
@@ -135,7 +135,7 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
135 | fb_data *dst, *dst_end; | 135 | fb_data *dst, *dst_end; |
136 | int len, step; | 136 | int len, step; |
137 | 137 | ||
138 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, NULL, NULL)) | 138 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, NULL, NULL)) |
139 | return; | 139 | return; |
140 | 140 | ||
141 | /* drawmode and optimisation */ | 141 | /* drawmode and optimisation */ |
@@ -216,7 +216,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
216 | int width, int height) | 216 | int width, int height) |
217 | { | 217 | { |
218 | struct viewport *vp = lcd_current_viewport; | 218 | struct viewport *vp = lcd_current_viewport; |
219 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 219 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
220 | return; | 220 | return; |
221 | 221 | ||
222 | /* move starting point */ | 222 | /* move starting point */ |
@@ -424,7 +424,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
424 | unsigned dmask = 0x00000000; | 424 | unsigned dmask = 0x00000000; |
425 | int drmode = vp->drawmode; | 425 | int drmode = vp->drawmode; |
426 | 426 | ||
427 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 427 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
428 | return; | 428 | return; |
429 | 429 | ||
430 | /* initialize blending */ | 430 | /* initialize blending */ |
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c index 1c0d441af4..d4ad218d14 100644 --- a/firmware/drivers/lcd-16bit-vert.c +++ b/firmware/drivers/lcd-16bit-vert.c | |||
@@ -68,7 +68,7 @@ void lcd_hline(int x1, int x2, int y) | |||
68 | 68 | ||
69 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; | 69 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; |
70 | 70 | ||
71 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) | 71 | if (!clip_viewport_hline(vp, &x1, &x2, &y)) |
72 | return; | 72 | return; |
73 | 73 | ||
74 | dst = FBADDR(x1, y); | 74 | dst = FBADDR(x1, y); |
@@ -92,7 +92,7 @@ void lcd_vline(int x, int y1, int y2) | |||
92 | enum fill_opt fillopt = OPT_NONE; | 92 | enum fill_opt fillopt = OPT_NONE; |
93 | fb_data *dst, *dst_end; | 93 | fb_data *dst, *dst_end; |
94 | 94 | ||
95 | if(!lcd_clip_viewport_vline(&x, &y1, &y2)) | 95 | if(!clip_viewport_vline(vp, &x, &y1, &y2)) |
96 | return; | 96 | return; |
97 | 97 | ||
98 | height = y2 - y1 + 1; | 98 | height = y2 - y1 + 1; |
@@ -153,7 +153,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
153 | fb_data *dst; | 153 | fb_data *dst; |
154 | int stride_dst; | 154 | int stride_dst; |
155 | 155 | ||
156 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 156 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
157 | return; | 157 | return; |
158 | 158 | ||
159 | src += stride * src_x + src_y; /* move starting point */ | 159 | src += stride * src_x + src_y; /* move starting point */ |
@@ -179,7 +179,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
179 | fb_data *dst, *dst_end; | 179 | fb_data *dst, *dst_end; |
180 | int stride_dst; | 180 | int stride_dst; |
181 | 181 | ||
182 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 182 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
183 | return; | 183 | return; |
184 | 184 | ||
185 | src += stride * src_x + src_y; /* move starting point */ | 185 | src += stride * src_x + src_y; /* move starting point */ |
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index f802a1bfbb..fbf6700f28 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c | |||
@@ -68,7 +68,7 @@ void lcd_hline(int x1, int x2, int y) | |||
68 | enum fill_opt fillopt = OPT_NONE; | 68 | enum fill_opt fillopt = OPT_NONE; |
69 | fb_data *dst, *dst_end; | 69 | fb_data *dst, *dst_end; |
70 | 70 | ||
71 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) | 71 | if (!clip_viewport_hline(vp, &x1, &x2, &y)) |
72 | return; | 72 | return; |
73 | 73 | ||
74 | width = x2 - x1 + 1; | 74 | width = x2 - x1 + 1; |
@@ -128,7 +128,7 @@ void lcd_vline(int x, int y1, int y2) | |||
128 | int stride_dst; | 128 | int stride_dst; |
129 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; | 129 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; |
130 | 130 | ||
131 | if (!lcd_clip_viewport_vline(&x, &y1, &y2)) | 131 | if (!clip_viewport_vline(vp, &x, &y1, &y2)) |
132 | return; | 132 | return; |
133 | 133 | ||
134 | dst = FBADDR(x, y1); | 134 | dst = FBADDR(x, y1); |
@@ -152,7 +152,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
152 | fb_data *dst; | 152 | fb_data *dst; |
153 | int stride_dst; | 153 | int stride_dst; |
154 | 154 | ||
155 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 155 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
156 | return; | 156 | return; |
157 | 157 | ||
158 | src += stride * src_y + src_x; /* move starting point */ | 158 | src += stride * src_y + src_x; /* move starting point */ |
@@ -178,7 +178,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
178 | unsigned fg = vp->fg_pattern; | 178 | unsigned fg = vp->fg_pattern; |
179 | int stride_dst = vp->buffer->stride; | 179 | int stride_dst = vp->buffer->stride; |
180 | 180 | ||
181 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 181 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
182 | return; | 182 | return; |
183 | 183 | ||
184 | src += stride * src_y + src_x; /* move starting point */ | 184 | src += stride * src_y + src_x; /* move starting point */ |
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index 548dd96994..66c785a3aa 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c | |||
@@ -243,7 +243,7 @@ void LCDFN(hline)(int x1, int x2, int y) | |||
243 | unsigned mask; | 243 | unsigned mask; |
244 | LCDFN(blockfunc_type) *bfunc; | 244 | LCDFN(blockfunc_type) *bfunc; |
245 | 245 | ||
246 | if (!LCDFN(clip_viewport_hline)(&x1, &x2, &y)) | 246 | if (!clip_viewport_hline(vp, &x1, &x2, &y)) |
247 | return; | 247 | return; |
248 | 248 | ||
249 | width = x2 - x1 + 1; | 249 | width = x2 - x1 + 1; |
@@ -268,7 +268,7 @@ void LCDFN(vline)(int x, int y1, int y2) | |||
268 | unsigned mask, mask_bottom; | 268 | unsigned mask, mask_bottom; |
269 | LCDFN(blockfunc_type) *bfunc; | 269 | LCDFN(blockfunc_type) *bfunc; |
270 | 270 | ||
271 | if (!LCDFN(clip_viewport_vline)(&x, &y1, &y2)) | 271 | if (!clip_viewport_vline(vp, &x, &y1, &y2)) |
272 | return; | 272 | return; |
273 | 273 | ||
274 | bfunc = LCDFN(blockfuncs)[vp->drawmode]; | 274 | bfunc = LCDFN(blockfuncs)[vp->drawmode]; |
@@ -300,7 +300,7 @@ void LCDFN(fillrect)(int x, int y, int width, int height) | |||
300 | LCDFN(blockfunc_type) *bfunc; | 300 | LCDFN(blockfunc_type) *bfunc; |
301 | bool fillopt = false; | 301 | bool fillopt = false; |
302 | 302 | ||
303 | if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, NULL, NULL)) | 303 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, NULL, NULL)) |
304 | return; | 304 | return; |
305 | 305 | ||
306 | if (vp->drawmode & DRMODE_INVERSEVID) | 306 | if (vp->drawmode & DRMODE_INVERSEVID) |
@@ -378,7 +378,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x, | |||
378 | unsigned mask, mask_bottom; | 378 | unsigned mask, mask_bottom; |
379 | LCDFN(blockfunc_type) *bfunc; | 379 | LCDFN(blockfunc_type) *bfunc; |
380 | 380 | ||
381 | if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, &src_x, &src_y)) | 381 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
382 | return; | 382 | return; |
383 | 383 | ||
384 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 384 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
diff --git a/firmware/drivers/lcd-24bit.c b/firmware/drivers/lcd-24bit.c index be0d3e239c..dbb7e543af 100644 --- a/firmware/drivers/lcd-24bit.c +++ b/firmware/drivers/lcd-24bit.c | |||
@@ -175,7 +175,7 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
175 | fb_data bits; | 175 | fb_data bits; |
176 | memset(&bits, 0, sizeof(fb_data)); | 176 | memset(&bits, 0, sizeof(fb_data)); |
177 | 177 | ||
178 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, NULL, NULL)) | 178 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, NULL, NULL)) |
179 | return; | 179 | return; |
180 | 180 | ||
181 | /* drawmode and optimisation */ | 181 | /* drawmode and optimisation */ |
@@ -268,7 +268,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
268 | int drmode = vp->drawmode; | 268 | int drmode = vp->drawmode; |
269 | int row; | 269 | int row; |
270 | 270 | ||
271 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 271 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
272 | return; | 272 | return; |
273 | 273 | ||
274 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 274 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
@@ -450,7 +450,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
450 | unsigned dmask = 0x00000000; | 450 | unsigned dmask = 0x00000000; |
451 | int drmode = vp->drawmode; | 451 | int drmode = vp->drawmode; |
452 | 452 | ||
453 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 453 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
454 | return; | 454 | return; |
455 | 455 | ||
456 | /* the following drawmode combinations are possible: | 456 | /* the following drawmode combinations are possible: |
@@ -698,7 +698,7 @@ void lcd_hline(int x1, int x2, int y) | |||
698 | fb_data *dst, *dst_end; | 698 | fb_data *dst, *dst_end; |
699 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; | 699 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; |
700 | 700 | ||
701 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) | 701 | if (!clip_viewport_hline(vp, &x1, &x2, &y)) |
702 | return; | 702 | return; |
703 | 703 | ||
704 | width = x2 - x1 + 1; | 704 | width = x2 - x1 + 1; |
@@ -719,7 +719,7 @@ void lcd_vline(int x, int y1, int y2) | |||
719 | fb_data *dst, *dst_end; | 719 | fb_data *dst, *dst_end; |
720 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; | 720 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode]; |
721 | 721 | ||
722 | if (!lcd_clip_viewport_vline(&x, &y1, &y2)) | 722 | if (!clip_viewport_vline(vp, &x, &y1, &y2)) |
723 | return; | 723 | return; |
724 | 724 | ||
725 | dst = FBADDR(x, y1); | 725 | dst = FBADDR(x, y1); |
@@ -738,9 +738,10 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
738 | int stride, int x, int y, int width, | 738 | int stride, int x, int y, int width, |
739 | int height) | 739 | int height) |
740 | { | 740 | { |
741 | struct viewport *vp = lcd_current_viewport; | ||
741 | fb_data *dst; | 742 | fb_data *dst; |
742 | 743 | ||
743 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 744 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
744 | return; | 745 | return; |
745 | 746 | ||
746 | src += stride * src_y + src_x; /* move starting point */ | 747 | src += stride * src_y + src_x; /* move starting point */ |
@@ -764,7 +765,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
764 | fb_data *dst; | 765 | fb_data *dst; |
765 | fb_data fg, transparent, replacewithfg; | 766 | fb_data fg, transparent, replacewithfg; |
766 | 767 | ||
767 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 768 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
768 | return; | 769 | return; |
769 | 770 | ||
770 | src += stride * src_y + src_x; /* move starting point */ | 771 | src += stride * src_y + src_x; /* move starting point */ |
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index e5d683be9e..0ec9d2a6aa 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c | |||
@@ -384,7 +384,7 @@ void lcd_hline(int x1, int x2, int y) | |||
384 | unsigned mask, mask_right; | 384 | unsigned mask, mask_right; |
385 | lcd_blockfunc_type *bfunc; | 385 | lcd_blockfunc_type *bfunc; |
386 | 386 | ||
387 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) | 387 | if (!clip_viewport_hline(vp, &x1, &x2, &y)) |
388 | return; | 388 | return; |
389 | 389 | ||
390 | bfunc = lcd_blockfuncs[vp->drawmode]; | 390 | bfunc = lcd_blockfuncs[vp->drawmode]; |
@@ -411,7 +411,7 @@ void lcd_vline(int x, int y1, int y2) | |||
411 | unsigned mask; | 411 | unsigned mask; |
412 | lcd_blockfunc_type *bfunc; | 412 | lcd_blockfunc_type *bfunc; |
413 | 413 | ||
414 | if (!lcd_clip_viewport_vline(&x, &y1, &y2)) | 414 | if (!clip_viewport_vline(vp, &x, &y1, &y2)) |
415 | return; | 415 | return; |
416 | 416 | ||
417 | bfunc = lcd_blockfuncs[vp->drawmode]; | 417 | bfunc = lcd_blockfuncs[vp->drawmode]; |
@@ -438,7 +438,7 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
438 | unsigned mask, mask_right; | 438 | unsigned mask, mask_right; |
439 | lcd_blockfunc_type *bfunc; | 439 | lcd_blockfunc_type *bfunc; |
440 | 440 | ||
441 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, NULL, NULL)) | 441 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, NULL, NULL)) |
442 | return; | 442 | return; |
443 | 443 | ||
444 | bfunc = lcd_blockfuncs[vp->drawmode]; | 444 | bfunc = lcd_blockfuncs[vp->drawmode]; |
@@ -496,7 +496,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
496 | unsigned dst_mask; | 496 | unsigned dst_mask; |
497 | int drmode = vp->drawmode; | 497 | int drmode = vp->drawmode; |
498 | 498 | ||
499 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 499 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
500 | return; | 500 | return; |
501 | 501 | ||
502 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 502 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
@@ -662,7 +662,7 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
662 | int stride_dst; | 662 | int stride_dst; |
663 | unsigned mask, mask_right; | 663 | unsigned mask, mask_right; |
664 | 664 | ||
665 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 665 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
666 | return; | 666 | return; |
667 | 667 | ||
668 | stride = LCD_FBSTRIDE(stride, 0); /* convert to no. of bytes */ | 668 | stride = LCD_FBSTRIDE(stride, 0); /* convert to no. of bytes */ |
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c index 354c8802fc..51897712d1 100644 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c | |||
@@ -386,7 +386,7 @@ void lcd_hline(int x1, int x2, int y) | |||
386 | unsigned mask; | 386 | unsigned mask; |
387 | lcd_blockfunc_type *bfunc; | 387 | lcd_blockfunc_type *bfunc; |
388 | 388 | ||
389 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) | 389 | if (!clip_viewport_hline(vp, &x1, &x2, &y)) |
390 | return; | 390 | return; |
391 | 391 | ||
392 | width = x2 - x1 + 1; | 392 | width = x2 - x1 + 1; |
@@ -411,7 +411,7 @@ void lcd_vline(int x, int y1, int y2) | |||
411 | unsigned mask, mask_bottom; | 411 | unsigned mask, mask_bottom; |
412 | lcd_blockfunc_type *bfunc; | 412 | lcd_blockfunc_type *bfunc; |
413 | 413 | ||
414 | if (!lcd_clip_viewport_vline(&x, &y1, &y2)) | 414 | if (!clip_viewport_vline(vp, &x, &y1, &y2)) |
415 | return; | 415 | return; |
416 | 416 | ||
417 | bfunc = lcd_blockfuncs[vp->drawmode]; | 417 | bfunc = lcd_blockfuncs[vp->drawmode]; |
@@ -443,7 +443,7 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
443 | lcd_blockfunc_type *bfunc; | 443 | lcd_blockfunc_type *bfunc; |
444 | bool fillopt = false; | 444 | bool fillopt = false; |
445 | 445 | ||
446 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, NULL, NULL)) | 446 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, NULL, NULL)) |
447 | return; | 447 | return; |
448 | 448 | ||
449 | if (vp->drawmode & DRMODE_INVERSEVID) | 449 | if (vp->drawmode & DRMODE_INVERSEVID) |
@@ -522,7 +522,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
522 | unsigned mask, mask_bottom; | 522 | unsigned mask, mask_bottom; |
523 | lcd_blockfunc_type *bfunc; | 523 | lcd_blockfunc_type *bfunc; |
524 | 524 | ||
525 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 525 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
526 | return; | 526 | return; |
527 | 527 | ||
528 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 528 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
@@ -672,7 +672,7 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
672 | int stride_dst; | 672 | int stride_dst; |
673 | unsigned mask, mask_bottom; | 673 | unsigned mask, mask_bottom; |
674 | 674 | ||
675 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) | 675 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
676 | return; | 676 | return; |
677 | 677 | ||
678 | src += stride * (src_y >> 2) + src_x; /* move starting point */ | 678 | src += stride * (src_y >> 2) + src_x; /* move starting point */ |
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c index 7de4a57577..c464537185 100644 --- a/firmware/drivers/lcd-2bit-vi.c +++ b/firmware/drivers/lcd-2bit-vi.c | |||
@@ -419,7 +419,7 @@ void LCDFN(hline)(int x1, int x2, int y) | |||
419 | unsigned mask; | 419 | unsigned mask; |
420 | LCDFN(blockfunc_type) *bfunc; | 420 | LCDFN(blockfunc_type) *bfunc; |
421 | 421 | ||
422 | if (!LCDFN(clip_viewport_hline)(&x1, &x2, &y)) | 422 | if (!clip_viewport_hline(vp, &x1, &x2, &y)) |
423 | return; | 423 | return; |
424 | 424 | ||
425 | width = x2 - x1 + 1; | 425 | width = x2 - x1 + 1; |
@@ -444,7 +444,7 @@ void LCDFN(vline)(int x, int y1, int y2) | |||
444 | unsigned mask, mask_bottom; | 444 | unsigned mask, mask_bottom; |
445 | LCDFN(blockfunc_type) *bfunc; | 445 | LCDFN(blockfunc_type) *bfunc; |
446 | 446 | ||
447 | if (!LCDFN(clip_viewport_vline)(&x, &y1, &y2)) | 447 | if (!clip_viewport_vline(vp, &x, &y1, &y2)) |
448 | return; | 448 | return; |
449 | 449 | ||
450 | bfunc = LCDFN(blockfuncs)[vp->drawmode]; | 450 | bfunc = LCDFN(blockfuncs)[vp->drawmode]; |
@@ -478,7 +478,7 @@ void LCDFN(fillrect)(int x, int y, int width, int height) | |||
478 | LCDFN(blockfunc_type) *bfunc; | 478 | LCDFN(blockfunc_type) *bfunc; |
479 | bool fillopt = false; | 479 | bool fillopt = false; |
480 | 480 | ||
481 | if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, NULL, NULL)) | 481 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, NULL, NULL)) |
482 | return; | 482 | return; |
483 | 483 | ||
484 | if (vp->drawmode & DRMODE_INVERSEVID) | 484 | if (vp->drawmode & DRMODE_INVERSEVID) |
@@ -559,7 +559,7 @@ void ICODE_ATTR LCDFN(mono_bitmap_part)(const unsigned char *src, int src_x, | |||
559 | unsigned data, mask, mask_bottom; | 559 | unsigned data, mask, mask_bottom; |
560 | LCDFN(blockfunc_type) *bfunc; | 560 | LCDFN(blockfunc_type) *bfunc; |
561 | 561 | ||
562 | if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, &src_x, &src_y)) | 562 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
563 | return; | 563 | return; |
564 | 564 | ||
565 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 565 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
@@ -680,7 +680,7 @@ void ICODE_ATTR LCDFN(bitmap_part)(const FBFN(data) *src, int src_x, | |||
680 | int stride_dst; | 680 | int stride_dst; |
681 | unsigned mask, mask_bottom; | 681 | unsigned mask, mask_bottom; |
682 | 682 | ||
683 | if (!LCDFN(clip_viewport_rect)(&x, &y, &width, &height, &src_x, &src_y)) | 683 | if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y)) |
684 | return; | 684 | return; |
685 | 685 | ||
686 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 686 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 6a3fd5f825..07ed509229 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c | |||
@@ -58,15 +58,13 @@ extern void viewport_set_buffer(struct viewport *vp, | |||
58 | * In-viewport clipping functions: | 58 | * In-viewport clipping functions: |
59 | * | 59 | * |
60 | * These clip a primitive (pixel, line, rect) given in | 60 | * These clip a primitive (pixel, line, rect) given in |
61 | * viewport-relative coordinates to the current viewport, | 61 | * viewport-relative coordinates to the specified viewport, |
62 | * and translate it to screen coordinates. They return | 62 | * and translate it to screen coordinates. They return |
63 | * false if the resulting primitive would be off-screen. | 63 | * false if the resulting primitive would be off-screen. |
64 | */ | 64 | */ |
65 | 65 | ||
66 | static bool LCDFN(clip_viewport_pixel)(int *x, int *y) | 66 | static inline bool clip_viewport_pixel(struct viewport *vp, int *x, int *y) |
67 | { | 67 | { |
68 | struct viewport *vp = LCDFN(current_viewport); | ||
69 | |||
70 | if (*x < 0 || *x >= vp->width || | 68 | if (*x < 0 || *x >= vp->width || |
71 | *y < 0 || *y >= vp->height) | 69 | *y < 0 || *y >= vp->height) |
72 | return false; | 70 | return false; |
@@ -76,10 +74,9 @@ static bool LCDFN(clip_viewport_pixel)(int *x, int *y) | |||
76 | return true; | 74 | return true; |
77 | } | 75 | } |
78 | 76 | ||
79 | static bool LCDFN(clip_viewport_hline)(int *x1, int *x2, int *y) | 77 | static inline bool clip_viewport_hline(struct viewport *vp, |
78 | int *x1, int *x2, int *y) | ||
80 | { | 79 | { |
81 | struct viewport *vp = LCDFN(current_viewport); | ||
82 | |||
83 | if (*y < 0 || *y > vp->height) | 80 | if (*y < 0 || *y > vp->height) |
84 | return false; | 81 | return false; |
85 | 82 | ||
@@ -105,10 +102,9 @@ static bool LCDFN(clip_viewport_hline)(int *x1, int *x2, int *y) | |||
105 | return true; | 102 | return true; |
106 | } | 103 | } |
107 | 104 | ||
108 | static bool LCDFN(clip_viewport_vline)(int *x, int *y1, int *y2) | 105 | static inline bool clip_viewport_vline(struct viewport *vp, |
106 | int *x, int *y1, int *y2) | ||
109 | { | 107 | { |
110 | struct viewport *vp = LCDFN(current_viewport); | ||
111 | |||
112 | if (*x < 0 || *x > vp->width) | 108 | if (*x < 0 || *x > vp->width) |
113 | return false; | 109 | return false; |
114 | 110 | ||
@@ -134,11 +130,10 @@ static bool LCDFN(clip_viewport_vline)(int *x, int *y1, int *y2) | |||
134 | return true; | 130 | return true; |
135 | } | 131 | } |
136 | 132 | ||
137 | static bool LCDFN(clip_viewport_rect)(int *x, int *y, int *width, int *height, | 133 | static inline bool clip_viewport_rect(struct viewport *vp, |
134 | int *x, int *y, int *width, int *height, | ||
138 | int *src_x, int *src_y) | 135 | int *src_x, int *src_y) |
139 | { | 136 | { |
140 | struct viewport *vp = LCDFN(current_viewport); | ||
141 | |||
142 | if (*x < 0) { | 137 | if (*x < 0) { |
143 | *width += *x; | 138 | *width += *x; |
144 | if (src_x) | 139 | if (src_x) |
@@ -844,7 +839,7 @@ void LCDFN(nine_segment_bmp)(const struct bitmap* bm, int x, int y, | |||
844 | void LCDFN(drawpixel)(int x, int y) | 839 | void LCDFN(drawpixel)(int x, int y) |
845 | { | 840 | { |
846 | struct viewport *vp = LCDFN(current_viewport); | 841 | struct viewport *vp = LCDFN(current_viewport); |
847 | if (LCDFN(clip_viewport_pixel(&x, &y))) | 842 | if (clip_viewport_pixel(vp, &x, &y)) |
848 | { | 843 | { |
849 | #if LCDM(DEPTH) >= 8 | 844 | #if LCDM(DEPTH) >= 8 |
850 | LCDFN(fastpixelfunc_type) *pfunc = LCDFN(fastpixelfuncs)[vp->drawmode]; | 845 | LCDFN(fastpixelfunc_type) *pfunc = LCDFN(fastpixelfuncs)[vp->drawmode]; |