diff options
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r-- | apps/plugins/lib/grey_core.c | 173 |
1 files changed, 92 insertions, 81 deletions
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index a7e8f2a08b..88becb1336 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c | |||
@@ -708,10 +708,10 @@ void grey_deferred_lcd_update(void) | |||
708 | /*** Screenshot ***/ | 708 | /*** Screenshot ***/ |
709 | 709 | ||
710 | #ifdef HAVE_LCD_SPLIT | 710 | #ifdef HAVE_LCD_SPLIT |
711 | #define GRADIENT_MAX 127 | 711 | #define NUM_SHADES 128 |
712 | #define BMP_NUMCOLORS 256 | 712 | #define BMP_NUMCOLORS 256 |
713 | #else | 713 | #else |
714 | #define GRADIENT_MAX 128 | 714 | #define NUM_SHADES 129 |
715 | #define BMP_NUMCOLORS 129 | 715 | #define BMP_NUMCOLORS 129 |
716 | #endif | 716 | #endif |
717 | 717 | ||
@@ -754,7 +754,7 @@ static const unsigned char colorindex[4] = {128, 85, 43, 0}; | |||
754 | static void grey_screendump_hook(int fd) | 754 | static void grey_screendump_hook(int fd) |
755 | { | 755 | { |
756 | int i; | 756 | int i; |
757 | int x, y, gx, gy; | 757 | int y, gx, gy; |
758 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | 758 | #if LCD_PIXELFORMAT == VERTICAL_PACKING |
759 | #if LCD_DEPTH == 1 | 759 | #if LCD_DEPTH == 1 |
760 | unsigned val; | 760 | unsigned val; |
@@ -766,45 +766,50 @@ static void grey_screendump_hook(int fd) | |||
766 | unsigned data; | 766 | unsigned data; |
767 | int shift; | 767 | int shift; |
768 | #endif /* LCD_PIXELFORMAT */ | 768 | #endif /* LCD_PIXELFORMAT */ |
769 | fb_data *lcdptr; | 769 | fb_data *src; |
770 | unsigned char *clut_entry; | 770 | unsigned char *gsrc; |
771 | unsigned char linebuf[MAX(4*BMP_NUMCOLORS,BMP_LINESIZE)]; | 771 | unsigned char *dst, *dst_end; |
772 | unsigned char linebuf[MAX(4*NUM_SHADES,BMP_LINESIZE)]; | ||
772 | 773 | ||
773 | rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ | 774 | rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ |
774 | 775 | ||
775 | /* build clut */ | 776 | /* build clut */ |
776 | rb->memset(linebuf, 0, 4*BMP_NUMCOLORS); | 777 | rb->memset(linebuf, 0, 4*NUM_SHADES); |
777 | clut_entry = linebuf; | 778 | dst = linebuf; |
778 | 779 | ||
779 | for (i = 0; i <= GRADIENT_MAX; i++) | 780 | for (i = 0; i < NUM_SHADES; i++) |
780 | { | 781 | { |
781 | *clut_entry++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR) | 782 | *dst++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR) |
782 | -BLUE_CMP(LCD_BL_DARKCOLOR), i) >> 7) | 783 | -BLUE_CMP(LCD_BL_DARKCOLOR), i) >> 7) |
783 | + BLUE_CMP(LCD_BL_DARKCOLOR); | 784 | + BLUE_CMP(LCD_BL_DARKCOLOR); |
784 | *clut_entry++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR) | 785 | *dst++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR) |
785 | -GREEN_CMP(LCD_BL_DARKCOLOR), i) >> 7) | 786 | -GREEN_CMP(LCD_BL_DARKCOLOR), i) >> 7) |
786 | + GREEN_CMP(LCD_BL_DARKCOLOR); | 787 | + GREEN_CMP(LCD_BL_DARKCOLOR); |
787 | *clut_entry++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR) | 788 | *dst++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR) |
788 | -RED_CMP(LCD_BL_DARKCOLOR), i) >> 7) | 789 | -RED_CMP(LCD_BL_DARKCOLOR), i) >> 7) |
789 | + RED_CMP(LCD_BL_DARKCOLOR); | 790 | + RED_CMP(LCD_BL_DARKCOLOR); |
790 | clut_entry++; | 791 | dst++; |
791 | } | 792 | } |
793 | rb->write(fd, linebuf, 4*NUM_SHADES); | ||
794 | |||
792 | #ifdef HAVE_LCD_SPLIT | 795 | #ifdef HAVE_LCD_SPLIT |
793 | for (i = 0; i <= GRADIENT_MAX; i++) | 796 | dst = linebuf; |
797 | |||
798 | for (i = 0; i <= NUM_SHADES; i++) | ||
794 | { | 799 | { |
795 | *clut_entry++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR_2) | 800 | *dst++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR_2) |
796 | -BLUE_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) | 801 | -BLUE_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) |
797 | + BLUE_CMP(LCD_BL_DARKCOLOR_2); | 802 | + BLUE_CMP(LCD_BL_DARKCOLOR_2); |
798 | *clut_entry++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR_2) | 803 | *dst++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR_2) |
799 | -GREEN_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) | 804 | -GREEN_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) |
800 | + GREEN_CMP(LCD_BL_DARKCOLOR_2); | 805 | + GREEN_CMP(LCD_BL_DARKCOLOR_2); |
801 | *clut_entry++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR_2) | 806 | *dst++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR_2) |
802 | -RED_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) | 807 | -RED_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) |
803 | + RED_CMP(LCD_BL_DARKCOLOR_2); | 808 | + RED_CMP(LCD_BL_DARKCOLOR_2); |
804 | clut_entry++; | 809 | dst++; |
805 | } | 810 | } |
811 | rb->write(fd, linebuf, 4*NUM_SHADES); | ||
806 | #endif | 812 | #endif |
807 | rb->write(fd, linebuf, 4*BMP_NUMCOLORS); | ||
808 | 813 | ||
809 | /* BMP image goes bottom -> top */ | 814 | /* BMP image goes bottom -> top */ |
810 | for (y = LCD_HEIGHT - 1; y >= 0; y--) | 815 | for (y = LCD_HEIGHT - 1; y >= 0; y--) |
@@ -819,116 +824,122 @@ static void grey_screendump_hook(int fd) | |||
819 | } | 824 | } |
820 | #endif | 825 | #endif |
821 | 826 | ||
827 | dst = linebuf; | ||
828 | dst_end = dst + LCD_WIDTH; | ||
822 | gy = y - _grey_info.y; | 829 | gy = y - _grey_info.y; |
830 | gx = -_grey_info.x; | ||
831 | |||
823 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 832 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
824 | #if LCD_DEPTH == 2 | 833 | gsrc = _grey_info.values + _GREY_MULUQ(_grey_info.width, gy); |
825 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y); | ||
826 | 834 | ||
827 | for (x = 0; x < LCD_WIDTH; x += 4) | 835 | #if LCD_DEPTH == 2 |
836 | src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y); | ||
837 | |||
838 | do | ||
828 | { | 839 | { |
829 | gx = x - _grey_info.x; | ||
830 | |||
831 | if (((unsigned)gy < (unsigned)_grey_info.height) | 840 | if (((unsigned)gy < (unsigned)_grey_info.height) |
832 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 841 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
833 | { | 842 | { |
834 | unsigned char *src = _grey_info.values | 843 | *dst++ = *gsrc++; |
835 | + _GREY_MULUQ(_grey_info.width, gy) + gx; | 844 | *dst++ = *gsrc++; |
836 | for (i = 0; i < 4; i++) | 845 | *dst++ = *gsrc++; |
837 | linebuf[x + i] = *src++; | 846 | *dst++ = *gsrc++; |
838 | } | 847 | } |
839 | else | 848 | else |
840 | { | 849 | { |
841 | unsigned data = *lcdptr; | 850 | unsigned data = *src; |
842 | linebuf[x] = colorindex[(data >> 6) & 3]; | 851 | *dst++ = colorindex[(data >> 6) & 3]; |
843 | linebuf[x + 1] = colorindex[(data >> 4) & 3]; | 852 | *dst++ = colorindex[(data >> 4) & 3]; |
844 | linebuf[x + 2] = colorindex[(data >> 2) & 3]; | 853 | *dst++ = colorindex[(data >> 2) & 3]; |
845 | linebuf[x + 3] = colorindex[data & 3]; | 854 | *dst++ = colorindex[data & 3]; |
846 | } | 855 | } |
847 | lcdptr++; | 856 | gx++, src++; |
848 | } | 857 | } |
858 | while (dst < dst_end); | ||
859 | |||
849 | #endif /* LCD_DEPTH */ | 860 | #endif /* LCD_DEPTH */ |
850 | #elif LCD_PIXELFORMAT == VERTICAL_PACKING | 861 | #elif LCD_PIXELFORMAT == VERTICAL_PACKING |
862 | gsrc = _grey_info.values + (~gy & _GREY_BMASK) | ||
863 | + _GREY_MULUQ(_grey_info.width, gy & ~_GREY_BMASK); | ||
864 | |||
851 | #if LCD_DEPTH == 1 | 865 | #if LCD_DEPTH == 1 |
852 | mask = 1 << (y & 7); | 866 | mask = 1 << (y & 7); |
853 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); | 867 | src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); |
854 | 868 | ||
855 | for (x = 0; x < LCD_WIDTH; x++) | 869 | do |
856 | { | 870 | { |
857 | gx = x - _grey_info.x; | ||
858 | |||
859 | if (((unsigned)gy < (unsigned)_grey_info.height) | 871 | if (((unsigned)gy < (unsigned)_grey_info.height) |
860 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 872 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
861 | { | 873 | { |
862 | val = _grey_info.values[_GREY_MULUQ(_grey_info.width, | 874 | val = *gsrc; |
863 | gy & ~_GREY_BMASK) | ||
864 | + (gx << _GREY_BSHIFT) | ||
865 | + (~gy & _GREY_BMASK)]; | ||
866 | #ifdef HAVE_LCD_SPLIT | 875 | #ifdef HAVE_LCD_SPLIT |
867 | val -= val >> 7; | 876 | val -= val >> 7; |
868 | #endif | 877 | #endif |
878 | gsrc += _GREY_BSIZE; | ||
869 | } | 879 | } |
870 | else | 880 | else |
871 | { | 881 | { |
872 | #ifdef HAVE_NEGATIVE_LCD | 882 | #ifdef HAVE_NEGATIVE_LCD |
873 | val = (*lcdptr & mask) ? GRADIENT_MAX : 0; | 883 | val = (*src & mask) ? (NUM_SHADES-1) : 0; |
874 | #else | 884 | #else |
875 | val = (*lcdptr & mask) ? 0 : GRADIENT_MAX; | 885 | val = (*src & mask) ? 0 : (NUM_SHADES-1); |
876 | #endif | 886 | #endif |
877 | } | 887 | } |
878 | #ifdef HAVE_LCD_SPLIT | 888 | #ifdef HAVE_LCD_SPLIT |
879 | if (y < LCD_SPLIT_POS) | 889 | if (y < LCD_SPLIT_POS) |
880 | val |= 0x80; | 890 | val |= 0x80; |
881 | #endif | 891 | #endif |
882 | linebuf[x] = val; | 892 | *dst++ = val; |
883 | lcdptr++; | 893 | gx++, src++; |
884 | } | 894 | } |
895 | while (dst < dst_end); | ||
896 | |||
885 | #elif LCD_DEPTH == 2 | 897 | #elif LCD_DEPTH == 2 |
886 | shift = 2 * (y & 3); | 898 | shift = 2 * (y & 3); |
887 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2); | 899 | src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2); |
888 | 900 | ||
889 | for (x = 0; x < LCD_WIDTH; x++) | 901 | do |
890 | { | 902 | { |
891 | gx = x - _grey_info.x; | ||
892 | |||
893 | if (((unsigned)gy < (unsigned)_grey_info.height) | 903 | if (((unsigned)gy < (unsigned)_grey_info.height) |
894 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 904 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
895 | { | 905 | { |
896 | linebuf[x] = _grey_info.values[_GREY_MULUQ(_grey_info.width, | 906 | *dst++ = *gsrc; |
897 | gy & ~_GREY_BMASK) | 907 | gsrc += _GREY_BSIZE; |
898 | + (gx << _GREY_BSHIFT) | ||
899 | + (~gy & _GREY_BMASK)]; | ||
900 | } | 908 | } |
901 | else | 909 | else |
902 | { | 910 | { |
903 | linebuf[x] = colorindex[(*lcdptr >> shift) & 3]; | 911 | *dst++ = colorindex[(*src >> shift) & 3]; |
904 | } | 912 | } |
905 | lcdptr++; | 913 | gx++, src++; |
906 | } | 914 | } |
915 | while (dst < dst_end); | ||
916 | |||
907 | #endif /* LCD_DEPTH */ | 917 | #endif /* LCD_DEPTH */ |
908 | #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED | 918 | #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED |
919 | gsrc = _grey_info.values + (~gy & _GREY_BMASK) | ||
920 | + _GREY_MULUQ(_grey_info.width, gy & ~_GREY_BMASK); | ||
921 | |||
909 | #if LCD_DEPTH == 2 | 922 | #if LCD_DEPTH == 2 |
910 | shift = y & 7; | 923 | shift = y & 7; |
911 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); | 924 | src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); |
912 | 925 | ||
913 | for (x = 0; x < LCD_WIDTH; x++) | 926 | do |
914 | { | 927 | { |
915 | gx = x - _grey_info.x; | ||
916 | |||
917 | if (((unsigned)gy < (unsigned)_grey_info.height) | 928 | if (((unsigned)gy < (unsigned)_grey_info.height) |
918 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 929 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
919 | { | 930 | { |
920 | linebuf[x] = _grey_info.values[_GREY_MULUQ(_grey_info.width, | 931 | *dst++ = *gsrc; |
921 | gy & ~_GREY_BMASK) | 932 | gsrc += _GREY_BSIZE; |
922 | + (gx << _GREY_BSHIFT) | ||
923 | + (~gy & _GREY_BMASK)]; | ||
924 | } | 933 | } |
925 | else | 934 | else |
926 | { | 935 | { |
927 | data = (*lcdptr >> shift) & 0x0101; | 936 | data = (*src >> shift) & 0x0101; |
928 | linebuf[x] = colorindex[((data >> 7) | data) & 3]; | 937 | *dst++ = colorindex[((data >> 7) | data) & 3]; |
929 | } | 938 | } |
930 | lcdptr++; | 939 | gx++, src++; |
931 | } | 940 | } |
941 | while (dst < dst_end); | ||
942 | |||
932 | #endif /* LCD_DEPTH */ | 943 | #endif /* LCD_DEPTH */ |
933 | #endif /* LCD_PIXELFORMAT */ | 944 | #endif /* LCD_PIXELFORMAT */ |
934 | 945 | ||