mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(RGUI) Move framebuf and pitch from menu_handle_t to rgui_handle_t
This commit is contained in:
parent
d01d42a3a9
commit
90b7f9b225
@ -271,8 +271,6 @@ static int menu_settings_iterate(unsigned action,
|
||||
const char *path = NULL;
|
||||
const char *label = NULL;
|
||||
unsigned type = 0, scroll_speed = 0;
|
||||
|
||||
driver.menu->frame_buf_pitch = driver.menu->width * 2;
|
||||
|
||||
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
|
||||
driver.menu->selection_ptr, &path, &label, &type);
|
||||
|
@ -37,7 +37,9 @@
|
||||
|
||||
typedef struct rgui_handle
|
||||
{
|
||||
uint16_t *menu_framebuf;
|
||||
unsigned term_height;
|
||||
uint16_t *frame_buf;
|
||||
size_t frame_buf_pitch;
|
||||
} rgui_handle_t;
|
||||
|
||||
#define RGUI_TERM_START_X (driver.menu->width / 21)
|
||||
@ -115,10 +117,16 @@ static void color_rect(uint16_t *buf, unsigned pitch,
|
||||
static void blit_line(int x, int y, const char *message, bool green)
|
||||
{
|
||||
int j, i;
|
||||
rgui_handle_t *rgui = NULL;
|
||||
|
||||
if (!driver.menu)
|
||||
return;
|
||||
|
||||
rgui = (rgui_handle_t*)driver.menu->userdata;
|
||||
|
||||
if (!rgui)
|
||||
return;
|
||||
|
||||
while (*message)
|
||||
{
|
||||
for (j = 0; j < FONT_HEIGHT; j++)
|
||||
@ -132,8 +140,8 @@ static void blit_line(int x, int y, const char *message, bool green)
|
||||
|
||||
if (col)
|
||||
{
|
||||
driver.menu->frame_buf[(y + j) *
|
||||
(driver.menu->frame_buf_pitch >> 1) + (x + i)] = green ?
|
||||
rgui->frame_buf[(y + j) *
|
||||
(rgui->frame_buf_pitch >> 1) + (x + i)] = green ?
|
||||
#if defined(GEKKO)|| defined(PSP)
|
||||
(3 << 0) | (10 << 4) | (3 << 8) | (7 << 12) : 0x7FFF;
|
||||
#else
|
||||
@ -189,25 +197,24 @@ static bool rguidisp_init_font(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void rgui_render_background(void)
|
||||
static void rgui_render_background(void *data)
|
||||
{
|
||||
if (!driver.menu)
|
||||
return;
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
0, 0, driver.menu->width, driver.menu->height, gray_filler);
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
5, 5, driver.menu->width - 10, 5, green_filler);
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
5, driver.menu->height - 10, driver.menu->width - 10, 5,
|
||||
green_filler);
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
5, 5, 5, driver.menu->height - 10, green_filler);
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
driver.menu->width - 10, 5, 5, driver.menu->height - 10,
|
||||
green_filler);
|
||||
}
|
||||
@ -215,10 +222,16 @@ static void rgui_render_background(void)
|
||||
static void rgui_render_messagebox(const char *message)
|
||||
{
|
||||
size_t i;
|
||||
rgui_handle_t *rgui = NULL;
|
||||
|
||||
if (!driver.menu || !message || !*message)
|
||||
return;
|
||||
|
||||
rgui = (rgui_handle_t*)driver.menu->userdata;
|
||||
|
||||
if (!rgui)
|
||||
return;
|
||||
|
||||
struct string_list *list = string_split(message, "\n");
|
||||
if (!list)
|
||||
return;
|
||||
@ -252,19 +265,19 @@ static void rgui_render_messagebox(const char *message)
|
||||
int x = (driver.menu->width - width) / 2;
|
||||
int y = (driver.menu->height - height) / 2;
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
x + 5, y + 5, width - 10, height - 10, gray_filler);
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
x, y, width - 5, 5, green_filler);
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
x + width - 5, y, 5, height - 5, green_filler);
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
x + 5, y + height - 5, width - 5, 5, green_filler);
|
||||
|
||||
fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
x, y + 5, 5, height - 5, green_filler);
|
||||
|
||||
for (i = 0; i < list->size; i++)
|
||||
@ -278,26 +291,35 @@ static void rgui_render_messagebox(const char *message)
|
||||
string_list_free(list);
|
||||
}
|
||||
|
||||
static void blit_cursor(void)
|
||||
static void rgui_blit_cursor(void* data)
|
||||
{
|
||||
int16_t x = driver.menu->mouse.x;
|
||||
int16_t y = driver.menu->mouse.y;
|
||||
int16_t x, y;
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
|
||||
color_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
x = driver.menu->mouse.x;
|
||||
y = driver.menu->mouse.y;
|
||||
|
||||
color_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
x, y-5, 1, 11, 0xFFFF);
|
||||
color_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch,
|
||||
color_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
x-5, y, 11, 1, 0xFFFF);
|
||||
}
|
||||
|
||||
static void rgui_render(void)
|
||||
{
|
||||
size_t end;
|
||||
rgui_handle_t *rgui = NULL;
|
||||
|
||||
if (driver.menu->need_refresh
|
||||
&& g_extern.is_menu
|
||||
&& !driver.menu->msg_force)
|
||||
return;
|
||||
|
||||
rgui = (rgui_handle_t*)driver.menu->userdata;
|
||||
|
||||
if (!rgui)
|
||||
return;
|
||||
|
||||
if (driver.menu->mouse.wheeldown && driver.menu->begin
|
||||
< menu_list_get_size(driver.menu->menu_list) - RGUI_TERM_HEIGHT)
|
||||
driver.menu->begin++;
|
||||
@ -314,7 +336,7 @@ static void rgui_render(void)
|
||||
driver.menu->begin + RGUI_TERM_HEIGHT :
|
||||
menu_list_get_size(driver.menu->menu_list);
|
||||
|
||||
rgui_render_background();
|
||||
rgui_render_background(rgui);
|
||||
|
||||
char title[256];
|
||||
const char *dir = NULL;
|
||||
@ -424,11 +446,12 @@ static void rgui_render(void)
|
||||
}
|
||||
|
||||
if (driver.menu->mouse.enable)
|
||||
blit_cursor();
|
||||
rgui_blit_cursor(rgui);
|
||||
}
|
||||
|
||||
static void *rgui_init(void)
|
||||
{
|
||||
rgui_handle_t *rgui = NULL;
|
||||
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
||||
|
||||
if (!menu)
|
||||
@ -442,9 +465,11 @@ static void *rgui_init(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
menu->frame_buf = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t));
|
||||
rgui = (rgui_handle_t*)menu->userdata;
|
||||
|
||||
if (!menu->frame_buf)
|
||||
rgui->frame_buf = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t));
|
||||
|
||||
if (!rgui->frame_buf)
|
||||
{
|
||||
free(menu->userdata);
|
||||
free(menu);
|
||||
@ -454,7 +479,7 @@ static void *rgui_init(void)
|
||||
menu->width = 320;
|
||||
menu->height = 240;
|
||||
menu->begin = 0;
|
||||
menu->frame_buf_pitch = menu->width * sizeof(uint16_t);
|
||||
rgui->frame_buf_pitch = menu->width * sizeof(uint16_t);
|
||||
|
||||
bool ret = rguidisp_init_font(menu);
|
||||
|
||||
@ -485,8 +510,8 @@ static void rgui_free(void *data)
|
||||
if (!rgui)
|
||||
return;
|
||||
|
||||
if (menu->frame_buf)
|
||||
free(menu->frame_buf);
|
||||
if (rgui->frame_buf)
|
||||
free(rgui->frame_buf);
|
||||
|
||||
if (menu->userdata)
|
||||
free(menu->userdata);
|
||||
@ -499,11 +524,12 @@ static void rgui_free(void *data)
|
||||
static void rgui_set_texture(void *data)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)menu->userdata;
|
||||
|
||||
if (driver.video_data && driver.video_poke &&
|
||||
driver.video_poke->set_texture_frame)
|
||||
driver.video_poke->set_texture_frame(driver.video_data,
|
||||
menu->frame_buf, false, menu->width, menu->height, 1.0f);
|
||||
rgui->frame_buf, false, menu->width, menu->height, 1.0f);
|
||||
}
|
||||
|
||||
static void rgui_navigation_clear(void *data, bool pending_push)
|
||||
@ -513,6 +539,18 @@ static void rgui_navigation_clear(void *data, bool pending_push)
|
||||
|
||||
static void rgui_navigation_set(void *data, bool scroll)
|
||||
{
|
||||
rgui_handle_t *rgui = NULL;
|
||||
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
rgui = (rgui_handle_t*)menu->userdata;
|
||||
|
||||
if (!rgui)
|
||||
return;
|
||||
|
||||
if (!scroll)
|
||||
return;
|
||||
|
||||
|
@ -77,9 +77,6 @@ typedef struct
|
||||
unsigned height;
|
||||
size_t begin;
|
||||
|
||||
uint16_t *frame_buf;
|
||||
size_t frame_buf_pitch;
|
||||
|
||||
menu_list_t *menu_list;
|
||||
size_t selection_ptr;
|
||||
size_t selection_ptr_old;
|
||||
|
Loading…
x
Reference in New Issue
Block a user