diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 1b590cb065..dfec3dd16c 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1281,8 +1281,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, if (gl->egl_images) { EGLImageKHR img = 0; - const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); - bool new_egl = ctx && ctx->write_egl_image(gl, + bool new_egl = gfx_ctx_write_egl_image(gl, frame, width, height, pitch, (gl->base_size == 4), gl->tex_index, &img); @@ -2500,12 +2499,7 @@ static bool gl_suppress_screensaver(void *data, bool enable) static bool gl_has_windowed(void *data) { - gl_t *gl = (gl_t*)data; - const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); - - if (gl && ctx) - return ctx->has_windowed(gl); - return true; + return gfx_ctx_has_windowed(data); } static void gl_update_tex_filter_frame(gl_t *gl) @@ -3072,9 +3066,7 @@ static uintptr_t gl_get_current_framebuffer(void *data) static retro_proc_address_t gl_get_proc_address(void *data, const char *sym) { - const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); - - return ctx->get_proc_address(sym); + return gfx_ctx_get_proc_address(sym); } static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) @@ -3179,11 +3171,7 @@ static void gl_set_osd_msg(void *data, const char *msg, static void gl_show_mouse(void *data, bool state) { - gl_t *gl = (gl_t*)data; - const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); - - if (gl && ctx->show_mouse) - ctx->show_mouse(gl, state); + gfx_ctx_show_mouse(data, state); } static struct video_shader *gl_get_current_shader(void *data) diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 1edb176986..555262efa0 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -127,6 +127,39 @@ bool gfx_ctx_get_metrics(enum display_metric_types type, float *value) value); } +bool gfx_ctx_write_egl_image(void *data, const void *frame, unsigned width, + unsigned height, unsigned pitch, bool rgb32, + unsigned index, void **image_handle) +{ + const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); + if (ctx && ctx->write_egl_image) + return ctx->write_egl_image(data, frame, width, height, pitch, + rgb32, index, image_handle); + return false; +} + +retro_proc_address_t gfx_ctx_get_proc_address(const char *sym) +{ + const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); + return ctx->get_proc_address(sym); +} + +void gfx_ctx_show_mouse(void *data, bool state) +{ + const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); + if (data && ctx->show_mouse) + ctx->show_mouse(data, state); +} + +bool gfx_ctx_has_windowed(void *data) +{ + const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); + + if (data && ctx) + return ctx->has_windowed(data); + return true; +} + /** * find_gfx_ctx_driver_index: * @ident : Identifier of resampler driver to find. diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 122e967a96..27e8608384 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -215,6 +215,16 @@ void gfx_ctx_swap_buffers(void *data); bool gfx_ctx_focus(void *data); +bool gfx_ctx_write_egl_image(void *data, const void *frame, + unsigned width, unsigned height, unsigned pitch, bool rgb32, + unsigned index, void **image_handle); + +void gfx_ctx_show_mouse(void *data, bool state); + +bool gfx_ctx_has_windowed(void *data); + +retro_proc_address_t gfx_ctx_get_proc_address(const char *sym); + #ifdef __cplusplus } #endif