From 263b9e8bcc0ed2eab80c164d0e46cb7ca7ec75f6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 13 Jun 2015 16:42:11 +0200 Subject: [PATCH] Go through menu_display_fb_get_ptr pointer --- menu/drivers/rgui.c | 72 ++++++++++++++++++++++++++------------------- menu/menu_display.c | 35 +++++++++++++--------- menu/menu_display.h | 4 +-- menu/menu_driver.h | 7 +---- 4 files changed, 66 insertions(+), 52 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 49680e5452..e0e95dd693 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -33,10 +33,10 @@ #include "shared.h" -#define RGUI_TERM_START_X (menu->frame_buf.width / 21) -#define RGUI_TERM_START_Y (menu->frame_buf.height / 9) -#define RGUI_TERM_WIDTH (((menu->frame_buf.width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) -#define RGUI_TERM_HEIGHT (((menu->frame_buf.height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) +#define RGUI_TERM_START_X (frame_buf->width / 21) +#define RGUI_TERM_START_Y (frame_buf->height / 9) +#define RGUI_TERM_WIDTH (((frame_buf->width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) +#define RGUI_TERM_HEIGHT (((frame_buf->height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) #if defined(GEKKO)|| defined(PSP) #define HOVER_COLOR(settings) ((3 << 0) | (10 << 4) | (3 << 8) | (7 << 12)) @@ -132,20 +132,22 @@ static void color_rect(menu_handle_t *menu, uint16_t color) { unsigned i, j; + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); - if (!menu->frame_buf.data) + if (!frame_buf || !frame_buf->data) return; for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) - if (i < menu->frame_buf.width && j < menu->frame_buf.height) - menu->frame_buf.data[j * (menu->frame_buf.pitch >> 1) + i] = color; + if (i < frame_buf->width && j < frame_buf->height) + frame_buf->data[j * (frame_buf->pitch >> 1) + i] = color; } static void blit_line(menu_handle_t *menu, int x, int y, const char *message, uint16_t color) { unsigned i, j; + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); while (*message) { @@ -161,8 +163,8 @@ static void blit_line(menu_handle_t *menu, int x, int y, if (!col) continue; - menu->frame_buf.data[(y + j) * - (menu->frame_buf.pitch >> 1) + (x + i)] = color; + frame_buf->data[(y + j) * + (frame_buf->pitch >> 1) + (x + i)] = color; } } @@ -217,16 +219,17 @@ static bool rguidisp_init_font(menu_handle_t *menu) static void rgui_render_background(void) { size_t pitch_in_pixels, size; - uint16_t *src = NULL; - uint16_t *dst = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); + uint16_t *src = NULL; + uint16_t *dst = NULL; + menu_handle_t *menu = menu_driver_get_ptr(); + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); if (!menu) return; - pitch_in_pixels = menu->frame_buf.pitch >> 1; - size = menu->frame_buf.pitch * 4; - src = menu->frame_buf.data + pitch_in_pixels * menu->frame_buf.height; - dst = menu->frame_buf.data; + pitch_in_pixels = frame_buf->pitch >> 1; + size = frame_buf->pitch * 4; + src = frame_buf->data + pitch_in_pixels * frame_buf->height; + dst = frame_buf->data; while (dst < src) { @@ -234,14 +237,14 @@ static void rgui_render_background(void) 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, + fill_rect(frame_buf, 5, 5, frame_buf->width - 10, 5, green_filler); + fill_rect(frame_buf, 5, frame_buf->height - 10, + frame_buf->width - 10, 5, green_filler); - fill_rect(&menu->frame_buf, 5, 5, 5, menu->frame_buf.height - 10, green_filler); - fill_rect(&menu->frame_buf, menu->frame_buf.width - 10, 5, 5, - menu->frame_buf.height - 10, + fill_rect(frame_buf, 5, 5, 5, frame_buf->height - 10, green_filler); + fill_rect(frame_buf, frame_buf->width - 10, 5, 5, + frame_buf->height - 10, green_filler); } @@ -251,9 +254,10 @@ static void rgui_render_messagebox(const char *message) int x, y; unsigned width, glyphs_width, height; uint16_t color; - struct string_list *list = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); - settings_t *settings = config_get_ptr(); + struct string_list *list = NULL; + menu_handle_t *menu = menu_driver_get_ptr(); + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); + settings_t *settings = config_get_ptr(); if (!menu) return; @@ -339,6 +343,7 @@ static void rgui_render(void) char title_msg[64] = {0}; char timedate[PATH_MAX_LENGTH] = {0}; menu_handle_t *menu = menu_driver_get_ptr(); + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); menu_navigation_t *nav = menu_navigation_get_ptr(); runloop_t *runloop = rarch_main_get_ptr(); driver_t *driver = driver_get_ptr(); @@ -571,6 +576,7 @@ static void rgui_free(void *data) static void rgui_set_texture(void) { menu_handle_t *menu = menu_driver_get_ptr(); + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); if (!menu) return; @@ -578,8 +584,11 @@ static void rgui_set_texture(void) menu_display_fb_unset_dirty(); video_driver_set_texture_frame( - menu->frame_buf.data, false, - menu->frame_buf.width, menu->frame_buf.height, 1.0f); + frame_buf->data, + false, + frame_buf->width, + frame_buf->height, + 1.0f); } static void rgui_navigation_clear(bool pending_push) @@ -594,11 +603,14 @@ static void rgui_navigation_clear(bool pending_push) static void rgui_navigation_set(bool scroll) { - menu_handle_t *menu = menu_driver_get_ptr(); - menu_navigation_t *nav = menu_navigation_get_ptr(); + size_t end; + menu_handle_t *menu = menu_driver_get_ptr(); + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); + menu_navigation_t *nav = menu_navigation_get_ptr(); if (!menu) return; - size_t end = menu_entries_get_end(); + + end = menu_entries_get_end(); if (!scroll) return; diff --git a/menu/menu_display.c b/menu/menu_display.c index b84254a32d..b73b10b787 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -24,32 +24,35 @@ #include "../gfx/video_context_driver.h" #include "menu_list.h" -bool menu_display_fb_in_use(void) +menu_framebuf_t *menu_display_fb_get_ptr(void) { menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) + return NULL; + return &menu->frame_buf; +} + +static bool menu_display_fb_in_use(menu_framebuf_t *frame_buf) +{ + if (!frame_buf) return false; - return menu->frame_buf.data != NULL; + return (frame_buf->data != NULL); } void menu_display_fb_set_dirty(void) { - menu_handle_t *menu = menu_driver_get_ptr(); - if (!menu) + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); + if (!menu_display_fb_in_use(frame_buf)) return; - if (!menu_display_fb_in_use()) - return; - menu->framebuf.dirty = true; + frame_buf->dirty = true; } void menu_display_fb_unset_dirty(void) { - menu_handle_t *menu = menu_driver_get_ptr(); - if (!menu) + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); + if (!menu_display_fb_in_use(frame_buf)) return; - if (!menu_display_fb_in_use()) - return; - menu->framebuf.dirty = false; + frame_buf->dirty = false; } /** @@ -82,10 +85,14 @@ void menu_display_fb(void) bool menu_display_update_pending(void) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_get_ptr(); + menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); + if (menu) { - if (menu->animation_is_active || menu->label.is_updated || menu->framebuf.dirty) + if (menu->animation_is_active || menu->label.is_updated) + return true; + if (frame_buf && frame_buf->dirty) return true; } return false; diff --git a/menu/menu_display.h b/menu/menu_display.h index 0bef1d3dfd..fc6034ee4c 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -25,9 +25,9 @@ extern "C" { #endif -void menu_display_fb(void); +menu_framebuf_t *menu_display_fb_get_ptr(void); -bool menu_display_fb_in_use(void); +void menu_display_fb(void); void menu_display_fb_set_dirty(void); diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 57f85bef27..994341a5e8 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -89,6 +89,7 @@ typedef struct menu_framebuf unsigned width; unsigned height; size_t pitch; + bool dirty; } menu_framebuf_t; typedef struct @@ -140,7 +141,6 @@ typedef struct menu_framebuf_t frame_buf; - struct { void *buf; @@ -210,11 +210,6 @@ typedef struct bool is_updated; } label; - struct - { - bool dirty; - } framebuf; - struct { bool active;