diff options
Diffstat (limited to 'firmware/drivers/lcd-24bit.c')
-rw-r--r-- | firmware/drivers/lcd-24bit.c | 186 |
1 files changed, 11 insertions, 175 deletions
diff --git a/firmware/drivers/lcd-24bit.c b/firmware/drivers/lcd-24bit.c index 279ed5924a..d95415e957 100644 --- a/firmware/drivers/lcd-24bit.c +++ b/firmware/drivers/lcd-24bit.c | |||
@@ -173,31 +173,9 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
173 | fb_data bits; | 173 | fb_data bits; |
174 | memset(&bits, 0, sizeof(fb_data)); | 174 | memset(&bits, 0, sizeof(fb_data)); |
175 | 175 | ||
176 | /******************** In viewport clipping **********************/ | 176 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, NULL, NULL)) |
177 | /* nothing to draw? */ | ||
178 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | ||
179 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | ||
180 | return; | 177 | return; |
181 | 178 | ||
182 | if (x < 0) | ||
183 | { | ||
184 | width += x; | ||
185 | x = 0; | ||
186 | } | ||
187 | if (y < 0) | ||
188 | { | ||
189 | height += y; | ||
190 | y = 0; | ||
191 | } | ||
192 | if (x + width > lcd_current_viewport->width) | ||
193 | width = lcd_current_viewport->width - x; | ||
194 | if (y + height > lcd_current_viewport->height) | ||
195 | height = lcd_current_viewport->height - y; | ||
196 | |||
197 | /* adjust for viewport */ | ||
198 | x += lcd_current_viewport->x; | ||
199 | y += lcd_current_viewport->y; | ||
200 | |||
201 | /* drawmode and optimisation */ | 179 | /* drawmode and optimisation */ |
202 | if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) | 180 | if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) |
203 | { | 181 | { |
@@ -287,33 +265,9 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
287 | int drmode = lcd_current_viewport->drawmode; | 265 | int drmode = lcd_current_viewport->drawmode; |
288 | int row; | 266 | int row; |
289 | 267 | ||
290 | /******************** Image in viewport clipping **********************/ | 268 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) |
291 | /* nothing to draw? */ | ||
292 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | ||
293 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | ||
294 | return; | 269 | return; |
295 | 270 | ||
296 | if (x < 0) | ||
297 | { | ||
298 | width += x; | ||
299 | src_x -= x; | ||
300 | x = 0; | ||
301 | } | ||
302 | if (y < 0) | ||
303 | { | ||
304 | height += y; | ||
305 | src_y -= y; | ||
306 | y = 0; | ||
307 | } | ||
308 | if (x + width > lcd_current_viewport->width) | ||
309 | width = lcd_current_viewport->width - x; | ||
310 | if (y + height > lcd_current_viewport->height) | ||
311 | height = lcd_current_viewport->height - y; | ||
312 | |||
313 | /* adjust for viewport */ | ||
314 | x += lcd_current_viewport->x; | ||
315 | y += lcd_current_viewport->y; | ||
316 | |||
317 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 271 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
318 | src_y &= 7; | 272 | src_y &= 7; |
319 | src_end = src + width; | 273 | src_end = src + width; |
@@ -491,32 +445,9 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
491 | fb_data *dst, *dst_row; | 445 | fb_data *dst, *dst_row; |
492 | unsigned dmask = 0x00000000; | 446 | unsigned dmask = 0x00000000; |
493 | int drmode = lcd_current_viewport->drawmode; | 447 | int drmode = lcd_current_viewport->drawmode; |
494 | /* nothing to draw? */ | ||
495 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | ||
496 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | ||
497 | return; | ||
498 | 448 | ||
499 | /* clipping */ | 449 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) |
500 | if (x < 0) | 450 | return; |
501 | { | ||
502 | width += x; | ||
503 | src_x -= x; | ||
504 | x = 0; | ||
505 | } | ||
506 | if (y < 0) | ||
507 | { | ||
508 | height += y; | ||
509 | src_y -= y; | ||
510 | y = 0; | ||
511 | } | ||
512 | if (x + width > lcd_current_viewport->width) | ||
513 | width = lcd_current_viewport->width - x; | ||
514 | if (y + height > lcd_current_viewport->height) | ||
515 | height = lcd_current_viewport->height - y; | ||
516 | |||
517 | /* adjust for viewport */ | ||
518 | x += lcd_current_viewport->x; | ||
519 | y += lcd_current_viewport->y; | ||
520 | 451 | ||
521 | /* the following drawmode combinations are possible: | 452 | /* the following drawmode combinations are possible: |
522 | * 1) COMPLEMENT: just negates the framebuffer contents | 453 | * 1) COMPLEMENT: just negates the framebuffer contents |
@@ -758,38 +689,16 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
758 | /* Draw a horizontal line (optimised) */ | 689 | /* Draw a horizontal line (optimised) */ |
759 | void lcd_hline(int x1, int x2, int y) | 690 | void lcd_hline(int x1, int x2, int y) |
760 | { | 691 | { |
761 | int x, width; | 692 | int width; |
762 | fb_data *dst, *dst_end; | 693 | fb_data *dst, *dst_end; |
763 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; | 694 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; |
764 | 695 | ||
765 | /* direction flip */ | 696 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) |
766 | if (x2 < x1) | ||
767 | { | ||
768 | x = x1; | ||
769 | x1 = x2; | ||
770 | x2 = x; | ||
771 | } | ||
772 | |||
773 | /******************** In viewport clipping **********************/ | ||
774 | /* nothing to draw? */ | ||
775 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || | ||
776 | (x1 >= lcd_current_viewport->width) || | ||
777 | (x2 < 0)) | ||
778 | return; | 697 | return; |
779 | 698 | ||
780 | if (x1 < 0) | ||
781 | x1 = 0; | ||
782 | if (x2 >= lcd_current_viewport->width) | ||
783 | x2 = lcd_current_viewport->width-1; | ||
784 | |||
785 | /* Adjust x1 and y to viewport */ | ||
786 | x1 += lcd_current_viewport->x; | ||
787 | x2 += lcd_current_viewport->x; | ||
788 | y += lcd_current_viewport->y; | ||
789 | |||
790 | width = x2 - x1 + 1; | 699 | width = x2 - x1 + 1; |
791 | 700 | ||
792 | dst = FBADDR(x1 , y); | 701 | dst = FBADDR(x1, y); |
793 | dst_end = dst + width; | 702 | dst_end = dst + width; |
794 | do | 703 | do |
795 | { | 704 | { |
@@ -801,36 +710,13 @@ void lcd_hline(int x1, int x2, int y) | |||
801 | /* Draw a vertical line (optimised) */ | 710 | /* Draw a vertical line (optimised) */ |
802 | void lcd_vline(int x, int y1, int y2) | 711 | void lcd_vline(int x, int y1, int y2) |
803 | { | 712 | { |
804 | int y; | ||
805 | fb_data *dst, *dst_end; | 713 | fb_data *dst, *dst_end; |
806 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; | 714 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; |
807 | 715 | ||
808 | /* direction flip */ | 716 | if (!lcd_clip_viewport_vline(&x, &y1, &y2)) |
809 | if (y2 < y1) | ||
810 | { | ||
811 | y = y1; | ||
812 | y1 = y2; | ||
813 | y2 = y; | ||
814 | } | ||
815 | |||
816 | /******************** In viewport clipping **********************/ | ||
817 | /* nothing to draw? */ | ||
818 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || | ||
819 | (y1 >= lcd_current_viewport->height) || | ||
820 | (y2 < 0)) | ||
821 | return; | 717 | return; |
822 | 718 | ||
823 | if (y1 < 0) | 719 | dst = FBADDR(x, y1); |
824 | y1 = 0; | ||
825 | if (y2 >= lcd_current_viewport->height) | ||
826 | y2 = lcd_current_viewport->height-1; | ||
827 | |||
828 | /* adjust for viewport */ | ||
829 | x += lcd_current_viewport->x; | ||
830 | y1 += lcd_current_viewport->y; | ||
831 | y2 += lcd_current_viewport->y; | ||
832 | |||
833 | dst = FBADDR(x , y1); | ||
834 | dst_end = dst + (y2 - y1) * LCD_WIDTH; | 720 | dst_end = dst + (y2 - y1) * LCD_WIDTH; |
835 | 721 | ||
836 | do | 722 | do |
@@ -848,34 +734,9 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
848 | { | 734 | { |
849 | fb_data *dst; | 735 | fb_data *dst; |
850 | 736 | ||
851 | /******************** Image in viewport clipping **********************/ | 737 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) |
852 | /* nothing to draw? */ | ||
853 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | ||
854 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | ||
855 | return; | 738 | return; |
856 | 739 | ||
857 | if (x < 0) | ||
858 | { | ||
859 | width += x; | ||
860 | src_x -= x; | ||
861 | x = 0; | ||
862 | } | ||
863 | if (y < 0) | ||
864 | { | ||
865 | height += y; | ||
866 | src_y -= y; | ||
867 | y = 0; | ||
868 | } | ||
869 | |||
870 | if (x + width > lcd_current_viewport->width) | ||
871 | width = lcd_current_viewport->width - x; | ||
872 | if (y + height > lcd_current_viewport->height) | ||
873 | height = lcd_current_viewport->height - y; | ||
874 | |||
875 | /* adjust for viewport */ | ||
876 | x += lcd_current_viewport->x; | ||
877 | y += lcd_current_viewport->y; | ||
878 | |||
879 | src += stride * src_y + src_x; /* move starting point */ | 740 | src += stride * src_y + src_x; /* move starting point */ |
880 | dst = FBADDR(x, y); | 741 | dst = FBADDR(x, y); |
881 | 742 | ||
@@ -896,34 +757,9 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
896 | fb_data *dst; | 757 | fb_data *dst; |
897 | fb_data fg, transparent, replacewithfg; | 758 | fb_data fg, transparent, replacewithfg; |
898 | 759 | ||
899 | /******************** Image in viewport clipping **********************/ | 760 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) |
900 | /* nothing to draw? */ | ||
901 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | ||
902 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | ||
903 | return; | 761 | return; |
904 | 762 | ||
905 | if (x < 0) | ||
906 | { | ||
907 | width += x; | ||
908 | src_x -= x; | ||
909 | x = 0; | ||
910 | } | ||
911 | if (y < 0) | ||
912 | { | ||
913 | height += y; | ||
914 | src_y -= y; | ||
915 | y = 0; | ||
916 | } | ||
917 | |||
918 | if (x + width > lcd_current_viewport->width) | ||
919 | width = lcd_current_viewport->width - x; | ||
920 | if (y + height > lcd_current_viewport->height) | ||
921 | height = lcd_current_viewport->height - y; | ||
922 | |||
923 | /* adjust for viewport */ | ||
924 | x += lcd_current_viewport->x; | ||
925 | y += lcd_current_viewport->y; | ||
926 | |||
927 | src += stride * src_y + src_x; /* move starting point */ | 763 | src += stride * src_y + src_x; /* move starting point */ |
928 | dst = FBADDR(x, y); | 764 | dst = FBADDR(x, y); |
929 | 765 | ||