Create some more gfx_ctx wrapper functions

This commit is contained in:
twinaphex 2015-04-09 21:58:58 +02:00
parent 4e24111f42
commit 82124d6181
3 changed files with 40 additions and 13 deletions

View File

@ -874,11 +874,7 @@ static void gl_set_rotation(void *data, unsigned rotation)
static void gl_set_video_mode(void *data, unsigned width, unsigned height, static void gl_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen) bool fullscreen)
{ {
gl_t *gl = (gl_t*)data; gfx_ctx_set_video_mode(data, width, height, fullscreen);
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (gl && ctx && ctx->set_video_mode)
ctx->set_video_mode(gl, width, height, fullscreen);
} }
#ifdef HAVE_FBO #ifdef HAVE_FBO
@ -1669,11 +1665,11 @@ static bool gl_frame(void *data, const void *frame,
!driver->nonblock_state && !runloop->is_slowmotion !driver->nonblock_state && !runloop->is_slowmotion
&& !runloop->is_paused) && !runloop->is_paused)
{ {
ctx->swap_buffers(gl); gfx_ctx_swap_buffers(gl);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
ctx->swap_buffers(gl); gfx_ctx_swap_buffers(gl);
#ifdef HAVE_GL_SYNC #ifdef HAVE_GL_SYNC
if (settings->video.hard_sync && gl->have_sync) if (settings->video.hard_sync && gl->have_sync)
@ -2493,12 +2489,7 @@ static bool gl_alive(void *data)
static bool gl_focus(void *data) static bool gl_focus(void *data)
{ {
gl_t *gl = (gl_t*)data; return gfx_ctx_focus(data);
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (!gl)
return false;
return ctx->has_focus(gl);
} }
static bool gl_suppress_screensaver(void *data, bool enable) static bool gl_suppress_screensaver(void *data, bool enable)

View File

@ -73,6 +73,7 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
NULL NULL
}; };
const gfx_ctx_driver_t *gfx_ctx_get_ptr(void) const gfx_ctx_driver_t *gfx_ctx_get_ptr(void)
{ {
driver_t *driver = driver_get_ptr(); driver_t *driver = driver_get_ptr();
@ -81,6 +82,33 @@ const gfx_ctx_driver_t *gfx_ctx_get_ptr(void)
return (const gfx_ctx_driver_t*)driver->video_context; return (const gfx_ctx_driver_t*)driver->video_context;
} }
void gfx_ctx_swap_buffers(void *data)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (ctx->swap_buffers)
ctx->swap_buffers(data);
}
bool gfx_ctx_focus(void *data)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (data && ctx && ctx->has_focus)
return ctx->has_focus(data);
return false;
}
void gfx_ctx_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr();
if (ctx && ctx->set_video_mode)
ctx->set_video_mode(data, width, height, fullscreen);
}
void gfx_ctx_translate_aspect(void *data, float *aspect, void gfx_ctx_translate_aspect(void *data, float *aspect,
unsigned width, unsigned height) unsigned width, unsigned height)
{ {

View File

@ -207,6 +207,14 @@ bool gfx_ctx_get_metrics(enum display_metric_types type, float *value);
void gfx_ctx_translate_aspect(void *data, float *aspect, void gfx_ctx_translate_aspect(void *data, float *aspect,
unsigned width, unsigned height); unsigned width, unsigned height);
void gfx_ctx_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen);
void gfx_ctx_swap_buffers(void *data);
bool gfx_ctx_focus(void *data);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif