mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
(gl_font_renderer_t) Implement block flushing
This commit is contained in:
parent
8f0302c519
commit
7d1bffc350
@ -32,7 +32,6 @@
|
||||
|
||||
typedef struct gl_raster_block {
|
||||
bool active;
|
||||
bool reuse;
|
||||
bool fullscreen;
|
||||
unsigned allocated;
|
||||
struct gl_coords coords;
|
||||
@ -430,30 +429,43 @@ static const struct font_glyph *gl_raster_font_get_glyph(
|
||||
return font->font_driver->get_glyph((void*)font->font_driver, code);
|
||||
}
|
||||
|
||||
static void gl_flush_block(void *data)
|
||||
{
|
||||
gl_raster_t *font = (gl_raster_t*)data;
|
||||
gl_raster_block_t *block = &font->block;
|
||||
|
||||
if (block->coords.vertices)
|
||||
{
|
||||
setup_viewport(font, block->fullscreen);
|
||||
|
||||
draw_vertices(font->gl, &block->coords);
|
||||
|
||||
restore_viewport(font->gl);
|
||||
}
|
||||
|
||||
block->coords.vertices = 0;
|
||||
}
|
||||
|
||||
static void gl_end_block(void *data)
|
||||
{
|
||||
gl_raster_t *font = (gl_raster_t*)data;
|
||||
gl_raster_block_t *block = &font->block;
|
||||
gl_t *gl = font->gl;
|
||||
|
||||
if (block->coords.vertices)
|
||||
gl_flush_block(data);
|
||||
|
||||
block->active = false;
|
||||
|
||||
if (block->allocated)
|
||||
{
|
||||
setup_viewport(font, block->fullscreen);
|
||||
|
||||
draw_vertices(gl, &block->coords);
|
||||
|
||||
restore_viewport(gl);
|
||||
free((void*)block->coords.color);
|
||||
free((void*)block->coords.lut_tex_coord);
|
||||
free((void*)block->coords.tex_coord);
|
||||
free((void*)block->coords.vertex);
|
||||
}
|
||||
|
||||
if (block->reuse && block->coords.vertices)
|
||||
block->coords.vertices = 0;
|
||||
else
|
||||
{
|
||||
block->active = false;
|
||||
block->allocated = 0;
|
||||
resize_block(font, 0);
|
||||
memset(&block->coords, 0, sizeof(block->coords));
|
||||
}
|
||||
block->coords.vertices = 0;
|
||||
block->allocated = 0;
|
||||
}
|
||||
|
||||
static void gl_begin_block(void *data)
|
||||
@ -463,12 +475,8 @@ static void gl_begin_block(void *data)
|
||||
unsigned i = 0;
|
||||
|
||||
if (block->active)
|
||||
{
|
||||
block->reuse = true;
|
||||
gl_end_block(data);
|
||||
}
|
||||
gl_flush_block(data);
|
||||
|
||||
block->reuse = false;
|
||||
block->active = true;
|
||||
block->coords.vertices = 0;
|
||||
|
||||
@ -486,5 +494,6 @@ gl_font_renderer_t gl_raster_font = {
|
||||
"GL raster",
|
||||
gl_raster_font_get_glyph,
|
||||
gl_begin_block,
|
||||
gl_flush_block,
|
||||
gl_end_block
|
||||
};
|
||||
|
@ -32,6 +32,7 @@ typedef struct gl_font_renderer
|
||||
|
||||
const struct font_glyph *(*get_glyph)(void *data, uint32_t code);
|
||||
void (*begin_block)(void *data);
|
||||
void (*flush_block)(void *data);
|
||||
void (*end_block)(void *data);
|
||||
} gl_font_renderer_t;
|
||||
|
||||
|
@ -326,6 +326,7 @@ static void glui_frame(void)
|
||||
settings_t *settings = config_get_ptr();
|
||||
const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_normal_color);
|
||||
const uint32_t hover_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_hover_color);
|
||||
const uint32_t title_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.title_color);
|
||||
runloop_t *runloop = rarch_main_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
@ -356,9 +357,6 @@ static void glui_frame(void)
|
||||
|
||||
glui_render_background(settings, gl, glui, false);
|
||||
|
||||
if (gl->font_driver->begin_block)
|
||||
gl->font_driver->begin_block(gl->font_handle);
|
||||
|
||||
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
|
||||
|
||||
get_title(label, dir, menu_type, title, sizeof(title));
|
||||
@ -366,7 +364,7 @@ static void glui_frame(void)
|
||||
menu_animation_ticker_line(title_buf, glui->term_width - 3,
|
||||
runloop->frames.video.count / glui->margin, title, true);
|
||||
glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height,
|
||||
title_buf, FONT_COLOR_ARGB_TO_RGBA(settings->menu.title_color));
|
||||
title_buf, title_color);
|
||||
|
||||
core_name = global->menu.info.library_name;
|
||||
if (!core_name)
|
||||
@ -388,7 +386,7 @@ static void glui_frame(void)
|
||||
glui_blit_line(gl,
|
||||
glui->margin * 2,
|
||||
glui->margin + glui->term_height * glui->line_height
|
||||
+ glui->line_height * 2, title_msg, FONT_COLOR_ARGB_TO_RGBA(settings->menu.title_color));
|
||||
+ glui->line_height * 2, title_msg, title_color);
|
||||
}
|
||||
|
||||
if (settings->menu.timedate_enable)
|
||||
@ -460,12 +458,12 @@ static void glui_frame(void)
|
||||
glui->box_message[0] = '\0';
|
||||
}
|
||||
|
||||
if (gl->font_driver->end_block)
|
||||
gl->font_driver->end_block(gl->font_handle);
|
||||
|
||||
if (settings->menu.mouse.enable)
|
||||
glui_draw_cursor(gl, menu->mouse.x, menu->mouse.y);
|
||||
|
||||
if (gl->font_driver->flush_block)
|
||||
gl->font_driver->flush_block(gl->font_handle);
|
||||
|
||||
gl_set_viewport(gl, gl->win_width, gl->win_height, false, true);
|
||||
}
|
||||
|
||||
@ -495,6 +493,9 @@ static void *glui_init(void)
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
glui->textures.bg.id = 0;
|
||||
|
||||
if (gl->font_driver->begin_block)
|
||||
gl->font_driver->begin_block(gl->font_handle);
|
||||
|
||||
return menu;
|
||||
error:
|
||||
if (menu)
|
||||
@ -504,8 +505,13 @@ error:
|
||||
|
||||
static void glui_free(void *data)
|
||||
{
|
||||
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
|
||||
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
|
||||
if (gl->font_driver->end_block)
|
||||
gl->font_driver->end_block(gl->font_handle);
|
||||
|
||||
if (menu->alloc_font)
|
||||
free((uint8_t*)menu->font);
|
||||
|
||||
|
@ -397,7 +397,7 @@ static void xmb_draw_text(gl_t *gl, xmb_handle_t *xmb, const char *str, float x,
|
||||
|| y < -xmb->icon.size || y > gl->win_height + xmb->icon.size)
|
||||
return;
|
||||
|
||||
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
||||
/* gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); */
|
||||
|
||||
params.x = x / gl->win_width;
|
||||
params.y = 1.0f - y / gl->win_height;
|
||||
@ -1165,6 +1165,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
|
||||
|
||||
xmb_draw_icon_end(gl, xmb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void xmb_draw_cursor(gl_t *gl, xmb_handle_t *xmb, float x, float y)
|
||||
@ -1377,6 +1378,9 @@ static void xmb_frame(void)
|
||||
xmb_frame_messagebox(msg);
|
||||
}
|
||||
|
||||
if (gl->font_driver->flush_block)
|
||||
gl->font_driver->flush_block(gl->font_handle);
|
||||
|
||||
if (settings->menu.mouse.enable)
|
||||
xmb_draw_cursor(gl, xmb, menu->mouse.x, menu->mouse.y);
|
||||
|
||||
@ -1482,6 +1486,9 @@ static void *xmb_init(void)
|
||||
if (global->core_info)
|
||||
menu->categories.size = global->core_info->count + 1;
|
||||
|
||||
if (gl->font_driver->begin_block)
|
||||
gl->font_driver->begin_block(gl->font_handle);
|
||||
|
||||
return menu;
|
||||
|
||||
error:
|
||||
@ -1497,9 +1504,13 @@ error:
|
||||
static void xmb_free(void *data)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
|
||||
|
||||
if (menu && menu->userdata)
|
||||
free(menu->userdata);
|
||||
|
||||
if (gl->font_driver->begin_block)
|
||||
gl->font_driver->begin_block(gl->font_handle);
|
||||
}
|
||||
|
||||
static bool xmb_font_init_first(const gl_font_renderer_t **font_driver,
|
||||
|
Loading…
x
Reference in New Issue
Block a user