Add MENU_DISPLAY_CTL_SET_FB_DATA

This commit is contained in:
twinaphex 2015-09-25 21:36:11 +02:00
parent eae4d761ba
commit 314dbf44e8
3 changed files with 22 additions and 13 deletions

View File

@ -639,10 +639,10 @@ static void *rgui_init(void)
{ {
size_t fb_pitch; size_t fb_pitch;
unsigned fb_width, fb_height; unsigned fb_width, fb_height;
bool ret = false; uint16_t *fb_data = NULL;
menu_framebuf_t *frame_buf = NULL;
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
rgui_t *rgui = NULL; rgui_t *rgui = NULL;
bool ret = false;
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
if (!menu) if (!menu)
return NULL; return NULL;
@ -652,20 +652,19 @@ static void *rgui_init(void)
if (!rgui) if (!rgui)
goto error; goto error;
frame_buf = menu_display_fb_get_ptr();
/* 4 extra lines to cache the checked background */ /* 4 extra lines to cache the checked background */
frame_buf->data = (uint16_t*)calloc(400 * (240 + 4), sizeof(uint16_t)); fb_data = (uint16_t*)calloc(400 * (240 + 4), sizeof(uint16_t));
if (!frame_buf->data) if (!fb_data)
goto error; goto error;
fb_width = 320; fb_width = 320;
fb_height = 240; fb_height = 240;
fb_pitch = fb_width * sizeof(uint16_t); fb_pitch = fb_width * sizeof(uint16_t);
menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &fb_width); menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &fb_width);
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &fb_height); menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &fb_height);
menu_display_ctl(MENU_DISPLAY_CTL_SET_FB_DATA, fb_data);
menu->display.header_height = FONT_HEIGHT_STRIDE * 2; menu->display.header_height = FONT_HEIGHT_STRIDE * 2;
@ -678,7 +677,7 @@ static void *rgui_init(void)
if (!ret) if (!ret)
goto error; goto error;
fill_rect(frame_buf->data, fb_pitch, 0, fb_height, fill_rect(fb_data, fb_pitch, 0, fb_height,
fb_width, 4, gray_filler); fb_width, 4, gray_filler);
rgui->last_width = fb_width; rgui->last_width = fb_width;
@ -689,9 +688,10 @@ static void *rgui_init(void)
error: error:
if (menu) if (menu)
{ {
if (frame_buf->data) if (fb_data)
free(frame_buf->data); free(fb_data);
frame_buf->data = NULL; fb_data = NULL;
menu_display_ctl(MENU_DISPLAY_CTL_SET_FB_DATA, &fb_data);
if (menu->userdata) if (menu->userdata)
free(menu->userdata); free(menu->userdata);
menu->userdata = NULL; menu->userdata = NULL;

View File

@ -258,6 +258,14 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
*ptr = frame_buf->data; *ptr = frame_buf->data;
} }
return true; return true;
case MENU_DISPLAY_CTL_SET_FB_DATA:
{
uint16_t *ptr = (uint16_t*)data;
if (!ptr)
return false;
frame_buf->data = ptr;
}
return true;
case MENU_DISPLAY_CTL_FB_PITCH: case MENU_DISPLAY_CTL_FB_PITCH:
{ {
size_t *ptr = (size_t*)data; size_t *ptr = (size_t*)data;

View File

@ -43,6 +43,7 @@ enum menu_display_ctl_state
MENU_DISPLAY_CTL_SET_WIDTH, MENU_DISPLAY_CTL_SET_WIDTH,
MENU_DISPLAY_CTL_SET_HEIGHT, MENU_DISPLAY_CTL_SET_HEIGHT,
MENU_DISPLAY_CTL_FB_DATA, MENU_DISPLAY_CTL_FB_DATA,
MENU_DISPLAY_CTL_SET_FB_DATA,
MENU_DISPLAY_CTL_FB_PITCH, MENU_DISPLAY_CTL_FB_PITCH,
MENU_DISPLAY_CTL_SET_FB_PITCH MENU_DISPLAY_CTL_SET_FB_PITCH
}; };