(D3D9 PC) Go through font context driver now

This commit is contained in:
twinaphex 2014-01-18 21:51:30 +01:00
parent 13620ab16d
commit 7cbfb14791
6 changed files with 28 additions and 52 deletions

View File

@ -91,7 +91,9 @@ RECT d3d_monitor_rect(void *data)
static void d3d_deinitialize(void *data)
{
D3DVideo *d3d = reinterpret_cast<D3DVideo*>(data);
d3d_deinit_font(d3d);
if (d3d->font_ctx && d3d->font_ctx->deinit)
d3d->font_ctx->deinit(d3d);
d3d_deinit_chain(d3d);
#ifdef HAVE_CG
d3d_deinit_shader(d3d);
@ -211,7 +213,8 @@ static bool d3d_initialize(void *data, const video_info_t *info)
return false;
}
if (!d3d_init_font(d3d))
d3d->font_ctx = d3d_font_init_first(d3d, g_settings.video.font_path, g_settings.video.font_size);
if (!d3d->font_ctx)
{
RARCH_ERR("Failed to initialize font.\n");
return false;
@ -473,7 +476,8 @@ static bool d3d_frame(void *data, const void *frame,
return false;
}
d3d_render_msg(d3d, msg, NULL);
if (d3d->font_ctx && d3d->font_ctx->render_msg)
d3d->font_ctx->render_msg(d3d, msg, NULL);
#ifdef HAVE_MENU
if (d3d->rgui.enabled)
@ -832,15 +836,6 @@ static void d3d_apply_state_changes(void *data)
d3d->should_resize = true;
}
static void d3d_render_msg(void *data, const char *msg, void *userdata)
{
D3DVideo *d3d = reinterpret_cast<D3DVideo*>(data);
d3d_font_msg(d3d, msg, userdata);
if (userdata)
d3d_set_font_rect(d3d, NULL);
}
static void d3d_set_osd_msg(void *data, const char *msg, void *userdata)
{
font_params_t *params = (font_params_t*)userdata;
@ -849,7 +844,8 @@ static void d3d_set_osd_msg(void *data, const char *msg, void *userdata)
if (params)
d3d_set_font_rect(d3d, params);
d3d_render_msg(d3d, msg, params);
if (d3d->font_ctx && d3d->font_ctx->render_msg)
d3d->font_ctx->render_msg(d3d, msg, params);
}
static void d3d_show_mouse(void *data, bool state)

View File

@ -39,6 +39,7 @@
#include "../../driver.h"
#include "../shader_parse.h"
#include "../fonts/d3d_font.h"
#include "../gfx_context.h"
#include "../gfx_common.h"
@ -81,15 +82,13 @@ bool d3d_init_singlepass(void *data);
bool d3d_init_multipass(void *data);
bool d3d_init_chain(void *data, const video_info_t *video_info);
void d3d_deinit_chain(void *data);
bool d3d_init_font(void *data);
void d3d_deinit_font(void *data);
void d3d_font_msg(void *data, const char *msg, void *userdata);
void d3d_show_cursor(void *data, bool state);
void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp);
bool d3d_alive_func(void *data);
struct D3DVideo
{
const d3d_font_renderer_t *font_ctx;
const gfx_ctx_driver_t *ctx_driver;
bool should_resize;

View File

@ -419,34 +419,6 @@ void d3d_deinit_chain(void *data)
d3d->chain = NULL;
}
bool d3d_init_font(void *data)
{
D3DVideo *d3d = reinterpret_cast<D3DVideo*>(data);
D3DXFONT_DESC desc = {
static_cast<int>(g_settings.video.font_size), 0, 400, 0,
false, DEFAULT_CHARSET,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_PITCH,
"Verdana" // Hardcode ftl :(
};
uint32_t r = static_cast<uint32_t>(g_settings.video.msg_color_r * 255) & 0xff;
uint32_t g = static_cast<uint32_t>(g_settings.video.msg_color_g * 255) & 0xff;
uint32_t b = static_cast<uint32_t>(g_settings.video.msg_color_b * 255) & 0xff;
d3d->font_color = D3DCOLOR_XRGB(r, g, b);
return SUCCEEDED(D3DXCreateFontIndirect(d3d->dev, &desc, &d3d->font));
}
void d3d_deinit_font(void *data)
{
D3DVideo *d3d = reinterpret_cast<D3DVideo*>(data);
if (d3d->font)
d3d->font->Release();
d3d->font = NULL;
}
static void gfx_ctx_d3d_show_mouse(bool state)
{
#ifdef HAVE_WINDOW

View File

@ -14,6 +14,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../d3d9/d3d9.hpp"
#include "d3d_font.h"
#include "../gfx_common.h"
#include "../../general.h"
@ -48,7 +49,7 @@ static void d3dfonts_w32_deinit_font(void *data)
d3d->font = NULL;
}
static void d3dfonts_w32_render_msg(void *data, const char *msg, void *parms)
static void d3dfonts_w32_render_msg(void *data, const char *msg, void *userdata)
{
D3DVideo *d3d = reinterpret_cast<D3DVideo*>(data);
font_params_t *params = (font_params_t*)userdata;
@ -73,7 +74,7 @@ static void d3dfonts_w32_render_msg(void *data, const char *msg, void *parms)
}
}
const d3d_font_renderer_t d3d_xdk1_font = {
const d3d_font_renderer_t d3d_win32_font = {
d3dfonts_w32_init_font,
d3dfonts_w32_deinit_font,
d3dfonts_w32_render_msg,

View File

@ -226,6 +226,8 @@
<ClCompile Include="..\..\gfx\d3d9\d3d9_pc.cpp" />
<ClCompile Include="..\..\gfx\d3d9\render_chain.cpp" />
<ClCompile Include="..\..\gfx\fonts\bitmapfont.c" />
<ClCompile Include="..\..\gfx\fonts\d3d_font.c" />
<ClCompile Include="..\..\gfx\fonts\d3d_w32_font.c" />
<ClCompile Include="..\..\gfx\fonts\fonts.c" />
<ClCompile Include="..\..\gfx\fonts\gl_font.c" />
<ClCompile Include="..\..\gfx\fonts\gl_raster_font.c" />

View File

@ -135,9 +135,6 @@
<ClCompile Include="..\..\gfx\context\win32_common.c">
<Filter>input</Filter>
</ClCompile>
<ClCompile Include="..\..\gfx\fonts\fonts.c">
<Filter>gfx\fonts</Filter>
</ClCompile>
<ClCompile Include="..\..\gfx\scaler\pixconv.c">
<Filter>gfx\scaler</Filter>
</ClCompile>
@ -150,9 +147,6 @@
<ClCompile Include="..\..\gfx\scaler\filter.c">
<Filter>gfx\scaler</Filter>
</ClCompile>
<ClCompile Include="..\..\gfx\fonts\bitmapfont.c">
<Filter>gfx\fonts</Filter>
</ClCompile>
<ClCompile Include="..\..\gfx\d3d9\render_chain.cpp">
<Filter>gfx\d3d9</Filter>
</ClCompile>
@ -219,6 +213,18 @@
<ClCompile Include="..\..\deps\rzlib\unzip.c">
<Filter>deps\zlib</Filter>
</ClCompile>
<ClCompile Include="..\..\gfx\fonts\d3d_w32_font.c">
<Filter>gfx\fonts</Filter>
</ClCompile>
<ClCompile Include="..\..\gfx\fonts\d3d_font.c">
<Filter>gfx\fonts</Filter>
</ClCompile>
<ClCompile Include="..\..\gfx\fonts\fonts.c">
<Filter>gfx\fonts</Filter>
</ClCompile>
<ClCompile Include="..\..\gfx\fonts\bitmapfont.c">
<Filter>gfx\fonts</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />