D3D and GL now use the same font driver interface

This commit is contained in:
twinaphex 2015-03-30 00:55:39 +02:00
parent 51202f7f0a
commit 2c555082ee
15 changed files with 54 additions and 67 deletions

View File

@ -169,11 +169,11 @@ static void d3d_deinit_chain(d3d_video_t *d3d)
static void d3d_deinitialize(d3d_video_t *d3d)
{
const d3d_font_renderer_t *font_ctx = NULL;
const font_renderer_t *font_ctx = NULL;
if (!d3d)
return;
font_ctx = (const d3d_font_renderer_t*)d3d->font_driver;
font_ctx = (const font_renderer_t*)d3d->font_driver;
if (font_ctx->free)
font_ctx->free(d3d->font_handle);
@ -506,7 +506,7 @@ static void d3d_set_osd_msg(void *data, const char *msg,
const struct font_params *params, void *font)
{
d3d_video_t *d3d = (d3d_video_t*)data;
d3d_font_renderer_t *font_ctx = d3d ? (d3d_font_renderer_t*)d3d->font_driver : NULL;
font_renderer_t *font_ctx = d3d ? (font_renderer_t*)d3d->font_driver : NULL;
#ifndef _XBOX
if (params)
@ -1638,7 +1638,7 @@ static bool d3d_frame(void *data, const void *frame,
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
const d3d_font_renderer_t *font_ctx = d3d ? (const d3d_font_renderer_t*)d3d->font_driver : NULL;
const font_renderer_t *font_ctx = d3d ? (const font_renderer_t*)d3d->font_driver : NULL;
(void)i;

View File

@ -1476,7 +1476,7 @@ static INLINE void gl_draw_texture(gl_t *gl)
static bool gl_frame(void *data, const void *frame,
unsigned width, unsigned height, unsigned pitch, const char *msg)
{
const struct gl_font_renderer *font_driver = NULL;
const struct font_renderer *font_driver = NULL;
gl_t *gl = (gl_t*)data;
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
@ -1485,7 +1485,7 @@ static bool gl_frame(void *data, const void *frame,
RARCH_PERFORMANCE_INIT(frame_run);
RARCH_PERFORMANCE_START(frame_run);
font_driver = (const struct gl_font_renderer*)gl->font_driver;
font_driver = (const struct font_renderer*)gl->font_driver;
context_bind_hw_render(gl, false);
@ -1726,12 +1726,12 @@ static void gl_free_overlay(gl_t *gl)
static void gl_free(void *data)
{
gl_t *gl = (gl_t*)data;
const struct gl_font_renderer *font_driver = NULL;
const struct font_renderer *font_driver = NULL;
if (!gl)
return;
font_driver = (const struct gl_font_renderer*)gl->font_driver;
font_driver = (const struct font_renderer*)gl->font_driver;
context_bind_hw_render(gl, false);
@ -3161,12 +3161,12 @@ static void gl_apply_state_changes(void *data)
static void gl_set_osd_msg(void *data, const char *msg,
const struct font_params *params, void *font)
{
const struct gl_font_renderer *font_driver = NULL;
const struct font_renderer *font_driver = NULL;
gl_t *gl = (gl_t*)data;
if (!gl)
return;
font_driver = (const struct gl_font_renderer*)gl->font_driver;
font_driver = (const struct font_renderer*)gl->font_driver;
if (font_driver && gl->font_handle)
{

View File

@ -108,7 +108,7 @@ static void d3dfonts_w32_render_msg(void *data, const char *msg,
d3dfonts->d3d->dev->EndScene();
}
d3d_font_renderer_t d3d_win32_font = {
font_renderer_t d3d_win32_font = {
d3dfonts_w32_init_font,
d3dfonts_w32_free_font,
d3dfonts_w32_render_msg,

View File

@ -379,7 +379,7 @@ static void gl_raster_font_bind_block(void *data, void *userdata)
font->block = block;
}
gl_font_renderer_t gl_raster_font = {
font_renderer_t gl_raster_font = {
gl_raster_font_init_font,
gl_raster_font_free_font,
gl_raster_font_render_msg,

View File

@ -98,7 +98,7 @@ static void libdbg_font_render_msg(void *data, const char *msg,
#endif
}
gl_font_renderer_t libdbg_font = {
font_renderer_t libdbg_font = {
libdbg_font_init_font,
libdbg_font_free_font,
libdbg_font_render_msg,

View File

@ -83,7 +83,7 @@ static void xfonts_render_msg(void *data, const char *msg,
xfonts->pFrontBuffer->Release();
}
d3d_font_renderer_t d3d_xdk1_font = {
font_renderer_t d3d_xdk1_font = {
xfonts_init_font,
xfonts_free_font,
xfonts_render_msg,

View File

@ -487,7 +487,7 @@ static void xdk360_render_msg(void *data, const char *str_msg,
}
}
d3d_font_renderer_t d3d_xbox360_font = {
font_renderer_t d3d_xbox360_font = {
xdk360_init_font,
xdk360_free_font,
xdk360_render_msg,

View File

@ -35,11 +35,11 @@ typedef struct freetype_renderer
struct font_atlas atlas;
struct font_glyph glyphs[FT_ATLAS_SIZE];
} font_renderer_t;
} ft_font_renderer_t;
static const struct font_atlas *font_renderer_ft_get_atlas(void *data)
{
font_renderer_t *handle = (font_renderer_t*)data;
ft_font_renderer_t *handle = (ft_font_renderer_t*)data;
if (!handle)
return NULL;
return &handle->atlas;
@ -48,7 +48,7 @@ static const struct font_atlas *font_renderer_ft_get_atlas(void *data)
static const void *font_renderer_ft_get_glyph(
void *data, uint32_t code)
{
font_renderer_t *handle = (font_renderer_t*)data;
ft_font_renderer_t *handle = (ft_font_renderer_t*)data;
if (!handle)
return NULL;
return code < FT_ATLAS_SIZE ? &handle->glyphs[code] : NULL;
@ -56,7 +56,7 @@ static const void *font_renderer_ft_get_glyph(
static void font_renderer_ft_free(void *data)
{
font_renderer_t *handle = (font_renderer_t*)data;
ft_font_renderer_t *handle = (ft_font_renderer_t*)data;
if (!handle)
return;
@ -69,7 +69,7 @@ static void font_renderer_ft_free(void *data)
free(handle);
}
static bool font_renderer_create_atlas(font_renderer_t *handle)
static bool font_renderer_create_atlas(ft_font_renderer_t *handle)
{
unsigned i;
bool ret = true;
@ -162,7 +162,7 @@ static void *font_renderer_ft_init(const char *font_path, float font_size)
{
FT_Error err;
font_renderer_t *handle = (font_renderer_t*)
ft_font_renderer_t *handle = (ft_font_renderer_t*)
calloc(1, sizeof(*handle));
if (!handle)

View File

@ -17,7 +17,7 @@
#include "font_d3d_driver.h"
#include "../general.h"
static const d3d_font_renderer_t *d3d_font_backends[] = {
static const font_renderer_t *d3d_font_backends[] = {
#if defined(_XBOX1)
&d3d_xdk1_font,
#elif defined(_XBOX360)

View File

@ -20,28 +20,12 @@
#include <stdint.h>
#include <boolean.h>
#include "../driver.h"
#include "font_renderer_driver.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct d3d_font_renderer
{
void *(*init)(void *data, const char *font_path, float font_size);
void (*free)(void *data);
void (*render_msg)(void *data, const char *msg,
const void *params);
const char *ident;
const void *(*get_glyph)(void *data, uint32_t code);
void (*bind_block)(void *data, void *block);
void (*flush)(void *data);
} d3d_font_renderer_t;
extern d3d_font_renderer_t d3d_xbox360_font;
extern d3d_font_renderer_t d3d_xdk1_font;
extern d3d_font_renderer_t d3d_win32_font;
bool d3d_font_init_first(
const void **font_driver, void **font_handle,
void *video_data, const char *font_path, float font_size);

View File

@ -17,7 +17,7 @@
#include "font_gl_driver.h"
#include "../general.h"
static const gl_font_renderer_t *gl_font_backends[] = {
static const font_renderer_t *gl_font_backends[] = {
#if defined(HAVE_LIBDBGFONT)
&libdbg_font,
#else

View File

@ -18,26 +18,10 @@
#define __FONT_GL_DRIVER_H__
#include "../driver.h"
#include "font_renderer_driver.h"
#include "gl_common.h"
#include <boolean.h>
struct font_glyph;
typedef struct gl_font_renderer
{
void *(*init)(void *data, const char *font_path, float font_size);
void (*free)(void *data);
void (*render_msg)(void *data, const char *msg, const void *userdata);
const char *ident;
const void *(*get_glyph)(void *data, uint32_t code);
void (*bind_block)(void *data, void *block);
void (*flush)(void *data);
} gl_font_renderer_t;
extern gl_font_renderer_t gl_raster_font;
extern gl_font_renderer_t libdbg_font;
bool gl_font_init_first(const void **font_driver,
void **font_handle, void *gl_data,
const char *font_path, float font_size);

View File

@ -55,6 +55,25 @@ struct font_atlas
unsigned height;
};
typedef struct font_renderer
{
void *(*init)(void *data, const char *font_path, float font_size);
void (*free)(void *data);
void (*render_msg)(void *data, const char *msg,
const void *params);
const char *ident;
const void *(*get_glyph)(void *data, uint32_t code);
void (*bind_block)(void *data, void *block);
void (*flush)(void *data);
} font_renderer_t;
extern font_renderer_t gl_raster_font;
extern font_renderer_t libdbg_font;
extern font_renderer_t d3d_xbox360_font;
extern font_renderer_t d3d_xdk1_font;
extern font_renderer_t d3d_win32_font;
typedef struct font_renderer_driver
{
void *(*init)(const char *font_path, float font_size);

View File

@ -329,7 +329,7 @@ static void glui_frame(void)
glui_handle_t *glui = NULL;
const char *core_name = NULL;
const char *core_version = NULL;
const struct gl_font_renderer *font_driver = NULL;
const struct font_renderer *font_driver = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_normal_color);
@ -346,7 +346,7 @@ static void glui_frame(void)
if (!gl)
return;
font_driver = (const struct gl_font_renderer*)gl->font_driver;
font_driver = (const struct font_renderer*)gl->font_driver;
glui = (glui_handle_t*)menu->userdata;
@ -501,7 +501,7 @@ static void *glui_init(void)
{
glui_handle_t *glui = NULL;
const video_driver_t *video_driver = NULL;
const struct gl_font_renderer *font_driver = NULL;
const struct font_renderer *font_driver = NULL;
menu_handle_t *menu = NULL;
gl_t *gl = (gl_t*)video_driver_get_ptr(&video_driver);
@ -511,7 +511,7 @@ static void *glui_init(void)
return NULL;
}
font_driver = (const struct gl_font_renderer*)gl->font_driver;
font_driver = (const struct font_renderer*)gl->font_driver;
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
if (!menu)
@ -538,7 +538,7 @@ error:
static void glui_free(void *data)
{
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
const struct gl_font_renderer *font_driver = NULL;
const struct font_renderer *font_driver = NULL;
menu_handle_t *menu = (menu_handle_t*)data;
glui_handle_t *glui = (glui_handle_t*)menu->userdata;
@ -548,7 +548,7 @@ static void glui_free(void *data)
gl_coord_array_free(&glui->raster_block.carr);
font_driver = (const struct gl_font_renderer*)gl->font_driver;
font_driver = (const struct font_renderer*)gl->font_driver;
if (glui->use_blocks)
font_driver->bind_block(gl->font_handle, NULL);

View File

@ -1250,7 +1250,7 @@ static void xmb_frame(void)
const char *core_version = NULL;
xmb_handle_t *xmb = NULL;
gl_t *gl = NULL;
const struct gl_font_renderer *font_driver = NULL;
const struct font_renderer *font_driver = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
@ -1268,7 +1268,7 @@ static void xmb_frame(void)
if (!gl)
return;
font_driver = (const struct gl_font_renderer*)gl->font_driver;
font_driver = (const struct font_renderer*)gl->font_driver;
if (font_driver->bind_block)
font_driver->bind_block(xmb->font.buf, &xmb->raster_block);
@ -1516,13 +1516,13 @@ static void xmb_free(void *data)
{
menu_handle_t *menu = (menu_handle_t*)data;
xmb_handle_t *xmb = NULL;
const struct gl_font_renderer *font_driver = NULL;
const struct font_renderer *font_driver = NULL;
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
if (!gl)
return;
font_driver = (const struct gl_font_renderer*)gl->font_driver;
font_driver = (const struct font_renderer*)gl->font_driver;
if (menu && menu->userdata)
{