Shelley Chen has uploaded a new change for review. ( https://review.coreboot.org/19698 )
Change subject: detachables: Add invert parameter ......................................................................
detachables: Add invert parameter
Instead of storing inverted-colored bitmaps, invert drawing of text bitmap on the fly by adding an invert parameter down to libpayload.
BUG=BUG=b:35585623 BRANCH=None TEST=Make sure compiles successfully
Change-Id: Ide6893a26f19eb2490377d4d53366ad145a9e6e3 Signed-off-by: Shelley Chen shchen@chromium.org --- M payloads/libpayload/drivers/video/graphics.c M payloads/libpayload/include/cbgfx.h 2 files changed, 12 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/98/19698/1
diff --git a/payloads/libpayload/drivers/video/graphics.c b/payloads/libpayload/drivers/video/graphics.c index d4eaa09..3be4f19 100644 --- a/payloads/libpayload/drivers/video/graphics.c +++ b/payloads/libpayload/drivers/video/graphics.c @@ -106,7 +106,7 @@ return -1; }
-static inline uint32_t calculate_color(const struct rgb_color *rgb) +static inline uint32_t calculate_color(const struct rgb_color *rgb, int invert) { uint32_t color = 0; color |= (rgb->red >> (8 - fbinfo->red_mask_size)) @@ -115,6 +115,8 @@ << fbinfo->green_mask_pos; color |= (rgb->blue >> (8 - fbinfo->blue_mask_size)) << fbinfo->blue_mask_pos; + if (invert) + color = ~color & 0x00ffffff; return color; }
@@ -180,7 +182,7 @@ struct vector top_left; struct vector size; struct vector p, t; - const uint32_t color = calculate_color(rgb); + const uint32_t color = calculate_color(rgb, 0); const struct scale top_left_s = { .x = { .n = box->offset.x, .d = CANVAS_SCALE, }, .y = { .n = box->offset.y, .d = CANVAS_SCALE, } @@ -230,7 +232,7 @@ return CBGFX_ERROR_INIT;
struct vector p; - uint32_t color = calculate_color(rgb); + uint32_t color = calculate_color(rgb, 0); const int bpp = fbinfo->bits_per_pixel; const int bpl = fbinfo->bytes_per_line;
@@ -269,7 +271,8 @@ const struct vector *dim_org, const struct bitmap_header_v3 *header, const struct bitmap_palette_element_v3 *pal, - const uint8_t *pixel_array) + const uint8_t *pixel_array, + uint32_t invert) { const int bpp = header->bits_per_pixel; int32_t dir; @@ -361,7 +364,7 @@ pal[c01].blue, pal[c11].blue, &tx, &ty), }; - set_pixel(&p, calculate_color(&rgb)); + set_pixel(&p, calculate_color(&rgb, invert)); } }
@@ -553,7 +556,7 @@
int draw_bitmap(const void *bitmap, size_t size, const struct scale *pos_rel, uint8_t pivot, - const struct scale *dim_rel) + const struct scale *dim_rel, uint32_t invert) { struct bitmap_header_v3 header; const struct bitmap_palette_element_v3 *palette; @@ -594,7 +597,7 @@ }
return draw_bitmap_v3(&top_left, &scale, &dim, &dim_org, - &header, palette, pixel_array); + &header, palette, pixel_array, invert); }
int draw_bitmap_direct(const void *bitmap, size_t size, @@ -629,7 +632,7 @@ }
return draw_bitmap_v3(top_left, &scale, &dim, &dim, - &header, palette, pixel_array); + &header, palette, pixel_array, 0); }
int get_bitmap_dimension(const void *bitmap, size_t sz, struct scale *dim_rel) diff --git a/payloads/libpayload/include/cbgfx.h b/payloads/libpayload/include/cbgfx.h index dca1be0..399fe75 100644 --- a/payloads/libpayload/include/cbgfx.h +++ b/payloads/libpayload/include/cbgfx.h @@ -144,7 +144,7 @@ */ int draw_bitmap(const void *bitmap, size_t size, const struct scale *pos_rel, uint8_t pivot, - const struct scale *dim_rel); + const struct scale *dim_rel, uint32_t invert);
/* Pivot flags. See the draw_bitmap description. */ #define PIVOT_H_LEFT (1 << 0)