From 1d7bddaef3f42479ef6245d43e65b0830819a1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Sun, 8 Mar 2015 09:18:32 -0300 Subject: [PATCH] (rgui) Cache and tile checked background --- menu/drivers/rgui.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index ad18f2f643..8c9a8bef54 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -223,7 +223,17 @@ static void rgui_render_background(void) if (!menu) return; - fill_rect(&menu->frame_buf, 0, 0, menu->frame_buf.width, menu->frame_buf.height, gray_filler); + size_t pitch_in_pixels = menu->frame_buf.pitch >> 1; + size_t size = menu->frame_buf.pitch * 4; + uint16_t *src = menu->frame_buf.data + pitch_in_pixels * menu->frame_buf.height; + uint16_t *dst = menu->frame_buf.data; + + while (dst < src) + { + memcpy(dst, src, size); + dst += pitch_in_pixels * 4; + } + fill_rect(&menu->frame_buf, 5, 5, menu->frame_buf.width - 10, 5, green_filler); fill_rect(&menu->frame_buf, 5, menu->frame_buf.height - 10, menu->frame_buf.width - 10, 5, green_filler); @@ -475,7 +485,8 @@ static void *rgui_init(void) if (!menu) return NULL; - menu->frame_buf.data = (uint16_t*)calloc(400 * 240, sizeof(uint16_t)); + /* 4 extra lines to cache the checked background */ + menu->frame_buf.data = (uint16_t*)calloc(400 * (240 + 4), sizeof(uint16_t)); if (!menu->frame_buf.data) goto error; @@ -493,6 +504,8 @@ static void *rgui_init(void) goto error; } + fill_rect(&menu->frame_buf, 0, menu->frame_buf.height, menu->frame_buf.width, 4, gray_filler); + return menu; error: