summaryrefslogtreecommitdiff
path: root/apps/plugins/pictureflow/pictureflow.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-06-18 07:15:00 +0200
committerThomas Martitz <kugel@rockbox.org>2014-06-21 00:15:53 +0200
commita1842c04f9cb73210d4cacde61a9e4b115050765 (patch)
treea37af61ef9285b763a42cd33797e2f3d634fbf9f /apps/plugins/pictureflow/pictureflow.c
parent0250be1d6799db7b5ddc99cb33f31bf9cff01ed2 (diff)
downloadrockbox-a1842c04f9cb73210d4cacde61a9e4b115050765.tar.gz
rockbox-a1842c04f9cb73210d4cacde61a9e4b115050765.zip
lcd-24bit: Introduce a 24-bit mid-level LCD driver
With LCD driver all calculation will be performed on RGB888 and the hardware/OS can display from our 24bit framebuffer. It is not yet as performance optimized as the existing drivers but should be good enough.The vast number of small changes is due to the fact that fb_data can be a struct type now, while most of the code expected a scalar type. lcd-as-memframe ASM code does not work with 24bit currently so the with 24bit it enforces the generic C code. All plugins are ported over. Except for rockpaint. It uses so much memory that it wouldnt fit into the 512k plugin buffer anymore (patches welcome). Change-Id: Ibb1964545028ce0d8ff9833ccc3ab66be3ee0754
Diffstat (limited to 'apps/plugins/pictureflow/pictureflow.c')
-rw-r--r--apps/plugins/pictureflow/pictureflow.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 796b66a48d..1003b0c65c 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -470,7 +470,6 @@ static int pf_state;
470 470
471/** code */ 471/** code */
472static bool free_slide_prio(int prio); 472static bool free_slide_prio(int prio);
473static inline unsigned fade_color(pix_t c, unsigned a);
474bool load_new_slide(void); 473bool load_new_slide(void);
475int load_surface(int); 474int load_surface(int);
476 475
@@ -646,10 +645,15 @@ static inline PFreal fcos(int iangle)
646 return fsin(iangle + (IANGLE_MAX >> 2)); 645 return fsin(iangle + (IANGLE_MAX >> 2));
647} 646}
648 647
649static inline unsigned scale_val(unsigned val, unsigned bits) 648/* scales the 8bit subpixel value to native lcd format, indicated by bits */
649static inline unsigned scale_subpixel_lcd(unsigned val, unsigned bits)
650{ 650{
651 (void) bits;
652#if LCD_PIXELFORMAT != RGB888
651 val = val * ((1 << bits) - 1); 653 val = val * ((1 << bits) - 1);
652 return ((val >> 8) + val + 128) >> 8; 654 val = ((val >> 8) + val + 128) >> 8;
655#endif
656 return val;
653} 657}
654 658
655static void output_row_8_transposed(uint32_t row, void * row_in, 659static void output_row_8_transposed(uint32_t row, void * row_in,
@@ -666,10 +670,10 @@ static void output_row_8_transposed(uint32_t row, void * row_in,
666 unsigned r, g, b; 670 unsigned r, g, b;
667 for (; dest < end; dest += ctx->bm->height) 671 for (; dest < end; dest += ctx->bm->height)
668 { 672 {
669 r = scale_val(qp->red, 5); 673 r = scale_subpixel_lcd(qp->red, 5);
670 g = scale_val(qp->green, 6); 674 g = scale_subpixel_lcd(qp->green, 6);
671 b = scale_val((qp++)->blue, 5); 675 b = scale_subpixel_lcd((qp++)->blue, 5);
672 *dest = LCD_RGBPACK_LCD(r,g,b); 676 *dest = FB_RGBPACK_LCD(r,g,b);
673 } 677 }
674#endif 678#endif
675} 679}
@@ -690,11 +694,11 @@ static void output_row_32_transposed(uint32_t row, void * row_in,
690 int r, g, b; 694 int r, g, b;
691 for (; dest < end; dest += ctx->bm->height) 695 for (; dest < end; dest += ctx->bm->height)
692 { 696 {
693 r = scale_val(SC_OUT(qp->r, ctx), 5); 697 r = scale_subpixel_lcd(SC_OUT(qp->r, ctx), 5);
694 g = scale_val(SC_OUT(qp->g, ctx), 6); 698 g = scale_subpixel_lcd(SC_OUT(qp->g, ctx), 6);
695 b = scale_val(SC_OUT(qp->b, ctx), 5); 699 b = scale_subpixel_lcd(SC_OUT(qp->b, ctx), 5);
696 qp++; 700 qp++;
697 *dest = LCD_RGBPACK_LCD(r,g,b); 701 *dest = FB_RGBPACK_LCD(r,g,b);
698 } 702 }
699#endif 703#endif
700} 704}
@@ -714,10 +718,10 @@ static void output_row_32_transposed_fromyuv(uint32_t row, void * row_in,
714 v = SC_OUT(qp->r, ctx); 718 v = SC_OUT(qp->r, ctx);
715 qp++; 719 qp++;
716 yuv_to_rgb(y, u, v, &r, &g, &b); 720 yuv_to_rgb(y, u, v, &r, &g, &b);
717 r = scale_val(r, 5); 721 r = scale_subpixel_lcd(r, 5);
718 g = scale_val(g, 6); 722 g = scale_subpixel_lcd(g, 6);
719 b = scale_val(b, 5); 723 b = scale_subpixel_lcd(b, 5);
720 *dest = LCD_RGBPACK_LCD(r, g, b); 724 *dest = FB_RGBPACK_LCD(r, g, b);
721 } 725 }
722} 726}
723#endif 727#endif
@@ -1793,14 +1797,13 @@ static void recalc_offsets(void)
1793 offsetY = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE / 2); 1797 offsetY = DISPLAY_WIDTH / 2 * (fsin(itilt) + PFREAL_ONE / 2);
1794} 1798}
1795 1799
1796
1797/** 1800/**
1798 Fade the given color by spreading the fb_data (ushort) 1801 Fade the given color by spreading the fb_data
1799 to an uint, multiply and compress the result back to a ushort. 1802 to an uint, multiply and compress the result back to a fb_data.
1800 */ 1803 */
1801#if (LCD_PIXELFORMAT == RGB565SWAPPED) 1804static inline pix_t fade_color(pix_t c, unsigned a)
1802static inline unsigned fade_color(pix_t c, unsigned a)
1803{ 1805{
1806#if (LCD_PIXELFORMAT == RGB565SWAPPED)
1804 unsigned int result; 1807 unsigned int result;
1805 c = swap16(c); 1808 c = swap16(c);
1806 a = (a + 2) & 0x1fc; 1809 a = (a + 2) & 0x1fc;
@@ -1808,24 +1811,29 @@ static inline unsigned fade_color(pix_t c, unsigned a)
1808 result |= ((c & 0x7e0) * a) & 0x7e000; 1811 result |= ((c & 0x7e0) * a) & 0x7e000;
1809 result >>= 8; 1812 result >>= 8;
1810 return swap16(result); 1813 return swap16(result);
1811} 1814
1812#elif LCD_PIXELFORMAT == RGB565 1815#elif LCD_PIXELFORMAT == RGB565
1813static inline unsigned fade_color(pix_t c, unsigned a)
1814{
1815 unsigned int result; 1816 unsigned int result;
1816 a = (a + 2) & 0x1fc; 1817 a = (a + 2) & 0x1fc;
1817 result = ((c & 0xf81f) * a) & 0xf81f00; 1818 result = ((c & 0xf81f) * a) & 0xf81f00;
1818 result |= ((c & 0x7e0) * a) & 0x7e000; 1819 result |= ((c & 0x7e0) * a) & 0x7e000;
1819 result >>= 8; 1820 result >>= 8;
1820 return result; 1821 return result;
1821} 1822
1823#elif LCD_PIXELFORMAT == RGB888
1824 unsigned int pixel = FB_UNPACK_SCALAR_LCD(c);
1825 unsigned int result;
1826 a = (a + 2) & 0x1fc;
1827 result = ((pixel & 0xff00ff) * a) & 0xff00ff00;
1828 result |= ((pixel & 0x00ff00) * a) & 0x00ff0000;
1829 result >>= 8;
1830 return FB_SCALARPACK(result);
1831
1822#else 1832#else
1823static inline unsigned fade_color(pix_t c, unsigned a)
1824{
1825 unsigned val = c; 1833 unsigned val = c;
1826 return MULUQ(val, a) >> 8; 1834 return MULUQ(val, a) >> 8;
1827}
1828#endif 1835#endif
1836}
1829 1837
1830/** 1838/**
1831 * Render a single slide 1839 * Render a single slide