mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
(D3D) Start using gfx_ctx_get_ptr
This commit is contained in:
parent
5d60938560
commit
5b96c82607
107
gfx/d3d/d3d.cpp
107
gfx/d3d/d3d.cpp
@ -323,26 +323,28 @@ static void d3d_calculate_rect(d3d_video_t *d3d,
|
|||||||
|
|
||||||
static void d3d_set_nonblock_state(void *data, bool state)
|
static void d3d_set_nonblock_state(void *data, bool state)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
|
|
||||||
if (!d3d)
|
if (!d3d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d3d->video_info.vsync = !state;
|
d3d->video_info.vsync = !state;
|
||||||
|
|
||||||
if (d3d->ctx_driver && d3d->ctx_driver->swap_interval)
|
if (ctx && ctx->swap_interval)
|
||||||
d3d->ctx_driver->swap_interval(d3d, state ? 0 : 1);
|
ctx->swap_interval(d3d, state ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool d3d_alive(void *data)
|
static bool d3d_alive(void *data)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
bool resize = false;
|
bool resize = false;
|
||||||
runloop_t *runloop = rarch_main_get_ptr();
|
runloop_t *runloop = rarch_main_get_ptr();
|
||||||
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
|
|
||||||
if (d3d->ctx_driver && d3d->ctx_driver->check_window)
|
if (ctx && ctx->check_window)
|
||||||
d3d->ctx_driver->check_window(d3d, &quit, &resize,
|
ctx->check_window(d3d, &quit, &resize,
|
||||||
&d3d->screen_width, &d3d->screen_height, runloop->frames.video.count);
|
&d3d->screen_width, &d3d->screen_height, runloop->frames.video.count);
|
||||||
|
|
||||||
if (quit)
|
if (quit)
|
||||||
@ -355,25 +357,31 @@ static bool d3d_alive(void *data)
|
|||||||
|
|
||||||
static bool d3d_focus(void *data)
|
static bool d3d_focus(void *data)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
if (d3d && d3d->ctx_driver && d3d->ctx_driver->has_focus)
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
return d3d->ctx_driver->has_focus(d3d);
|
|
||||||
|
if (d3d && ctx && ctx->has_focus)
|
||||||
|
return ctx->has_focus(d3d);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool d3d_suppress_screensaver(void *data, bool enable)
|
static bool d3d_suppress_screensaver(void *data, bool enable)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
if (d3d && d3d->ctx_driver && d3d->ctx_driver->suppress_screensaver)
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
return d3d->ctx_driver->suppress_screensaver(d3d, enable);
|
|
||||||
|
if (d3d && ctx && ctx->suppress_screensaver)
|
||||||
|
return ctx->suppress_screensaver(d3d, enable);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool d3d_has_windowed(void *data)
|
static bool d3d_has_windowed(void *data)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
if (d3d && d3d->ctx_driver && d3d->ctx_driver->has_windowed)
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
return d3d->ctx_driver->has_windowed(d3d);
|
|
||||||
|
if (d3d && ctx && ctx->has_windowed)
|
||||||
|
return ctx->has_windowed(d3d);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,8 +446,9 @@ static bool d3d_construct(d3d_video_t *d3d,
|
|||||||
void **input_data)
|
void **input_data)
|
||||||
{
|
{
|
||||||
unsigned full_x, full_y;
|
unsigned full_x, full_y;
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
|
|
||||||
d3d->should_resize = false;
|
d3d->should_resize = false;
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
@ -497,8 +506,8 @@ static bool d3d_construct(d3d_video_t *d3d,
|
|||||||
(int)(mon_rect.right - mon_rect.left),
|
(int)(mon_rect.right - mon_rect.left),
|
||||||
(int)(mon_rect.bottom - mon_rect.top));
|
(int)(mon_rect.bottom - mon_rect.top));
|
||||||
#else
|
#else
|
||||||
if (d3d->ctx_driver && d3d->ctx_driver->get_video_size)
|
if (ctx && ctx->get_video_size)
|
||||||
d3d->ctx_driver->get_video_size(d3d, &full_x, &full_y);
|
ctx->get_video_size(d3d, &full_x, &full_y);
|
||||||
#endif
|
#endif
|
||||||
d3d->screen_width = info->fullscreen ? full_x : info->width;
|
d3d->screen_width = info->fullscreen ? full_x : info->width;
|
||||||
d3d->screen_height = info->fullscreen ? full_y : info->height;
|
d3d->screen_height = info->fullscreen ? full_y : info->height;
|
||||||
@ -537,8 +546,8 @@ static bool d3d_construct(d3d_video_t *d3d,
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (d3d && d3d->ctx_driver && d3d->ctx_driver->show_mouse)
|
if (d3d && ctx && ctx->show_mouse)
|
||||||
d3d->ctx_driver->show_mouse(d3d, !info->fullscreen
|
ctx->show_mouse(d3d, !info->fullscreen
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
|| d3d->overlays_enabled
|
|| d3d->overlays_enabled
|
||||||
#endif
|
#endif
|
||||||
@ -583,9 +592,8 @@ static bool d3d_construct(d3d_video_t *d3d,
|
|||||||
if (!d3d_initialize(d3d, &d3d->video_info))
|
if (!d3d_initialize(d3d, &d3d->video_info))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (input && input_data &&
|
if (input && input_data && ctx && ctx->input_driver)
|
||||||
d3d->ctx_driver && d3d->ctx_driver->input_driver)
|
ctx->input_driver(d3d, input, input_data);
|
||||||
d3d->ctx_driver->input_driver(d3d, input, input_data);
|
|
||||||
|
|
||||||
RARCH_LOG("[D3D]: Init complete.\n");
|
RARCH_LOG("[D3D]: Init complete.\n");
|
||||||
return true;
|
return true;
|
||||||
@ -616,10 +624,11 @@ static void d3d_set_rotation(void *data, unsigned rot)
|
|||||||
|
|
||||||
static void d3d_show_mouse(void *data, bool state)
|
static void d3d_show_mouse(void *data, bool state)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
|
|
||||||
if (d3d && d3d->ctx_driver && d3d->ctx_driver->show_mouse)
|
if (d3d && ctx && ctx->show_mouse)
|
||||||
d3d->ctx_driver->show_mouse(d3d, state);
|
ctx->show_mouse(d3d, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gfx_ctx_driver_t *d3d_get_context(void *data)
|
static const gfx_ctx_driver_t *d3d_get_context(void *data)
|
||||||
@ -644,8 +653,9 @@ static const gfx_ctx_driver_t *d3d_get_context(void *data)
|
|||||||
static void *d3d_init(const video_info_t *info,
|
static void *d3d_init(const video_info_t *info,
|
||||||
const input_driver_t **input, void **input_data)
|
const input_driver_t **input, void **input_data)
|
||||||
{
|
{
|
||||||
d3d_video_t *vid = NULL;
|
d3d_video_t *vid = NULL;
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
|
const gfx_ctx_driver_t *ctx = NULL;
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
if (driver->video_data)
|
if (driver->video_data)
|
||||||
@ -676,8 +686,8 @@ static void *d3d_init(const video_info_t *info,
|
|||||||
if (!vid)
|
if (!vid)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
vid->ctx_driver = d3d_get_context(vid);
|
ctx = d3d_get_context(vid);
|
||||||
if (!vid->ctx_driver)
|
if (!ctx)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Default values */
|
/* Default values */
|
||||||
@ -694,6 +704,8 @@ static void *d3d_init(const video_info_t *info,
|
|||||||
vid->menu = NULL;
|
vid->menu = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
driver->video_context = ctx;
|
||||||
|
|
||||||
if (!d3d_construct(vid, info, input, input_data))
|
if (!d3d_construct(vid, info, input, input_data))
|
||||||
{
|
{
|
||||||
RARCH_ERR("[D3D]: Failed to init D3D.\n");
|
RARCH_ERR("[D3D]: Failed to init D3D.\n");
|
||||||
@ -710,12 +722,15 @@ static void *d3d_init(const video_info_t *info,
|
|||||||
error:
|
error:
|
||||||
if (vid)
|
if (vid)
|
||||||
free(vid);
|
free(vid);
|
||||||
|
if (driver)
|
||||||
|
driver->video_context = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void d3d_free(void *data)
|
static void d3d_free(void *data)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
|
|
||||||
if (!d3d)
|
if (!d3d)
|
||||||
return;
|
return;
|
||||||
@ -726,9 +741,9 @@ static void d3d_free(void *data)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
if (d3d->ctx_driver && d3d->ctx_driver->destroy)
|
if (ctx && ctx->destroy)
|
||||||
d3d->ctx_driver->destroy(d3d);
|
ctx->destroy(d3d);
|
||||||
d3d->ctx_driver = NULL;
|
ctx = NULL;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
@ -1434,7 +1449,8 @@ static bool d3d_overlay_load(void *data,
|
|||||||
static void d3d_overlay_enable(void *data, bool state)
|
static void d3d_overlay_enable(void *data, bool state)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||||
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
|
|
||||||
if (!d3d)
|
if (!d3d)
|
||||||
return;
|
return;
|
||||||
@ -1442,8 +1458,8 @@ static void d3d_overlay_enable(void *data, bool state)
|
|||||||
for (i = 0; i < d3d->overlays.size(); i++)
|
for (i = 0; i < d3d->overlays.size(); i++)
|
||||||
d3d->overlays_enabled = state;
|
d3d->overlays_enabled = state;
|
||||||
|
|
||||||
if (d3d && d3d->ctx_driver && d3d->ctx_driver->show_mouse)
|
if (d3d && ctx && ctx->show_mouse)
|
||||||
d3d->ctx_driver->show_mouse(d3d, state);
|
ctx->show_mouse(d3d, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void d3d_overlay_full_screen(void *data, bool enable)
|
static void d3d_overlay_full_screen(void *data, bool enable)
|
||||||
@ -1492,6 +1508,7 @@ static bool d3d_frame(void *data, const void *frame,
|
|||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
const font_renderer_t *font_ctx = d3d ? (const font_renderer_t*)d3d->font_driver : NULL;
|
const font_renderer_t *font_ctx = d3d ? (const font_renderer_t*)d3d->font_driver : NULL;
|
||||||
|
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
|
||||||
|
|
||||||
(void)i;
|
(void)i;
|
||||||
|
|
||||||
@ -1605,11 +1622,11 @@ static bool d3d_frame(void *data, const void *frame,
|
|||||||
|
|
||||||
RARCH_PERFORMANCE_STOP(d3d_frame);
|
RARCH_PERFORMANCE_STOP(d3d_frame);
|
||||||
|
|
||||||
if (d3d && d3d->ctx_driver && d3d->ctx_driver->update_window_title)
|
if (d3d && ctx && ctx->update_window_title)
|
||||||
d3d->ctx_driver->update_window_title(d3d);
|
ctx->update_window_title(d3d);
|
||||||
|
|
||||||
if (d3d && d3d->ctx_driver && d3d->ctx_driver->swap_buffers)
|
if (d3d && ctx && ctx->swap_buffers)
|
||||||
d3d->ctx_driver->swap_buffers(d3d);
|
ctx->swap_buffers(d3d);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,6 @@ typedef struct d3d_video
|
|||||||
{
|
{
|
||||||
const void *font_driver;
|
const void *font_driver;
|
||||||
void *font_handle;
|
void *font_handle;
|
||||||
const gfx_ctx_driver_t *ctx_driver;
|
|
||||||
bool should_resize;
|
bool should_resize;
|
||||||
bool quitting;
|
bool quitting;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user