mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
lcd-16bit: Introduce lcd_gradient_fillrect_part().
It is similar to lcd_gradient_fillrect(), except that it only draws a part of the complete gradient. This can be used to draw only the bottom half of a full gradient. Change-Id: Ib47cc5237f6966e35ba07988bddbb00fd97adf96
This commit is contained in:
parent
6630958533
commit
77836e5736
4 changed files with 41 additions and 3 deletions
|
@ -268,6 +268,7 @@ struct screen screens[NB_SCREENS] =
|
||||||
.set_framebuffer = (void*)lcd_set_framebuffer,
|
.set_framebuffer = (void*)lcd_set_framebuffer,
|
||||||
#if defined(HAVE_LCD_COLOR)
|
#if defined(HAVE_LCD_COLOR)
|
||||||
.gradient_fillrect = lcd_gradient_fillrect,
|
.gradient_fillrect = lcd_gradient_fillrect,
|
||||||
|
.gradient_fillrect_part = lcd_gradient_fillrect_part,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
|
|
|
@ -169,6 +169,8 @@ struct screen
|
||||||
#if defined(HAVE_LCD_COLOR)
|
#if defined(HAVE_LCD_COLOR)
|
||||||
void (*gradient_fillrect)(int x, int y, int width, int height,
|
void (*gradient_fillrect)(int x, int y, int width, int height,
|
||||||
unsigned start, unsigned end);
|
unsigned start, unsigned end);
|
||||||
|
void (*gradient_fillrect_part)(int x, int y, int width, int height,
|
||||||
|
unsigned start, unsigned end, int src_height, int row_skip);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_LCD_BITMAP)
|
#if defined(HAVE_LCD_BITMAP)
|
||||||
|
|
|
@ -41,8 +41,21 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
|
#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
|
||||||
void lcd_gradient_fillrect(int x, int y, int width, int height,
|
/* Fill a rectangle with a gradient. This function draws only the partial
|
||||||
unsigned start_rgb, unsigned end_rgb)
|
* gradient. It assumes the original gradient is src_height high and skips
|
||||||
|
* the first few rows. This is useful for drawing only the bottom half of
|
||||||
|
* a full gradient.
|
||||||
|
*
|
||||||
|
* height == src_height and row_skip == 0 will draw the full gradient
|
||||||
|
*
|
||||||
|
* x, y, width, height - dimensions describing the rectangle
|
||||||
|
* start_rgb - beginning color of the gradient
|
||||||
|
* end_rgb - end color of the gradient
|
||||||
|
* src_height - assumed original height (only height rows will be drawn)
|
||||||
|
* row_skip - how many rows of the original gradient to skip
|
||||||
|
*/
|
||||||
|
void lcd_gradient_fillrect_part(int x, int y, int width, int height,
|
||||||
|
unsigned start_rgb, unsigned end_rgb, int src_height, int row_skip)
|
||||||
{
|
{
|
||||||
int old_pattern = current_vp->fg_pattern;
|
int old_pattern = current_vp->fg_pattern;
|
||||||
int step_mul, i;
|
int step_mul, i;
|
||||||
|
@ -52,7 +65,7 @@ void lcd_gradient_fillrect(int x, int y, int width, int height,
|
||||||
|
|
||||||
if (height == 0) return;
|
if (height == 0) return;
|
||||||
|
|
||||||
step_mul = (1 << 16) / height;
|
step_mul = (1 << 16) / src_height;
|
||||||
int h_r = RGB_UNPACK_RED(start_rgb);
|
int h_r = RGB_UNPACK_RED(start_rgb);
|
||||||
int h_g = RGB_UNPACK_GREEN(start_rgb);
|
int h_g = RGB_UNPACK_GREEN(start_rgb);
|
||||||
int h_b = RGB_UNPACK_BLUE(start_rgb);
|
int h_b = RGB_UNPACK_BLUE(start_rgb);
|
||||||
|
@ -63,6 +76,13 @@ void lcd_gradient_fillrect(int x, int y, int width, int height,
|
||||||
h_g = (h_g << 16) + (1 << 15);
|
h_g = (h_g << 16) + (1 << 15);
|
||||||
h_b = (h_b << 16) + (1 << 15);
|
h_b = (h_b << 16) + (1 << 15);
|
||||||
|
|
||||||
|
if (row_skip > 0)
|
||||||
|
{
|
||||||
|
h_r -= rstep * row_skip;
|
||||||
|
h_g -= gstep * row_skip;
|
||||||
|
h_b -= bstep * row_skip;
|
||||||
|
}
|
||||||
|
|
||||||
for(i = y; i < y + height; i++) {
|
for(i = y; i < y + height; i++) {
|
||||||
current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
|
current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
|
||||||
lcd_hline(x1, x2, i);
|
lcd_hline(x1, x2, i);
|
||||||
|
@ -74,6 +94,19 @@ void lcd_gradient_fillrect(int x, int y, int width, int height,
|
||||||
current_vp->fg_pattern = old_pattern;
|
current_vp->fg_pattern = old_pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fill a rectangle with a gradient. The gradient's color will fade from
|
||||||
|
* start_rgb to end_rgb over the height of the rectangle
|
||||||
|
*
|
||||||
|
* x, y, width, height - dimensions describing the rectangle
|
||||||
|
* start_rgb - beginning color of the gradient
|
||||||
|
* end_rgb - end color of the gradient
|
||||||
|
*/
|
||||||
|
void lcd_gradient_fillrect(int x, int y, int width, int height,
|
||||||
|
unsigned start_rgb, unsigned end_rgb)
|
||||||
|
{
|
||||||
|
lcd_gradient_fillrect_part(x, y, width, height, start_rgb, end_rgb, height, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Fill a text line with a gradient:
|
/* Fill a text line with a gradient:
|
||||||
* x1, x2 - x pixel coordinates to start/stop
|
* x1, x2 - x pixel coordinates to start/stop
|
||||||
* y - y pixel to start from
|
* y - y pixel to start from
|
||||||
|
|
|
@ -530,6 +530,8 @@ extern void lcd_drawrect(int x, int y, int width, int height);
|
||||||
extern void lcd_fillrect(int x, int y, int width, int height);
|
extern void lcd_fillrect(int x, int y, int width, int height);
|
||||||
extern void lcd_gradient_fillrect(int x, int y, int width, int height,
|
extern void lcd_gradient_fillrect(int x, int y, int width, int height,
|
||||||
unsigned start_rgb, unsigned end_rgb);
|
unsigned start_rgb, unsigned end_rgb);
|
||||||
|
extern void lcd_gradient_fillrect_part(int x, int y, int width, int height,
|
||||||
|
unsigned start_rgb, unsigned end_rgb, int src_height, int row_skip);
|
||||||
extern void lcd_draw_border_viewport(void);
|
extern void lcd_draw_border_viewport(void);
|
||||||
extern void lcd_fill_viewport(void);
|
extern void lcd_fill_viewport(void);
|
||||||
extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
|
extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue