mirror of
https://github.com/libretro/RetroArch
synced 2025-03-24 04:44:02 +00:00
(gl_font_renderer_t) Implement swappable blocks and remove end_block pointer
This commit is contained in:
parent
ed6f1cfdd3
commit
8b7bbc7975
@ -39,6 +39,7 @@
|
||||
#endif
|
||||
|
||||
#include "../gl_common.h"
|
||||
#include "../font_gl_driver.h"
|
||||
#include "../video_viewport.h"
|
||||
#include "../video_pixel_converter.h"
|
||||
#include "../video_context_driver.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "../gl_common.h"
|
||||
#include "../font_gl_driver.h"
|
||||
#include "../video_shader_driver.h"
|
||||
|
||||
#define emit(c, vx, vy) do { \
|
||||
@ -30,11 +31,6 @@
|
||||
|
||||
#define MAX_MSG_LEN_CHUNK 64
|
||||
|
||||
typedef struct gl_raster_block {
|
||||
bool fullscreen;
|
||||
gl_coord_array_t carr;
|
||||
} gl_raster_block_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gl_t *gl;
|
||||
@ -44,7 +40,7 @@ typedef struct
|
||||
const font_renderer_driver_t *font_driver;
|
||||
void *font_data;
|
||||
|
||||
gl_raster_block_t *block;
|
||||
gl_font_raster_block_t *block;
|
||||
} gl_raster_t;
|
||||
|
||||
static void *gl_raster_font_init_font(void *gl_data,
|
||||
@ -359,7 +355,7 @@ static const struct font_glyph *gl_raster_font_get_glyph(
|
||||
static void gl_flush_block(void *data)
|
||||
{
|
||||
gl_raster_t *font = (gl_raster_t*)data;
|
||||
gl_raster_block_t *block = font->block;
|
||||
gl_font_raster_block_t *block = font->block;
|
||||
|
||||
if (block->carr.coords.vertices)
|
||||
{
|
||||
@ -373,27 +369,12 @@ static void gl_flush_block(void *data)
|
||||
block->carr.coords.vertices = 0;
|
||||
}
|
||||
|
||||
static void gl_end_block(void *data)
|
||||
{
|
||||
gl_raster_t *font = (gl_raster_t*)data;
|
||||
gl_t *gl = font->gl;
|
||||
|
||||
gl_flush_block(data);
|
||||
|
||||
gl_coord_array_release(&font->block->carr);
|
||||
free(font->block);
|
||||
font->block = NULL;
|
||||
}
|
||||
|
||||
static void gl_begin_block(void *data)
|
||||
static void gl_bind_block(void *data, gl_font_raster_block_t *block)
|
||||
{
|
||||
gl_raster_t *font = (gl_raster_t*)data;
|
||||
unsigned i = 0;
|
||||
|
||||
if (font->block)
|
||||
return;
|
||||
|
||||
font->block = calloc(1, sizeof(gl_raster_block_t));
|
||||
font->block = block;
|
||||
}
|
||||
|
||||
gl_font_renderer_t gl_raster_font = {
|
||||
@ -402,7 +383,6 @@ gl_font_renderer_t gl_raster_font = {
|
||||
gl_raster_font_render_msg,
|
||||
"GL raster",
|
||||
gl_raster_font_get_glyph,
|
||||
gl_begin_block,
|
||||
gl_flush_block,
|
||||
gl_end_block
|
||||
gl_bind_block,
|
||||
gl_flush_block
|
||||
};
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "../font_renderer_driver.h"
|
||||
#include "../gl_common.h"
|
||||
#include "../font_gl_driver.h"
|
||||
|
||||
#if defined(SN_TARGET_PSP2)
|
||||
#include <libdbgfont.h>
|
||||
|
@ -18,10 +18,17 @@
|
||||
#define __FONT_GL_DRIVER_H__
|
||||
|
||||
#include "../driver.h"
|
||||
#include "gl_common.h"
|
||||
#include <boolean.h>
|
||||
|
||||
struct font_glyph;
|
||||
|
||||
/* XXX: please include gl_common.h before this file */
|
||||
typedef struct gl_raster_block {
|
||||
bool fullscreen;
|
||||
gl_coord_array_t carr;
|
||||
} gl_font_raster_block_t;
|
||||
|
||||
typedef struct gl_font_renderer
|
||||
{
|
||||
void *(*init)(void *data, const char *font_path, float font_size);
|
||||
@ -31,9 +38,8 @@ typedef struct gl_font_renderer
|
||||
const char *ident;
|
||||
|
||||
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);
|
||||
void (*bind_block)(void *data, gl_font_raster_block_t *block);
|
||||
void (*flush)(void *data);
|
||||
} gl_font_renderer_t;
|
||||
|
||||
extern gl_font_renderer_t gl_raster_font;
|
||||
|
@ -186,6 +186,9 @@ bool gl_coord_array_add(gl_coord_array_t *ca, const gl_coords_t *coords, unsigne
|
||||
|
||||
void gl_coord_array_release(gl_coord_array_t *ca)
|
||||
{
|
||||
if (!ca->allocated)
|
||||
return;
|
||||
|
||||
free(ca->coords.vertex);
|
||||
free(ca->coords.color);
|
||||
free(ca->coords.tex_coord);
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "font_renderer_driver.h"
|
||||
#include <gfx/math/matrix_4x4.h>
|
||||
#include <gfx/scaler/scaler.h>
|
||||
#include "font_gl_driver.h"
|
||||
//#include "font_gl_driver.h"
|
||||
#include <formats/image.h>
|
||||
#include "video_shader_driver.h"
|
||||
#include <retro_inline.h>
|
||||
@ -255,6 +255,8 @@ typedef struct gl_coord_array
|
||||
unsigned allocated;
|
||||
} gl_coord_array_t;
|
||||
|
||||
struct gl_font_renderer;
|
||||
|
||||
typedef struct gl
|
||||
{
|
||||
const gfx_ctx_driver_t *ctx_driver;
|
||||
@ -333,7 +335,7 @@ typedef struct gl
|
||||
#endif
|
||||
|
||||
/* Fonts */
|
||||
const gl_font_renderer_t *font_driver;
|
||||
const struct gl_font_renderer *font_driver;
|
||||
void *font_handle;
|
||||
|
||||
bool egl_images;
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include "../../gfx/gl_common.h"
|
||||
#include "../../gfx/font_gl_driver.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
#include <compat/posix_string.h>
|
||||
|
||||
@ -46,6 +47,8 @@ typedef struct glui_handle
|
||||
char path[PATH_MAX_LENGTH];
|
||||
} bg;
|
||||
} textures;
|
||||
|
||||
gl_font_raster_block_t raster_block;
|
||||
} glui_handle_t;
|
||||
|
||||
static int glui_entry_iterate(unsigned action)
|
||||
@ -461,8 +464,8 @@ static void glui_frame(void)
|
||||
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);
|
||||
if (gl->font_driver->flush)
|
||||
gl->font_driver->flush(gl->font_handle);
|
||||
|
||||
gl_set_viewport(gl, gl->win_width, gl->win_height, false, true);
|
||||
}
|
||||
@ -493,8 +496,8 @@ 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);
|
||||
if (gl->font_driver->bind_block)
|
||||
gl->font_driver->bind_block(gl->font_handle, &glui->raster_block);
|
||||
|
||||
return menu;
|
||||
error:
|
||||
@ -508,9 +511,9 @@ static void glui_free(void *data)
|
||||
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
|
||||
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
glui_handle_t *glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (gl->font_driver->end_block)
|
||||
gl->font_driver->end_block(gl->font_handle);
|
||||
gl_coord_array_release(&glui->raster_block.carr);
|
||||
|
||||
if (menu->alloc_font)
|
||||
free((uint8_t*)menu->font);
|
||||
|
@ -211,6 +211,8 @@ typedef struct xmb_handle
|
||||
|
||||
xmb_node_t settings_node;
|
||||
bool prevent_populate;
|
||||
|
||||
gl_font_raster_block_t raster_block;
|
||||
} xmb_handle_t;
|
||||
|
||||
static const GLfloat rmb_vertex[] = {
|
||||
@ -1378,8 +1380,8 @@ static void xmb_frame(void)
|
||||
xmb_frame_messagebox(msg);
|
||||
}
|
||||
|
||||
if (gl->font_driver->flush_block)
|
||||
gl->font_driver->flush_block(gl->font_handle);
|
||||
if (gl->font_driver->flush)
|
||||
gl->font_driver->flush(gl->font_handle);
|
||||
|
||||
if (settings->menu.mouse.enable)
|
||||
xmb_draw_cursor(gl, xmb, menu->mouse.x, menu->mouse.y);
|
||||
@ -1486,8 +1488,8 @@ 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);
|
||||
if (gl->font_driver->bind_block)
|
||||
gl->font_driver->bind_block(gl->font_handle, &xmb->raster_block);
|
||||
|
||||
return menu;
|
||||
|
||||
@ -1504,13 +1506,15 @@ error:
|
||||
static void xmb_free(void *data)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
xmb_handle_t *xmb = NULL;
|
||||
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
|
||||
|
||||
if (menu && menu->userdata)
|
||||
free(menu->userdata);
|
||||
|
||||
if (gl->font_driver->end_block)
|
||||
gl->font_driver->end_block(gl->font_handle);
|
||||
xmb = (xmb_handle_t*)menu->userdata;
|
||||
|
||||
gl_coord_array_release(&xmb->raster_block.carr);
|
||||
}
|
||||
|
||||
static bool xmb_font_init_first(const gl_font_renderer_t **font_driver,
|
||||
|
Loading…
x
Reference in New Issue
Block a user