summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2013-04-16 23:50:43 +0200
committerThomas Martitz <kugel@rockbox.org>2014-01-07 14:13:48 +0100
commitdeb6ac3693a6fb5c47abd0c32f966f5e38b6a68a (patch)
tree08cb6563035e9aca18618548c86b10a9d39a5cbe
parent36e469db8bb7789c89ff642b51c1471669b830f5 (diff)
downloadrockbox-deb6ac3693a6fb5c47abd0c32f966f5e38b6a68a.tar.gz
rockbox-deb6ac3693a6fb5c47abd0c32f966f5e38b6a68a.zip
lcd-16bit: Move lcd_gradient_fillrect/_part() to lcd-16bit-common.c.
Change-Id: I6b2d2ba73464610556cfd9ecec52fc62adb007c7
-rw-r--r--firmware/drivers/lcd-16bit-common.c66
-rw-r--r--firmware/drivers/lcd-bitmap-common.c70
2 files changed, 66 insertions, 70 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index 99cbe489fc..9d36499418 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -1362,3 +1362,69 @@ void lcd_blit_yuv(unsigned char * const src[3],
1362 lcd_update_rect(LCD_WIDTH - y - height, x, height, width); 1362 lcd_update_rect(LCD_WIDTH - y - height, x, height, width);
1363#endif 1363#endif
1364} 1364}
1365
1366/* Fill a rectangle with a gradient. This function draws only the partial
1367 * gradient. It assumes the original gradient is src_height high and skips
1368 * the first few rows. This is useful for drawing only the bottom half of
1369 * a full gradient.
1370 *
1371 * height == src_height and row_skip == 0 will draw the full gradient
1372 *
1373 * x, y, width, height - dimensions describing the rectangle
1374 * start_rgb - beginning color of the gradient
1375 * end_rgb - end color of the gradient
1376 * src_height - assumed original height (only height rows will be drawn)
1377 * row_skip - how many rows of the original gradient to skip
1378 */
1379void lcd_gradient_fillrect_part(int x, int y, int width, int height,
1380 unsigned start_rgb, unsigned end_rgb, int src_height, int row_skip)
1381{
1382 int old_pattern = current_vp->fg_pattern;
1383 int step_mul, i;
1384 int x1, x2;
1385 x1 = x;
1386 x2 = x + width;
1387
1388 if (height == 0) return;
1389
1390 step_mul = (1 << 16) / src_height;
1391 int h_r = RGB_UNPACK_RED(start_rgb);
1392 int h_g = RGB_UNPACK_GREEN(start_rgb);
1393 int h_b = RGB_UNPACK_BLUE(start_rgb);
1394 int rstep = (h_r - RGB_UNPACK_RED(end_rgb)) * step_mul;
1395 int gstep = (h_g - RGB_UNPACK_GREEN(end_rgb)) * step_mul;
1396 int bstep = (h_b - RGB_UNPACK_BLUE(end_rgb)) * step_mul;
1397 h_r = (h_r << 16) + (1 << 15);
1398 h_g = (h_g << 16) + (1 << 15);
1399 h_b = (h_b << 16) + (1 << 15);
1400
1401 if (row_skip > 0)
1402 {
1403 h_r -= rstep * row_skip;
1404 h_g -= gstep * row_skip;
1405 h_b -= bstep * row_skip;
1406 }
1407
1408 for(i = y; i < y + height; i++) {
1409 current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
1410 lcd_hline(x1, x2, i);
1411 h_r -= rstep;
1412 h_g -= gstep;
1413 h_b -= bstep;
1414 }
1415
1416 current_vp->fg_pattern = old_pattern;
1417}
1418
1419/* Fill a rectangle with a gradient. The gradient's color will fade from
1420 * start_rgb to end_rgb over the height of the rectangle
1421 *
1422 * x, y, width, height - dimensions describing the rectangle
1423 * start_rgb - beginning color of the gradient
1424 * end_rgb - end color of the gradient
1425 */
1426void lcd_gradient_fillrect(int x, int y, int width, int height,
1427 unsigned start_rgb, unsigned end_rgb)
1428{
1429 lcd_gradient_fillrect_part(x, y, width, height, start_rgb, end_rgb, height, 0);
1430}
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index e37da51a1b..81decadbcb 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -40,76 +40,6 @@
40#define MAIN_LCD 40#define MAIN_LCD
41#endif 41#endif
42 42
43#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
44
45/* Fill a rectangle with a gradient. This function draws only the partial
46 * gradient. It assumes the original gradient is src_height high and skips
47 * the first few rows. This is useful for drawing only the bottom half of
48 * a full gradient.
49 *
50 * height == src_height and row_skip == 0 will draw the full gradient
51 *
52 * x, y, width, height - dimensions describing the rectangle
53 * start_rgb - beginning color of the gradient
54 * end_rgb - end color of the gradient
55 * src_height - assumed original height (only height rows will be drawn)
56 * row_skip - how many rows of the original gradient to skip
57 */
58void lcd_gradient_fillrect_part(int x, int y, int width, int height,
59 unsigned start_rgb, unsigned end_rgb, int src_height, int row_skip)
60{
61 int old_pattern = current_vp->fg_pattern;
62 int step_mul, i;
63 int x1, x2;
64 x1 = x;
65 x2 = x + width;
66
67 if (height == 0) return;
68
69 step_mul = (1 << 16) / src_height;
70 int h_r = RGB_UNPACK_RED(start_rgb);
71 int h_g = RGB_UNPACK_GREEN(start_rgb);
72 int h_b = RGB_UNPACK_BLUE(start_rgb);
73 int rstep = (h_r - RGB_UNPACK_RED(end_rgb)) * step_mul;
74 int gstep = (h_g - RGB_UNPACK_GREEN(end_rgb)) * step_mul;
75 int bstep = (h_b - RGB_UNPACK_BLUE(end_rgb)) * step_mul;
76 h_r = (h_r << 16) + (1 << 15);
77 h_g = (h_g << 16) + (1 << 15);
78 h_b = (h_b << 16) + (1 << 15);
79
80 if (row_skip > 0)
81 {
82 h_r -= rstep * row_skip;
83 h_g -= gstep * row_skip;
84 h_b -= bstep * row_skip;
85 }
86
87 for(i = y; i < y + height; i++) {
88 current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
89 lcd_hline(x1, x2, i);
90 h_r -= rstep;
91 h_g -= gstep;
92 h_b -= bstep;
93 }
94
95 current_vp->fg_pattern = old_pattern;
96}
97
98/* Fill a rectangle with a gradient. The gradient's color will fade from
99 * start_rgb to end_rgb over the height of the rectangle
100 *
101 * x, y, width, height - dimensions describing the rectangle
102 * start_rgb - beginning color of the gradient
103 * end_rgb - end color of the gradient
104 */
105void lcd_gradient_fillrect(int x, int y, int width, int height,
106 unsigned start_rgb, unsigned end_rgb)
107{
108 lcd_gradient_fillrect_part(x, y, width, height, start_rgb, end_rgb, height, 0);
109}
110
111#endif
112
113void LCDFN(set_framebuffer)(FBFN(data) *fb) 43void LCDFN(set_framebuffer)(FBFN(data) *fb)
114{ 44{
115 if (fb) 45 if (fb)