(Font driver/drivers display) All the font_init_first implementations

were exactly the same, cut down on code duplication
This commit is contained in:
libretroadmin 2022-06-26 17:27:59 +02:00
parent 6aa16442db
commit aab64da1be
19 changed files with 24 additions and 297 deletions

View File

@ -22,7 +22,6 @@
#include "../gfx_display.h"
#include "../../retroarch.h"
#include "../font_driver.h"
#include "../common/ctr_common.h"
#include "../drivers/ctr_gu.h"
#include "../../ctr/gpu_old.h"
@ -127,24 +126,6 @@ static void gfx_display_ctr_draw(gfx_display_ctx_draw_t *draw,
}
GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, 0, GPU_REPLACE, GPU_REPLACE, 0);
#if 0
printf("(%i,%i,%i,%i) , (%i,%i)\n", (int)draw->x,
(int)draw->y, (int)draw->width, (int)draw->height,
texture->width, texture->height);
#endif
}
static bool gfx_display_ctr_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_CTR);
return *handle;
}
gfx_display_ctx_driver_t gfx_display_ctx_ctr = {
@ -155,7 +136,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_ctr = {
NULL, /* get_default_mvp */
NULL, /* get_default_vertices */
NULL, /* get_default_tex_coords */
gfx_display_ctr_font_init_first,
FONT_DRIVER_RENDER_CTR,
GFX_VIDEO_DRIVER_CTR,
"ctr",
true,

View File

@ -25,7 +25,6 @@
#include "../gfx_display.h"
#include "../../retroarch.h"
#include "../font_driver.h"
#include "../common/d3d10_common.h"
static void gfx_display_d3d10_blend_begin(void *data)
@ -240,23 +239,6 @@ static void gfx_display_d3d10_draw_pipeline(gfx_display_ctx_draw_t* draw,
}
}
static bool gfx_display_d3d10_font_init_first(
void** font_handle,
void* video_data,
const char* font_path,
float menu_font_size,
bool is_threaded)
{
font_data_t** handle = (font_data_t**)font_handle;
font_data_t* new_handle = font_driver_init_first(
video_data, font_path, menu_font_size, true,
is_threaded, FONT_DRIVER_RENDER_D3D10_API);
if (!new_handle)
return false;
*handle = new_handle;
return true;
}
void gfx_display_d3d10_scissor_begin(void *data,
unsigned video_width, unsigned video_height,
int x, int y, unsigned width, unsigned height)
@ -300,7 +282,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d10 = {
NULL, /* get_default_mvp */
NULL, /* get_default_vertices */
NULL, /* get_default_tex_coords */
gfx_display_d3d10_font_init_first,
FONT_DRIVER_RENDER_D3D10_API,
GFX_VIDEO_DRIVER_DIRECT3D10,
"d3d10",
true,

View File

@ -24,7 +24,6 @@
#include "../gfx_display.h"
#include "../../retroarch.h"
#include "../font_driver.h"
#include "../common/d3d11_common.h"
static void gfx_display_d3d11_blend_begin(void *data)
@ -271,23 +270,6 @@ static void gfx_display_d3d11_draw_pipeline(gfx_display_ctx_draw_t *draw,
}
}
static bool gfx_display_d3d11_font_init_first(
void** font_handle,
void* video_data,
const char* font_path,
float menu_font_size,
bool is_threaded)
{
font_data_t** handle = (font_data_t**)font_handle;
font_data_t* new_handle = font_driver_init_first(
video_data, font_path, menu_font_size, true,
is_threaded, FONT_DRIVER_RENDER_D3D11_API);
if (!new_handle)
return false;
*handle = new_handle;
return true;
}
void gfx_display_d3d11_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
@ -333,7 +315,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d11 = {
NULL, /* get_default_mvp */
NULL, /* get_default_vertices */
NULL, /* get_default_tex_coords */
gfx_display_d3d11_font_init_first,
FONT_DRIVER_RENDER_D3D11_API,
GFX_VIDEO_DRIVER_DIRECT3D11,
"d3d11",
true,

View File

@ -24,7 +24,6 @@
#include "../gfx_display.h"
#include "../../retroarch.h"
#include "../font_driver.h"
#include "../common/d3d12_common.h"
static void gfx_display_d3d12_blend_begin(void *data)
@ -247,22 +246,6 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw,
d3d12->queue.cmd, ROOT_ID_UBO, d3d12->ubo_view.BufferLocation);
}
static bool gfx_display_d3d12_font_init_first(
void** font_handle,
void* video_data,
const char* font_path,
float menu_font_size,
bool is_threaded)
{
font_data_t** handle = (font_data_t**)font_handle;
font_data_t* new_handle = font_driver_init_first(
video_data, font_path, menu_font_size, true, is_threaded, FONT_DRIVER_RENDER_D3D12_API);
if (!new_handle)
return false;
*handle = new_handle;
return true;
}
void gfx_display_d3d12_scissor_begin(void *data,
unsigned video_width, unsigned video_height,
int x, int y, unsigned width, unsigned height)
@ -307,7 +290,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d12 = {
NULL, /* get_default_mvp */
NULL, /* get_default_vertices */
NULL, /* get_default_tex_coords */
gfx_display_d3d12_font_init_first,
FONT_DRIVER_RENDER_D3D12_API,
GFX_VIDEO_DRIVER_DIRECT3D12,
"d3d12",
true,

View File

@ -234,20 +234,6 @@ static void gfx_display_d3d8_draw(gfx_display_ctx_draw_t *draw,
d3d->menu_display.offset += draw->coords->vertices;
}
static bool gfx_display_d3d8_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
if (!(*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_D3D8_API)))
return false;
return true;
}
gfx_display_ctx_driver_t gfx_display_ctx_d3d8 = {
gfx_display_d3d8_draw,
NULL, /* draw_pipeline */
@ -256,7 +242,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d8 = {
gfx_display_d3d8_get_default_mvp,
gfx_display_d3d8_get_default_vertices,
gfx_display_d3d8_get_default_tex_coords,
gfx_display_d3d8_font_init_first,
FONT_DRIVER_RENDER_D3D8_API,
GFX_VIDEO_DRIVER_DIRECT3D8,
"d3d8",
false,

View File

@ -264,20 +264,6 @@ static void gfx_display_d3d9_cg_draw_pipeline(gfx_display_ctx_draw_t *draw,
}
}
static bool gfx_display_d3d9_cg_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float menu_font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
if (!(*handle = font_driver_init_first(video_data,
font_path, menu_font_size, true,
is_threaded,
FONT_DRIVER_RENDER_D3D9_API)))
return false;
return true;
}
void gfx_display_d3d9_cg_scissor_begin(
void *data,
unsigned video_width, unsigned video_height,
@ -322,7 +308,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d9_cg = {
gfx_display_d3d9_cg_get_default_mvp,
gfx_display_d3d9_cg_get_default_vertices,
gfx_display_d3d9_cg_get_default_tex_coords,
gfx_display_d3d9_cg_font_init_first,
FONT_DRIVER_RENDER_D3D9_API,
GFX_VIDEO_DRIVER_DIRECT3D9_CG,
"d3d9_cg",
false,

View File

@ -271,20 +271,6 @@ static void gfx_display_d3d9_hlsl_draw_pipeline(
}
}
static bool gfx_display_d3d9_hlsl_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float menu_font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
if (!(*handle = font_driver_init_first(video_data,
font_path, menu_font_size, true,
is_threaded,
FONT_DRIVER_RENDER_D3D9_API)))
return false;
return true;
}
void gfx_display_d3d9_hlsl_scissor_begin(
void *data,
unsigned video_width, unsigned video_height,
@ -329,7 +315,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_d3d9_hlsl = {
gfx_display_d3d9_hlsl_get_default_mvp,
gfx_display_d3d9_hlsl_get_default_vertices,
gfx_display_d3d9_hlsl_get_default_tex_coords,
gfx_display_d3d9_hlsl_font_init_first,
FONT_DRIVER_RENDER_D3D9_API,
GFX_VIDEO_DRIVER_DIRECT3D9_HLSL,
"d3d9_hlsl",
false,

View File

@ -21,7 +21,6 @@
#include <retro_miscellaneous.h>
#include "../../config.def.h"
#include "../font_driver.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
@ -114,20 +113,6 @@ static void gfx_display_gdi_draw(gfx_display_ctx_draw_t *draw,
}
}
static bool gfx_display_gdi_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float gdi_font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
if (!(*handle = font_driver_init_first(video_data,
font_path, gdi_font_size, true,
is_threaded,
FONT_DRIVER_RENDER_GDI)))
return false;
return true;
}
gfx_display_ctx_driver_t gfx_display_ctx_gdi = {
gfx_display_gdi_draw,
NULL, /* draw_pipeline */
@ -136,7 +121,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_gdi = {
NULL, /* get_default_mvp */
gfx_display_gdi_get_default_vertices,
gfx_display_gdi_get_default_tex_coords,
gfx_display_gdi_font_init_first,
FONT_DRIVER_RENDER_GDI,
GFX_VIDEO_DRIVER_GDI,
"gdi",
false,

View File

@ -21,7 +21,6 @@
#endif
#include "../../retroarch.h"
#include "../font_driver.h"
#include "../common/gl1_common.h"
#include "../gfx_display.h"
@ -167,20 +166,6 @@ static void gfx_display_gl1_draw(gfx_display_ctx_draw_t *draw,
gl1->coords.color = gl1->white_color_ptr;
}
static bool gfx_display_gl1_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float menu_font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
if (!(*handle = font_driver_init_first(video_data,
font_path, menu_font_size, true,
is_threaded,
FONT_DRIVER_RENDER_OPENGL1_API)))
return false;
return true;
}
static void gfx_display_gl1_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
@ -208,7 +193,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_gl1 = {
gfx_display_gl1_get_default_mvp,
gfx_display_gl1_get_default_vertices,
gfx_display_gl1_get_default_tex_coords,
gfx_display_gl1_font_init_first,
FONT_DRIVER_RENDER_OPENGL1_API,
GFX_VIDEO_DRIVER_OPENGL1,
"gl1",
false,

View File

@ -20,7 +20,6 @@
#endif
#include "../../retroarch.h"
#include "../font_driver.h"
#include "../common/gl2_common.h"
#include "../gfx_display.h"
@ -331,20 +330,6 @@ static void gfx_display_gl2_draw_pipeline(
#endif
}
static bool gfx_display_gl2_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float menu_font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
if (!(*handle = font_driver_init_first(video_data,
font_path, menu_font_size, true,
is_threaded,
FONT_DRIVER_RENDER_OPENGL_API)))
return false;
return true;
}
static void gfx_display_gl2_scissor_begin(
void *data,
unsigned video_width,
@ -387,7 +372,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_gl = {
gfx_display_gl2_get_default_mvp,
gfx_display_gl2_get_default_vertices,
gfx_display_gl2_get_default_tex_coords,
gfx_display_gl2_font_init_first,
FONT_DRIVER_RENDER_OPENGL_API,
GFX_VIDEO_DRIVER_OPENGL,
"gl",
false,

View File

@ -24,7 +24,6 @@
#include "../gfx_display.h"
#include "../font_driver.h"
#include "../../retroarch.h"
static const float gl3_vertexes[] = {
@ -293,22 +292,6 @@ static void gfx_display_gl3_blend_end(void *data)
glDisable(GL_BLEND);
}
static bool gfx_display_gl3_font_init_first(
void **font_handle, void *video_data, const char *font_path,
float menu_font_size, bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
*handle = font_driver_init_first(video_data,
font_path, menu_font_size, true,
is_threaded,
FONT_DRIVER_RENDER_OPENGL_CORE_API);
if (*handle)
return true;
return false;
}
static void gfx_display_gl3_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
@ -334,7 +317,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_gl3 = {
gfx_display_gl3_get_default_mvp,
gfx_display_gl3_get_default_vertices,
gfx_display_gl3_get_default_tex_coords,
gfx_display_gl3_font_init_first,
FONT_DRIVER_RENDER_OPENGL_CORE_API,
GFX_VIDEO_DRIVER_OPENGL_CORE,
"glcore",
false,

View File

@ -21,7 +21,6 @@
#include "../gfx_display.h"
#include "../font_driver.h"
#include "../../retroarch.h"
#import "../common/metal_common.h"
@ -113,23 +112,6 @@ static void gfx_display_metal_scissor_end(void *data,
[md.display clearScissorRect];
}
static bool gfx_display_metal_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t **)font_handle;
*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_METAL_API);
if (*handle)
return true;
return false;
}
gfx_display_ctx_driver_t gfx_display_ctx_metal = {
.draw = gfx_display_metal_draw,
.draw_pipeline = gfx_display_metal_draw_pipeline,
@ -138,7 +120,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_metal = {
.get_default_mvp = gfx_display_metal_get_default_mvp,
.get_default_vertices = gfx_display_metal_get_default_vertices,
.get_default_tex_coords = gfx_display_metal_get_default_tex_coords,
.font_init_first = gfx_display_metal_font_init_first,
.font_type = FONT_DRIVER_RENDER_METAL_API,
.type = GFX_VIDEO_DRIVER_METAL,
.ident = "metal",
.handles_transform = NO,

View File

@ -23,7 +23,6 @@
#include "../../retroarch.h"
#include "../common/rsx_common.h"
#include "../font_driver.h"
static const float rsx_vertexes[] = {
0, 0,
@ -132,19 +131,6 @@ static void gfx_display_rsx_draw(gfx_display_ctx_draw_t *draw,
rsxDrawVertexArray(rsx->context, GCM_TYPE_TRIANGLE_STRIP, 0, draw->coords->vertices);
}
static bool gfx_display_rsx_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_RSX);
return *handle;
}
static void gfx_display_rsx_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
@ -196,7 +182,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_rsx = {
gfx_display_rsx_get_default_mvp,
gfx_display_rsx_get_default_vertices,
gfx_display_rsx_get_default_tex_coords,
gfx_display_rsx_font_init_first,
FONT_DRIVER_RENDER_RSX,
GFX_VIDEO_DRIVER_RSX,
"rsx",
true,

View File

@ -17,7 +17,6 @@
#include <queues/message_queue.h>
#include <retro_miscellaneous.h>
#include "../font_driver.h"
#include "../../retroarch.h"
#include "../gfx_display.h"
@ -25,19 +24,6 @@
static void gfx_display_switch_draw(gfx_display_ctx_draw_t *draw,
void *data, unsigned video_width, unsigned video_height) { }
static bool gfx_display_switch_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_SWITCH);
return *handle;
}
static const float *gfx_display_switch_get_default_vertices(void)
{
static float dummy[16] = {0.0f};
@ -58,7 +44,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_switch = {
NULL, /* get_default_mvp */
gfx_display_switch_get_default_vertices,
gfx_display_switch_get_default_tex_coords,
gfx_display_switch_font_init_first,
FONT_DRIVER_RENDER_SWITCH,
GFX_VIDEO_DRIVER_SWITCH,
"switch",
false,

View File

@ -24,7 +24,6 @@
#include "../gfx_display.h"
#include "../../retroarch.h"
#include "../font_driver.h"
#include "../common/vita2d_common.h"
#include <defines/psp_defines.h>
@ -131,19 +130,6 @@ static void gfx_display_vita2d_draw(gfx_display_ctx_draw_t *draw,
}
}
static bool gfx_display_vita2d_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_VITA2D);
return *handle;
}
static void gfx_display_vita2d_scissor_begin(void *data,
unsigned video_width,
unsigned video_height,
@ -172,7 +158,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_vita2d = {
gfx_display_vita2d_get_default_mvp,
gfx_display_vita2d_get_default_vertices,
gfx_display_vita2d_get_default_tex_coords,
gfx_display_vita2d_font_init_first,
FONT_DRIVER_RENDER_VITA2D,
GFX_VIDEO_DRIVER_VITA2D,
"vita2d",
true,

View File

@ -22,7 +22,6 @@
#include "../gfx_display.h"
#include "../font_driver.h"
#include "../../retroarch.h"
#include "../common/vulkan_common.h"
@ -287,22 +286,6 @@ static void gfx_display_vk_blend_end(void *data)
vk->display.blend = false;
}
static bool gfx_display_vk_font_init_first(
void **font_handle, void *video_data, const char *font_path,
float menu_font_size, bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
*handle = font_driver_init_first(video_data,
font_path, menu_font_size, true,
is_threaded,
FONT_DRIVER_RENDER_VULKAN_API);
if (*handle)
return true;
return false;
}
static void gfx_display_vk_scissor_begin(
void *data,
unsigned video_width,
@ -341,7 +324,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_vulkan = {
gfx_display_vk_get_default_mvp,
gfx_display_vk_get_default_vertices,
gfx_display_vk_get_default_tex_coords,
gfx_display_vk_font_init_first,
FONT_DRIVER_RENDER_VULKAN_API,
GFX_VIDEO_DRIVER_VULKAN,
"vulkan",
false,

View File

@ -23,7 +23,6 @@
#include "../gfx_display.h"
#include "../../retroarch.h"
#include "../font_driver.h"
#include "../common/gx2_common.h"
#include "../../wiiu/system/memory.h"
#include "../../wiiu/wiiu_dbg.h"
@ -263,19 +262,6 @@ static void gfx_display_wiiu_draw_pipeline(
GX2SetPixelUniformBlock(1, sizeof(*wiiu->menu_shader_ubo), wiiu->menu_shader_ubo);
}
static bool gfx_display_wiiu_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded)
{
font_data_t **handle = (font_data_t**)font_handle;
*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_WIIU);
return *handle;
}
static void gfx_display_wiiu_scissor_begin(
void *data,
unsigned video_width,
@ -303,7 +289,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_wiiu = {
NULL, /* get_default_mvp */
NULL, /* get_default_vertices */
NULL, /* get_default_tex_coords */
gfx_display_wiiu_font_init_first,
FONT_DRIVER_RENDER_WIIU,
GFX_VIDEO_DRIVER_WIIU,
"gx2",
true,

View File

@ -43,16 +43,14 @@ gfx_display_t *disp_get_ptr(void)
return &dispgfx_st;
}
static bool gfx_display_null_font_init_first(
static bool gfx_display_font_init_first(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded)
bool is_threaded, enum font_driver_render_api font_type)
{
font_data_t **handle = (font_data_t**)font_handle;
return ((*handle = font_driver_init_first(video_data,
font_path, font_size, true,
is_threaded,
FONT_DRIVER_RENDER_DONT_CARE)));
font_path, font_size, true, is_threaded, font_type)));
}
static const float *null_get_default_matrix(void)
@ -69,7 +67,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_null = {
NULL, /* get_default_mvp */
null_get_default_matrix,
null_get_default_matrix,
gfx_display_null_font_init_first,
FONT_DRIVER_RENDER_DONT_CARE,
GFX_VIDEO_DRIVER_GENERIC,
"null",
false,
@ -487,9 +485,9 @@ font_data_t *gfx_display_font_file(
if (font_size < 2.0f)
font_size = 2.0f;
if (!dispctx->font_init_first((void**)&font_data,
if (!gfx_display_font_init_first((void**)&font_data,
video_driver_get_ptr(),
fontpath, font_size, is_threaded))
fontpath, font_size, is_threaded, dispctx->font_type))
return NULL;
return font_data;

View File

@ -137,11 +137,7 @@ typedef struct gfx_display_ctx_driver
const float *(*get_default_vertices)(void);
/* Get the default texture coordinates matrix */
const float *(*get_default_tex_coords)(void);
/* Initialize the first compatible font driver for this menu driver. */
bool (*font_init_first)(
void **font_handle, void *video_data,
const char *font_path, float font_size,
bool is_threaded);
enum font_driver_render_api font_type;
enum gfx_display_driver_type type;
const char *ident;
bool handles_transform;