Refactors

This commit is contained in:
twinaphex 2015-09-25 20:42:45 +02:00
parent f9742d21a2
commit 35707d45e1
2 changed files with 23 additions and 19 deletions

View File

@ -119,19 +119,19 @@ static uint16_t green_filler(unsigned x, unsigned y)
#endif
}
static void fill_rect(menu_framebuf_t *frame_buf,
static void fill_rect(uint16_t *data, size_t pitch,
unsigned x, unsigned y,
unsigned width, unsigned height,
uint16_t (*col)(unsigned x, unsigned y))
{
unsigned i, j;
if (!frame_buf->data || !col)
if (!data || !col)
return;
for (j = y; j < y + height; j++)
for (i = x; i < x + width; i++)
frame_buf->data[j * (frame_buf->pitch >> 1) + i] = col(i, j);
data[j * (pitch >> 1) + i] = col(i, j);
}
static void color_rect(menu_handle_t *menu,
@ -280,11 +280,11 @@ static void rgui_render_background(void)
}
fill_rect(frame_buf, 5, 5, fb_width - 10, 5, green_filler);
fill_rect(frame_buf, 5, fb_height - 10, fb_width - 10, 5, green_filler);
fill_rect(frame_buf->data, frame_buf->pitch, 5, 5, fb_width - 10, 5, green_filler);
fill_rect(frame_buf->data, frame_buf->pitch, 5, fb_height - 10, fb_width - 10, 5, green_filler);
fill_rect(frame_buf, 5, 5, 5, fb_height - 10, green_filler);
fill_rect(frame_buf, fb_width - 10, 5, 5, fb_height - 10,
fill_rect(frame_buf->data, frame_buf->pitch, 5, 5, 5, fb_height - 10, green_filler);
fill_rect(frame_buf->data, frame_buf->pitch, fb_width - 10, 5, 5, fb_height - 10,
green_filler);
}
@ -354,14 +354,14 @@ static void rgui_render_messagebox(const char *message)
x = (fb_width - width) / 2;
y = (fb_height - height) / 2;
fill_rect(frame_buf, x + 5, y + 5, width - 10,
fill_rect(frame_buf->data, frame_buf->pitch, x + 5, y + 5, width - 10,
height - 10, gray_filler);
fill_rect(frame_buf, x, y, width - 5, 5, green_filler);
fill_rect(frame_buf, x + width - 5, y, 5,
fill_rect(frame_buf->data, frame_buf->pitch, x, y, width - 5, 5, green_filler);
fill_rect(frame_buf->data, frame_buf->pitch, x + width - 5, y, 5,
height - 5, green_filler);
fill_rect(frame_buf, x + 5, y + height - 5,
fill_rect(frame_buf->data, frame_buf->pitch, x + 5, y + height - 5,
width - 5, 5, green_filler);
fill_rect(frame_buf, x, y + 5, 5,
fill_rect(frame_buf->data, frame_buf->pitch, x, y + 5, 5,
height - 5, green_filler);
color = NORMAL_COLOR(settings);
@ -437,7 +437,7 @@ static void rgui_render(void)
/* if the framebuffer changed size, recache the background */
if (rgui->last_width != fb_width || rgui->last_height != fb_height)
{
fill_rect(frame_buf, 0, fb_height, fb_width, 4, gray_filler);
fill_rect(frame_buf->data, frame_buf->pitch, 0, fb_height, fb_width, 4, gray_filler);
rgui->last_width = fb_width;
rgui->last_height = fb_height;
}
@ -659,7 +659,7 @@ static void *rgui_init(void)
if (!ret)
goto error;
fill_rect(frame_buf, 0, frame_buf->height,
fill_rect(frame_buf->data, frame_buf->pitch, 0, frame_buf->height,
frame_buf->width, 4, gray_filler);
rgui->last_width = frame_buf->width;

View File

@ -231,8 +231,8 @@ static void rmenu_render(void)
static void rmenu_set_texture(void)
{
unsigned fb_width, fb_height;
menu_handle_t *menu = menu_driver_get_ptr();
menu_framebuf_t *frame_buf = menu_display_fb_get_ptr();
if (!menu)
return;
@ -243,8 +243,11 @@ static void rmenu_set_texture(void)
if (!menu_texture->pixels)
return;
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height);
video_driver_set_texture_frame(menu_texture->pixels, true,
frame_buf->width, frame_buf->height, 1.0f);
fb_width, fb_height, 1.0f);
menu_texture_inited = true;
}
@ -264,9 +267,9 @@ static void rmenu_wallpaper_set_defaults(char *s, size_t len)
static void rmenu_context_reset(void)
{
unsigned fb_width, fb_height;
char menu_bg[PATH_MAX_LENGTH] = {0};
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)
@ -279,8 +282,9 @@ static void rmenu_context_reset(void)
if (path_file_exists(menu_bg))
texture_image_load(menu_texture, menu_bg);
frame_buf->width = menu_texture->width;
frame_buf->height = menu_texture->height;
menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &menu_texture->width);
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &menu_texture->height);
menu_texture_inited = false;
}