2015-01-12 22:38:39 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2017-12-12 07:55:31 +00:00
|
|
|
*
|
2015-01-12 22:38:39 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <xtl.h>
|
2015-09-16 03:53:34 +00:00
|
|
|
|
2016-09-11 13:07:07 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
2016-12-02 00:03:14 +00:00
|
|
|
#include "../drivers/d3d.h"
|
|
|
|
|
2015-04-03 18:36:19 +00:00
|
|
|
#include "../font_driver.h"
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-03-29 22:29:02 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
d3d_video_t *d3d;
|
|
|
|
XFONT *debug_font;
|
2015-04-10 08:11:43 +00:00
|
|
|
D3DSurface *surf;
|
2015-03-29 22:29:02 +00:00
|
|
|
} xfonts_t;
|
|
|
|
|
2015-03-29 22:41:42 +00:00
|
|
|
static void *xfonts_init_font(void *video_data,
|
2017-01-25 13:47:24 +00:00
|
|
|
const char *font_path, float font_size,
|
|
|
|
bool is_threaded)
|
2015-01-12 22:38:39 +00:00
|
|
|
{
|
2015-03-30 00:10:17 +00:00
|
|
|
xfonts_t *xfont = (xfonts_t*)calloc(1, sizeof(*xfont));
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-03-30 00:10:17 +00:00
|
|
|
if (!xfont)
|
2015-03-29 22:41:42 +00:00
|
|
|
return NULL;
|
2015-03-29 22:29:02 +00:00
|
|
|
|
2015-03-29 22:41:42 +00:00
|
|
|
(void)font_path;
|
|
|
|
(void)font_size;
|
2015-03-29 22:29:02 +00:00
|
|
|
|
2015-03-30 00:10:17 +00:00
|
|
|
xfont->d3d = (d3d_video_t*)video_data;
|
2015-03-29 22:29:02 +00:00
|
|
|
|
2015-03-30 00:10:17 +00:00
|
|
|
XFONT_OpenDefaultFont(&xfont->debug_font);
|
2018-01-03 13:26:40 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2015-03-30 00:10:17 +00:00
|
|
|
xfont->debug_font->SetBkMode(XFONT_TRANSPARENT);
|
|
|
|
xfont->debug_font->SetBkColor(D3DCOLOR_ARGB(100,0,0,0));
|
|
|
|
xfont->debug_font->SetTextHeight(14);
|
2018-01-03 13:26:40 +00:00
|
|
|
xfont->debug_font->SetTextAntialiasLevel(
|
|
|
|
xfont->debug_font->GetTextAntialiasLevel());
|
|
|
|
#else
|
|
|
|
XFONT_SetBkMode(xfont->debug_font, XFONT_TRANSPARENT);
|
|
|
|
XFONT_SetBkColor(xfont->debug_font, D3DCOLOR_ARGB(100,0,0,0));
|
|
|
|
XFONT_SetTextHeight(xfont->debug_font, 14);
|
2018-01-03 13:28:07 +00:00
|
|
|
XFONT_SetTextAntialiasLevel(xfont->debug_font,
|
|
|
|
XFONT_GetTextAntialiasLevel(xfont->debug_font));
|
2018-01-03 13:26:40 +00:00
|
|
|
#endif
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-03-30 00:10:17 +00:00
|
|
|
return xfont;
|
2015-01-12 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
2017-01-25 13:47:24 +00:00
|
|
|
static void xfonts_free_font(void *data, bool is_threaded)
|
2015-01-12 22:38:39 +00:00
|
|
|
{
|
2017-01-14 20:02:30 +00:00
|
|
|
xfonts_t *font = (xfonts_t*)data;
|
|
|
|
|
|
|
|
if (font)
|
|
|
|
free(font);
|
2017-12-12 07:55:31 +00:00
|
|
|
|
2017-01-14 20:02:30 +00:00
|
|
|
font = NULL;
|
2015-01-12 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
2017-01-19 15:30:40 +00:00
|
|
|
static void xfonts_render_msg(
|
|
|
|
video_frame_info_t *video_info,
|
|
|
|
void *data, const char *msg,
|
2015-03-29 19:59:01 +00:00
|
|
|
const void *userdata)
|
2015-01-12 22:38:39 +00:00
|
|
|
{
|
|
|
|
wchar_t str[PATH_MAX_LENGTH];
|
|
|
|
float x, y;
|
2015-03-29 19:59:01 +00:00
|
|
|
const struct font_params *params = (const struct font_params*)userdata;
|
2018-01-03 13:26:40 +00:00
|
|
|
xfonts_t *xfonts = (xfonts_t*)data;
|
2015-03-29 22:29:02 +00:00
|
|
|
|
2015-01-12 22:38:39 +00:00
|
|
|
if (params)
|
|
|
|
{
|
|
|
|
x = params->x;
|
|
|
|
y = params->y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-19 15:30:40 +00:00
|
|
|
x = video_info->font_msg_pos_x;
|
|
|
|
y = video_info->font_msg_pos_y;
|
2015-01-12 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
2018-01-03 15:25:45 +00:00
|
|
|
d3d_device_get_backbuffer(xfonts->d3d->dev, -1, 0, D3DBACKBUFFER_TYPE_MONO, &xfonts->surf);
|
2015-01-12 22:38:39 +00:00
|
|
|
|
|
|
|
mbstowcs(str, msg, sizeof(str) / sizeof(wchar_t));
|
2018-01-03 13:26:40 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2015-04-10 08:11:43 +00:00
|
|
|
xfonts->debug_font->TextOut(xfonts->surf, str, (unsigned)-1, x, y);
|
2018-01-03 13:26:40 +00:00
|
|
|
#else
|
|
|
|
XFONT_TextOut(xfonts->debug_font, xfonts->surf, str, (unsigned)-1, x, y);
|
|
|
|
#endif
|
2018-01-03 13:10:14 +00:00
|
|
|
d3d_surface_free(xfonts->surf);
|
2015-01-12 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-29 22:55:39 +00:00
|
|
|
font_renderer_t d3d_xdk1_font = {
|
2015-01-12 22:38:39 +00:00
|
|
|
xfonts_init_font,
|
2015-03-29 20:01:52 +00:00
|
|
|
xfonts_free_font,
|
2015-01-12 22:38:39 +00:00
|
|
|
xfonts_render_msg,
|
2015-04-21 15:17:44 +00:00
|
|
|
"xfonts",
|
2015-04-21 15:13:55 +00:00
|
|
|
NULL, /* get_glyph */
|
|
|
|
NULL, /* bind_block */
|
|
|
|
NULL, /* flush */
|
2015-05-16 14:32:16 +00:00
|
|
|
NULL /* get_message_width */
|
2015-01-12 22:38:39 +00:00
|
|
|
};
|