diff options
author | Yu-Ping Wu <yupingso@chromium.org> | 2021-08-23 16:27:18 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2021-08-27 02:53:38 +0000 |
commit | 52889c9c9f6d634f580c003b77889301916ef5e5 (patch) | |
tree | 84ae4d20b16a01a558c63c485fe883555b21c584 /payloads | |
parent | b69d1dea47552fa0939c884523570b9ce6e42017 (diff) |
libpayload: cbgfx: Clear screen by sequential access
Currently clear_screen() calls set_pixel() to set all pixels. However,
the actual order of pixels being set depends on the framebuffer
orientation. With NORMAL orientation, the framebuffer is accessed
sequentially; with LEFT_UP/RIGHT_UP orientation, it is accessed back and
forth, leading to performance drop (>1 second on bugzzy).
Therefore, ensure sequential access to the framebuffer, regardless of
the orientation.
BUG=b:194967458
TEST=emerge-cherry libpayload
BRANCH=dedede
Change-Id: Iecaff5b6abc24ba4b3859cbc44c0d61b2a90b2d9
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57104
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'payloads')
-rw-r--r-- | payloads/libpayload/drivers/video/graphics.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/payloads/libpayload/drivers/video/graphics.c b/payloads/libpayload/drivers/video/graphics.c index 563f2961c7..53de3024f9 100644 --- a/payloads/libpayload/drivers/video/graphics.c +++ b/payloads/libpayload/drivers/video/graphics.c @@ -274,12 +274,19 @@ static inline uint32_t calculate_color(const struct rgb_color *rgb, * Plot a pixel in a framebuffer. This is called from tight loops. Keep it slim * and do the validation at callers' site. */ -static inline void set_pixel(struct vector *coord, uint32_t color) +static inline void set_pixel_raw(struct vector *rcoord, uint32_t color) { const int bpp = fbinfo->bits_per_pixel; const int bpl = fbinfo->bytes_per_line; - struct vector rcoord; int i; + uint8_t * const pixel = FB + rcoord->y * bpl + rcoord->x * bpp / 8; + for (i = 0; i < bpp / 8; i++) + pixel[i] = (color >> (i * 8)); +} + +static inline void set_pixel(struct vector *coord, uint32_t color) +{ + struct vector rcoord; switch (fbinfo->orientation) { case CB_FB_ORIENTATION_NORMAL: @@ -301,9 +308,7 @@ static inline void set_pixel(struct vector *coord, uint32_t color) break; } - uint8_t * const pixel = FB + rcoord.y * bpl + rcoord.x * bpp / 8; - for (i = 0; i < bpp / 8; i++) - pixel[i] = (color >> (i * 8)); + set_pixel_raw(&rcoord, color); } /* @@ -631,9 +636,9 @@ int clear_screen(const struct rgb_color *rgb) (((color >> 16) & 0xff) == (color & 0xff)))) { memset(FB, color & 0xff, fbinfo->y_resolution * bpl); } else { - for (p.y = 0; p.y < screen.size.height; p.y++) - for (p.x = 0; p.x < screen.size.width; p.x++) - set_pixel(&p, color); + for (p.y = 0; p.y < fbinfo->y_resolution; p.y++) + for (p.x = 0; p.x < fbinfo->x_resolution; p.x++) + set_pixel_raw(&p, color); } return CBGFX_SUCCESS; |