lcd-16bit: Move lcd_gradient_fillrect/_part() to lcd-16bit-common.c.
Change-Id: I6b2d2ba73464610556cfd9ecec52fc62adb007c7
This commit is contained in:
parent
36e469db8b
commit
deb6ac3693
2 changed files with 66 additions and 70 deletions
|
@ -1362,3 +1362,69 @@ void lcd_blit_yuv(unsigned char * const src[3],
|
|||
lcd_update_rect(LCD_WIDTH - y - height, x, height, width);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Fill a rectangle with a gradient. This function draws only the partial
|
||||
* 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 step_mul, i;
|
||||
int x1, x2;
|
||||
x1 = x;
|
||||
x2 = x + width;
|
||||
|
||||
if (height == 0) return;
|
||||
|
||||
step_mul = (1 << 16) / src_height;
|
||||
int h_r = RGB_UNPACK_RED(start_rgb);
|
||||
int h_g = RGB_UNPACK_GREEN(start_rgb);
|
||||
int h_b = RGB_UNPACK_BLUE(start_rgb);
|
||||
int rstep = (h_r - RGB_UNPACK_RED(end_rgb)) * step_mul;
|
||||
int gstep = (h_g - RGB_UNPACK_GREEN(end_rgb)) * step_mul;
|
||||
int bstep = (h_b - RGB_UNPACK_BLUE(end_rgb)) * step_mul;
|
||||
h_r = (h_r << 16) + (1 << 15);
|
||||
h_g = (h_g << 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++) {
|
||||
current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
|
||||
lcd_hline(x1, x2, i);
|
||||
h_r -= rstep;
|
||||
h_g -= gstep;
|
||||
h_b -= bstep;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -40,76 +40,6 @@
|
|||
#define MAIN_LCD
|
||||
#endif
|
||||
|
||||
#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
|
||||
|
||||
/* Fill a rectangle with a gradient. This function draws only the partial
|
||||
* 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 step_mul, i;
|
||||
int x1, x2;
|
||||
x1 = x;
|
||||
x2 = x + width;
|
||||
|
||||
if (height == 0) return;
|
||||
|
||||
step_mul = (1 << 16) / src_height;
|
||||
int h_r = RGB_UNPACK_RED(start_rgb);
|
||||
int h_g = RGB_UNPACK_GREEN(start_rgb);
|
||||
int h_b = RGB_UNPACK_BLUE(start_rgb);
|
||||
int rstep = (h_r - RGB_UNPACK_RED(end_rgb)) * step_mul;
|
||||
int gstep = (h_g - RGB_UNPACK_GREEN(end_rgb)) * step_mul;
|
||||
int bstep = (h_b - RGB_UNPACK_BLUE(end_rgb)) * step_mul;
|
||||
h_r = (h_r << 16) + (1 << 15);
|
||||
h_g = (h_g << 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++) {
|
||||
current_vp->fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
|
||||
lcd_hline(x1, x2, i);
|
||||
h_r -= rstep;
|
||||
h_g -= gstep;
|
||||
h_b -= bstep;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void LCDFN(set_framebuffer)(FBFN(data) *fb)
|
||||
{
|
||||
if (fb)
|
||||
|
|
Loading…
Reference in a new issue