Rename video context driver functions

This commit is contained in:
twinaphex 2016-05-08 20:32:46 +02:00
parent be1daeebd7
commit b20d550cc4
13 changed files with 440 additions and 397 deletions

View File

@ -976,7 +976,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
flags.flags = 0; flags.flags = 0;
BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
gfx_ctx_ctl(GFX_CTL_SET_FLAGS, &flags); video_context_driver_set_flags(&flags);
RARCH_LOG("Requesting core OpenGL context (%u.%u).\n", RARCH_LOG("Requesting core OpenGL context (%u.%u).\n",
cb->version_major, cb->version_minor); cb->version_major, cb->version_minor);

View File

@ -544,7 +544,7 @@ void d3d_make_d3dpp(void *data,
unsigned width = 0; unsigned width = 0;
unsigned height = 0; unsigned height = 0;
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); video_context_driver_get_video_size(&mode);
width = mode.width; width = mode.width;
height = mode.height; height = mode.height;
@ -664,7 +664,7 @@ static void d3d_calculate_rect(void *data,
aspect_data.width = *width; aspect_data.width = *width;
aspect_data.height = *height; aspect_data.height = *height;
gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); video_context_driver_translate_aspect(&aspect_data);
*x = 0; *x = 0;
*y = 0; *y = 0;
@ -845,7 +845,7 @@ static void d3d_set_nonblock_state(void *data, bool state)
d3d->video_info.vsync = !state; d3d->video_info.vsync = !state;
gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); video_context_driver_swap_interval(&interval);
#ifndef _XBOX #ifndef _XBOX
d3d->needs_restore = true; d3d->needs_restore = true;
d3d_restore(d3d); d3d_restore(d3d);
@ -867,7 +867,7 @@ static bool d3d_alive(void *data)
size_data.width = &temp_width; size_data.width = &temp_width;
size_data.height = &temp_height; size_data.height = &temp_height;
if (gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data)) if (video_context_driver_check_window(&size_data))
{ {
if (quit) if (quit)
d3d->quitting = quit; d3d->quitting = quit;
@ -881,7 +881,7 @@ static bool d3d_alive(void *data)
mode.width = temp_width; mode.width = temp_width;
mode.height = temp_height; mode.height = temp_height;
gfx_ctx_ctl(GFX_CTL_SET_RESIZE, &mode); video_context_driver_set_resize(&mode);
d3d_restore(d3d); d3d_restore(d3d);
} }
@ -896,18 +896,18 @@ static bool d3d_alive(void *data)
static bool d3d_focus(void *data) static bool d3d_focus(void *data)
{ {
return gfx_ctx_ctl(GFX_CTL_FOCUS, NULL); return video_context_driver_focus();
} }
static bool d3d_suppress_screensaver(void *data, bool enable) static bool d3d_suppress_screensaver(void *data, bool enable)
{ {
bool enabled = enable; bool enabled = enable;
return gfx_ctx_ctl(GFX_CTL_SUPPRESS_SCREENSAVER, &enabled); return video_context_driver_suppress_screensaver(&enabled);
} }
static bool d3d_has_windowed(void *data) static bool d3d_has_windowed(void *data)
{ {
return gfx_ctx_ctl(GFX_CTL_HAS_WINDOWED, NULL); return video_context_driver_has_windowed();
} }
static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
@ -1017,7 +1017,7 @@ static bool d3d_construct(d3d_video_t *d3d,
{ {
gfx_ctx_mode_t mode; gfx_ctx_mode_t mode;
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); video_context_driver_get_video_size(&mode);
full_x = mode.width; full_x = mode.width;
full_y = mode.height; full_y = mode.height;
@ -1065,7 +1065,7 @@ static bool d3d_construct(d3d_video_t *d3d,
inp.input = input; inp.input = input;
inp.input_data = input_data; inp.input_data = input_data;
gfx_ctx_ctl(GFX_CTL_INPUT_DRIVER, &inp); video_context_driver_input_driver(&inp);
RARCH_LOG("[D3D]: Init complete.\n"); RARCH_LOG("[D3D]: Init complete.\n");
return true; return true;
@ -1084,7 +1084,7 @@ 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)
{ {
gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); video_context_driver_show_mouse(&state);
} }
static const gfx_ctx_driver_t *d3d_get_context(void *data) static const gfx_ctx_driver_t *d3d_get_context(void *data)
@ -1100,7 +1100,7 @@ static const gfx_ctx_driver_t *d3d_get_context(void *data)
unsigned major = 9; unsigned major = 9;
enum gfx_ctx_api api = GFX_CTX_DIRECT3D9_API; enum gfx_ctx_api api = GFX_CTX_DIRECT3D9_API;
#endif #endif
return video_driver_context_init_first(data, return video_context_driver_init_first(data,
settings->video.context_driver, settings->video.context_driver,
api, major, minor, false); api, major, minor, false);
} }
@ -1154,7 +1154,7 @@ static void *d3d_init(const video_info_t *info,
#endif #endif
#endif #endif
gfx_ctx_ctl(GFX_CTL_SET, (void*)ctx_driver); video_context_driver_set((void*)ctx_driver);
if (!d3d_construct(d3d, info, input, input_data)) if (!d3d_construct(d3d, info, input, input_data))
{ {
@ -1171,7 +1171,7 @@ static void *d3d_init(const video_info_t *info,
return d3d; return d3d;
error: error:
gfx_ctx_ctl(GFX_CTL_DESTROY, NULL); video_context_driver_destroy();
if (d3d) if (d3d)
delete d3d; delete d3d;
return NULL; return NULL;
@ -1204,7 +1204,7 @@ static void d3d_free(void *data)
d3d_free_overlays(d3d); d3d_free_overlays(d3d);
#endif #endif
gfx_ctx_ctl(GFX_CTL_FREE, NULL); video_context_driver_free();
#ifndef _XBOX #ifndef _XBOX
#ifdef HAVE_MENU #ifdef HAVE_MENU
@ -1392,7 +1392,7 @@ 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;
gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); video_context_driver_show_mouse(&state);
} }
static void d3d_overlay_full_screen(void *data, bool enable) static void d3d_overlay_full_screen(void *data, bool enable)
@ -1537,11 +1537,11 @@ static bool d3d_frame(void *data, const void *frame,
} }
#endif #endif
gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); video_context_driver_update_window_title();
retro_perf_stop(&d3d_frame); retro_perf_stop(&d3d_frame);
gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); video_context_driver_swap_buffers();
return true; return true;
} }

View File

@ -115,7 +115,7 @@ static const GLfloat white_color[] = {
static INLINE void context_bind_hw_render(gl_t *gl, bool enable) static INLINE void context_bind_hw_render(gl_t *gl, bool enable)
{ {
if (gl && gl->shared_context_use) if (gl && gl->shared_context_use)
gfx_ctx_ctl(GFX_CTL_BIND_HW_RENDER, &enable); video_context_driver_bind_hw_render(&enable);
} }
static INLINE bool gl_query_extension(gl_t *gl, const char *ext) static INLINE bool gl_query_extension(gl_t *gl, const char *ext)
@ -882,7 +882,7 @@ static void gl_set_viewport(void *data, unsigned viewport_width,
aspect_data.width = viewport_width; aspect_data.width = viewport_width;
aspect_data.height = viewport_height; aspect_data.height = viewport_height;
gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); video_context_driver_translate_aspect(&aspect_data);
if (settings->video.scale_integer && !force_full) if (settings->video.scale_integer && !force_full)
{ {
@ -987,7 +987,7 @@ static void gl_set_video_mode(void *data, unsigned width, unsigned height,
mode.height = height; mode.height = height;
mode.fullscreen = fullscreen; mode.fullscreen = fullscreen;
gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode); video_context_driver_set_video_mode(&mode);
} }
#ifdef HAVE_FBO #ifdef HAVE_FBO
@ -1387,7 +1387,7 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video)
#if defined(HAVE_EGL) && defined(HAVE_OPENGLES2) #if defined(HAVE_EGL) && defined(HAVE_OPENGLES2)
/* Use regular textures if we use HW render. */ /* Use regular textures if we use HW render. */
gl->egl_images = !gl->hw_render_use && gl_check_eglimage_proc() && gl->egl_images = !gl->hw_render_use && gl_check_eglimage_proc() &&
gfx_ctx_ctl(GFX_CTL_IMAGE_BUFFER_INIT, (void*)video); video_context_driver_init_image_buffer((void*)video);
#else #else
(void)video; (void)video;
#endif #endif
@ -1466,7 +1466,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame,
img_info.rgb32 = (gl->base_size == 4); img_info.rgb32 = (gl->base_size == 4);
img_info.handle = &img; img_info.handle = &img;
new_egl = gfx_ctx_ctl(GFX_CTL_IMAGE_BUFFER_WRITE, &img_info); new_egl = video_context_driver_write_to_image_buffer(&img_info);
if (img == EGL_NO_IMAGE_KHR) if (img == EGL_NO_IMAGE_KHR)
{ {
@ -1793,7 +1793,7 @@ static bool gl_frame(void *data, const void *frame,
mode.width = width; mode.width = width;
mode.height = height; mode.height = height;
gfx_ctx_ctl(GFX_CTL_SET_RESIZE, &mode); video_context_driver_set_resize(&mode);
#ifdef HAVE_FBO #ifdef HAVE_FBO
if (gl->fbo_inited) if (gl->fbo_inited)
@ -1938,7 +1938,7 @@ static bool gl_frame(void *data, const void *frame,
gl_render_overlay(gl); gl_render_overlay(gl);
#endif #endif
gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); video_context_driver_update_window_title();
retro_perf_stop(&frame_run); retro_perf_stop(&frame_run);
@ -1989,11 +1989,11 @@ static bool gl_frame(void *data, const void *frame,
&& !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)
&& !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
{ {
gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); video_context_driver_swap_buffers();
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); video_context_driver_swap_buffers();
#ifdef HAVE_GL_SYNC #ifdef HAVE_GL_SYNC
if (settings->video.hard_sync && gl->have_sync) if (settings->video.hard_sync && gl->have_sync)
@ -2121,7 +2121,7 @@ static void gl_free(void *data)
} }
#endif #endif
gfx_ctx_ctl(GFX_CTL_FREE, NULL); video_context_driver_free();
free(gl->empty_buf); free(gl->empty_buf);
free(gl->conv_buffer); free(gl->conv_buffer);
@ -2144,7 +2144,7 @@ static void gl_set_nonblock_state(void *data, bool state)
if (!state) if (!state)
interval = settings->video.swap_interval; interval = settings->video.swap_interval;
gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); video_context_driver_swap_interval(&interval);
context_bind_hw_render(gl, true); context_bind_hw_render(gl, true);
} }
@ -2444,7 +2444,7 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl)
gl->shared_context_use = settings->video.shared_context gl->shared_context_use = settings->video.shared_context
&& hwr->context_type != RETRO_HW_CONTEXT_NONE; && hwr->context_type != RETRO_HW_CONTEXT_NONE;
return video_driver_context_init_first(gl, settings->video.context_driver, return video_context_driver_init_first(gl, settings->video.context_driver,
api, major, minor, gl->shared_context_use); api, major, minor, gl->shared_context_use);
} }
@ -2610,13 +2610,13 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
if (!gl || !ctx_driver) if (!gl || !ctx_driver)
goto error; goto error;
gfx_ctx_ctl(GFX_CTL_SET, (void*)ctx_driver); video_context_driver_set((void*)ctx_driver);
gl->video_info = *video; gl->video_info = *video;
RARCH_LOG("Found GL context: %s\n", ctx_driver->ident); RARCH_LOG("Found GL context: %s\n", ctx_driver->ident);
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); video_context_driver_get_video_size(&mode);
full_x = mode.width; full_x = mode.width;
full_y = mode.height; full_y = mode.height;
@ -2627,7 +2627,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
interval = video->vsync ? settings->video.swap_interval : 0; interval = video->vsync ? settings->video.swap_interval : 0;
gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); video_context_driver_swap_interval(&interval);
win_width = video->width; win_width = video->width;
win_height = video->height; win_height = video->height;
@ -2642,7 +2642,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
mode.height = win_height; mode.height = win_height;
mode.fullscreen = video->fullscreen; mode.fullscreen = video->fullscreen;
if (!gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode)) if (!video_context_driver_set_video_mode(&mode))
goto error; goto error;
/* Clear out potential error flags in case we use cached context. */ /* Clear out potential error flags in case we use cached context. */
@ -2678,7 +2678,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
mode.width = 0; mode.width = 0;
mode.height = 0; mode.height = 0;
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); video_context_driver_get_video_size(&mode);
temp_width = mode.width; temp_width = mode.width;
temp_height = mode.height; temp_height = mode.height;
@ -2832,7 +2832,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
inp.input = input; inp.input = input;
inp.input_data = input_data; inp.input_data = input_data;
gfx_ctx_ctl(GFX_CTL_INPUT_DRIVER, &inp); video_context_driver_input_driver(&inp);
if (settings->video.font_enable) if (settings->video.font_enable)
{ {
@ -2853,7 +2853,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
return gl; return gl;
error: error:
gfx_ctx_ctl(GFX_CTL_DESTROY, NULL); video_context_driver_destroy();
free(gl); free(gl);
return NULL; return NULL;
} }
@ -2876,7 +2876,7 @@ static bool gl_alive(void *data)
size_data.width = &temp_width; size_data.width = &temp_width;
size_data.height = &temp_height; size_data.height = &temp_height;
if (gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data)) if (video_context_driver_check_window(&size_data))
{ {
if (quit) if (quit)
gl->quitting = true; gl->quitting = true;
@ -2894,18 +2894,18 @@ static bool gl_alive(void *data)
static bool gl_focus(void *data) static bool gl_focus(void *data)
{ {
return gfx_ctx_ctl(GFX_CTL_FOCUS, NULL); return video_context_driver_focus();
} }
static bool gl_suppress_screensaver(void *data, bool enable) static bool gl_suppress_screensaver(void *data, bool enable)
{ {
bool enabled = enable; bool enabled = enable;
return gfx_ctx_ctl(GFX_CTL_SUPPRESS_SCREENSAVER, &enabled); return video_context_driver_suppress_screensaver(&enabled);
} }
static bool gl_has_windowed(void *data) static bool gl_has_windowed(void *data)
{ {
return gfx_ctx_ctl(GFX_CTL_HAS_WINDOWED, NULL); return video_context_driver_has_windowed();
} }
static void gl_update_tex_filter_frame(gl_t *gl) static void gl_update_tex_filter_frame(gl_t *gl)
@ -3463,7 +3463,7 @@ static void gl_overlay_enable(void *data, bool state)
gl->overlay_enable = state; gl->overlay_enable = state;
if (gl->fullscreen) if (gl->fullscreen)
gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); video_context_driver_show_mouse(&state);
} }
static void gl_overlay_full_screen(void *data, bool enable) static void gl_overlay_full_screen(void *data, bool enable)
@ -3579,7 +3579,7 @@ static retro_proc_address_t gl_get_proc_address(void *data, const char *sym)
proc_address.sym = sym; proc_address.sym = sym;
gfx_ctx_ctl(GFX_CTL_PROC_ADDRESS_GET, &proc_address); video_context_driver_get_proc_address(&proc_address);
return proc_address.addr; return proc_address.addr;
} }
@ -3677,7 +3677,7 @@ static void gl_set_osd_msg(void *data, const char *msg,
static void gl_show_mouse(void *data, bool state) static void gl_show_mouse(void *data, bool state)
{ {
gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); video_context_driver_show_mouse(&state);
} }
static struct video_shader *gl_get_current_shader(void *data) static struct video_shader *gl_get_current_shader(void *data)
@ -3696,20 +3696,19 @@ static void gl_get_video_output_size(void *data,
gfx_ctx_size_t size_data; gfx_ctx_size_t size_data;
size_data.width = width; size_data.width = width;
size_data.height = height; size_data.height = height;
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_SIZE, &size_data); video_context_driver_get_video_output_size(&size_data);
} }
static void gl_get_video_output_prev(void *data) static void gl_get_video_output_prev(void *data)
{ {
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_PREV, NULL); video_context_driver_get_video_output_prev();
} }
static void gl_get_video_output_next(void *data) static void gl_get_video_output_next(void *data)
{ {
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); video_context_driver_get_video_output_next();
} }
static void video_texture_load_gl( static void video_texture_load_gl(
struct texture_image *ti, struct texture_image *ti,
enum texture_filter_type filter_type, enum texture_filter_type filter_type,

View File

@ -70,7 +70,7 @@ static PFNVGCREATEEGLIMAGETARGETKHRPROC pvgCreateEGLImageTargetKHR;
static void vg_set_nonblock_state(void *data, bool state) static void vg_set_nonblock_state(void *data, bool state)
{ {
unsigned interval = state ? 0 : 1; unsigned interval = state ? 0 : 1;
gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); video_context_driver_set_swap_interval(&interval);
} }
static INLINE bool vg_query_extension(const char *ext) static INLINE bool vg_query_extension(const char *ext)
@ -94,16 +94,16 @@ static void *vg_init(const video_info_t *video,
VGfloat clearColor[4] = {0, 0, 0, 1}; VGfloat clearColor[4] = {0, 0, 0, 1};
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t)); vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t));
const gfx_ctx_driver_t *ctx = video_driver_context_init_first( const gfx_ctx_driver_t *ctx = video_context_driver_init_first(
vg, settings->video.context_driver, vg, settings->video.context_driver,
GFX_CTX_OPENVG_API, 0, 0, false); GFX_CTX_OPENVG_API, 0, 0, false);
if (!vg || !ctx) if (!vg || !ctx)
goto error; goto error;
gfx_ctx_ctl(GFX_CTL_SET, (void*)ctx); video_context_driver_set((void*)ctx);
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); video_context_driver_get_video_size(&mode);
temp_width = mode.width; temp_width = mode.width;
temp_height = mode.height; temp_height = mode.height;
@ -117,8 +117,8 @@ static void *vg_init(const video_info_t *video,
interval = video->vsync ? 1 : 0; interval = video->vsync ? 1 : 0;
gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); video_context_driver_swap_interval(&interval);
gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); video_context_driver_update_window_title();
vg->mTexType = video->rgb32 ? VG_sXRGB_8888 : VG_sRGB_565; vg->mTexType = video->rgb32 ? VG_sXRGB_8888 : VG_sRGB_565;
vg->keep_aspect = video->force_aspect; vg->keep_aspect = video->force_aspect;
@ -137,7 +137,7 @@ static void *vg_init(const video_info_t *video,
mode.height = win_height; mode.height = win_height;
mode.fullscreen = video->fullscreen; mode.fullscreen = video->fullscreen;
if (!gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode)) if (!vidoe_context_driver_set_video_mode(&mode))
goto error; goto error;
video_driver_get_size(&temp_width, &temp_height); video_driver_get_size(&temp_width, &temp_height);
@ -147,7 +147,7 @@ static void *vg_init(const video_info_t *video,
mode.width = 0; mode.width = 0;
mode.height = 0; mode.height = 0;
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); video_context_driver_get_video_size(&mode);
temp_width = mode.width; temp_width = mode.width;
temp_height = mode.height; temp_height = mode.height;
@ -170,7 +170,7 @@ static void *vg_init(const video_info_t *video,
aspect_data.width = temp_width; aspect_data.width = temp_width;
aspect_data.height = temp_height; aspect_data.height = temp_height;
gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); video_context_driver_translate_aspect(&aspect_data);
vgSetfv(VG_CLEAR_COLOR, 4, clearColor); vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
@ -182,7 +182,7 @@ static void *vg_init(const video_info_t *video,
inp.input = input; inp.input = input;
inp.input_data = input_data; inp.input_data = input_data;
gfx_ctx_ctl(GFX_CTL_INPUT_DRIVER, &inp); video_context_driver_input_driver(&inp);
if ( settings->video.font_enable if ( settings->video.font_enable
&& font_renderer_create_default((const void**)&vg->font_driver, &vg->mFontRenderer, && font_renderer_create_default((const void**)&vg->font_driver, &vg->mFontRenderer,
@ -216,13 +216,13 @@ static void *vg_init(const video_info_t *video,
} }
if (vg_query_extension("KHR_EGL_image") if (vg_query_extension("KHR_EGL_image")
&& gfx_ctx_ctl(GFX_CTL_IMAGE_BUFFER_INIT, (void*)video)) && video_context_driver_init_image_buffer((void*)video))
{ {
gfx_ctx_proc_address_t proc_address; gfx_ctx_proc_address_t proc_address;
proc_address.sym = "vgCreateEGLImageTargetKHR"; proc_address.sym = "vgCreateEGLImageTargetKHR";
gfx_ctx_ctl(GFX_CTL_PROC_ADDRESS_GET, &proc_address); video_context_driver_get_proc_address(&proc_address);
pvgCreateEGLImageTargetKHR = pvgCreateEGLImageTargetKHR =
(PFNVGCREATEEGLIMAGETARGETKHRPROC)proc_address.addr; (PFNVGCREATEEGLIMAGETARGETKHRPROC)proc_address.addr;
@ -245,7 +245,7 @@ static void *vg_init(const video_info_t *video,
error: error:
if (vg) if (vg)
free(vg); free(vg);
gfx_ctx_ctl(GFX_CTL_DESTROY, NULL); video_context_driver_destroy();
return NULL; return NULL;
} }
@ -266,7 +266,7 @@ static void vg_free(void *data)
vgDestroyPaint(vg->mPaintBg); vgDestroyPaint(vg->mPaintBg);
} }
gfx_ctx_ctl(GFX_CTL_FREE, NULL); video_context_driver_free();
free(vg); free(vg);
} }
@ -343,7 +343,7 @@ static void vg_copy_frame(void *data, const void *frame,
img_info.index = 0; img_info.index = 0;
img_info.handle = &img; img_info.handle = &img;
new_egl = gfx_ctx_ctl(GFX_CTL_IMAGE_BUFFER_WRITE, &img_info); new_egl = video_context_driver_write_to_image_buffer(&img_info);
retro_assert(img != EGL_NO_IMAGE_KHR); retro_assert(img != EGL_NO_IMAGE_KHR);
@ -413,11 +413,11 @@ static bool vg_frame(void *data, const void *frame,
vg_draw_message(vg, msg); vg_draw_message(vg, msg);
#endif #endif
gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); video_context_driver_update_window_title();
retro_perf_stop(&vg_fr); retro_perf_stop(&vg_fr);
gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); video_context_driver_swap_buffers();
return true; return true;
} }
@ -435,7 +435,7 @@ static bool vg_alive(void *data)
size_data.width = &temp_width; size_data.width = &temp_width;
size_data.height = &temp_height; size_data.height = &temp_height;
gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data); video_context_driver_check_window(&size_data);
if (temp_width != 0 && temp_height != 0) if (temp_width != 0 && temp_height != 0)
video_driver_set_size(&temp_width, &temp_height); video_driver_set_size(&temp_width, &temp_height);
@ -445,18 +445,18 @@ static bool vg_alive(void *data)
static bool vg_focus(void *data) static bool vg_focus(void *data)
{ {
return gfx_ctx_ctl(GFX_CTL_FOCUS, NULL); return video_context_driver_focus();
} }
static bool vg_suppress_screensaver(void *data, bool enable) static bool vg_suppress_screensaver(void *data, bool enable)
{ {
bool enabled = enable; bool enabled = enable;
return gfx_ctx_ctl(GFX_CTL_SUPPRESS_SCREENSAVER, &enabled); return video_context_driver_suppress_screensaver(&enabled);
} }
static bool vg_has_windowed(void *data) static bool vg_has_windowed(void *data)
{ {
return gfx_ctx_ctl(GFX_CTL_HAS_WINDOWED, NULL); return video_context_driver_has_windowed();
} }
static bool vg_set_shader(void *data, static bool vg_set_shader(void *data,

View File

@ -70,7 +70,7 @@ static const gfx_ctx_driver_t *vulkan_get_context(vk_t *vk)
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
enum gfx_ctx_api api = GFX_CTX_VULKAN_API; enum gfx_ctx_api api = GFX_CTX_VULKAN_API;
return video_driver_context_init_first( return video_context_driver_init_first(
vk, settings->video.context_driver, vk, settings->video.context_driver,
api, major, minor, false); api, major, minor, false);
} }
@ -810,7 +810,7 @@ static void vulkan_free(void *data)
if (vk->filter_chain) if (vk->filter_chain)
vulkan_filter_chain_free(vk->filter_chain); vulkan_filter_chain_free(vk->filter_chain);
gfx_ctx_ctl(GFX_CTL_FREE, NULL); video_context_driver_free();
} }
scaler_ctx_gen_reset(&vk->readback.scaler); scaler_ctx_gen_reset(&vk->readback.scaler);
@ -980,9 +980,9 @@ static void *vulkan_init(const video_info_t *video,
if (!ctx_driver) if (!ctx_driver)
goto error; goto error;
gfx_ctx_ctl(GFX_CTL_SET, (void*)ctx_driver); video_context_driver_set((void*)ctx_driver);
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); video_context_driver_get_video_size(&mode);
full_x = mode.width; full_x = mode.width;
full_y = mode.height; full_y = mode.height;
mode.width = 0; mode.width = 0;
@ -990,7 +990,7 @@ static void *vulkan_init(const video_info_t *video,
RARCH_LOG("Detecting screen resolution %ux%u.\n", full_x, full_y); RARCH_LOG("Detecting screen resolution %ux%u.\n", full_x, full_y);
interval = video->vsync ? settings->video.swap_interval : 0; interval = video->vsync ? settings->video.swap_interval : 0;
gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); video_context_driver_swap_interval(&interval);
win_width = video->width; win_width = video->width;
win_height = video->height; win_height = video->height;
@ -1004,10 +1004,10 @@ static void *vulkan_init(const video_info_t *video,
mode.width = win_width; mode.width = win_width;
mode.height = win_height; mode.height = win_height;
mode.fullscreen = video->fullscreen; mode.fullscreen = video->fullscreen;
if (!gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode)) if (!video_context_driver_set_video_mode(&mode))
goto error; goto error;
gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); video_context_driver_get_video_size(&mode);
temp_width = mode.width; temp_width = mode.width;
temp_height = mode.height; temp_height = mode.height;
@ -1017,7 +1017,7 @@ static void *vulkan_init(const video_info_t *video,
RARCH_LOG("Vulkan: Using resolution %ux%u\n", temp_width, temp_height); RARCH_LOG("Vulkan: Using resolution %ux%u\n", temp_width, temp_height);
gfx_ctx_ctl(GFX_CTL_GET_CONTEXT_DATA, &vk->context); video_context_driver_get_context_data(&vk->context);
vk->vsync = video->vsync; vk->vsync = video->vsync;
vk->fullscreen = video->fullscreen; vk->fullscreen = video->fullscreen;
@ -1041,7 +1041,7 @@ static void *vulkan_init(const video_info_t *video,
inp.input = input; inp.input = input;
inp.input_data = input_data; inp.input_data = input_data;
gfx_ctx_ctl(GFX_CTL_INPUT_DRIVER, &inp); video_context_driver_input_driver(&inp);
if (settings->video.font_enable) if (settings->video.font_enable)
{ {
@ -1098,7 +1098,7 @@ static void vulkan_set_nonblock_state(void *data, bool state)
RARCH_LOG("[Vulkan]: VSync => %s\n", state ? "off" : "on"); RARCH_LOG("[Vulkan]: VSync => %s\n", state ? "off" : "on");
interval = state ? 0 : settings->video.swap_interval; interval = state ? 0 : settings->video.swap_interval;
gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); video_context_driver_swap_interval(&interval);
/* Changing vsync might require recreating the swapchain, which means new VkImages /* Changing vsync might require recreating the swapchain, which means new VkImages
* to render into. */ * to render into. */
@ -1122,7 +1122,7 @@ static bool vulkan_alive(void *data)
size_data.width = &temp_width; size_data.width = &temp_width;
size_data.height = &temp_height; size_data.height = &temp_height;
if (gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data)) if (video_context_driver_check_window(&size_data))
{ {
if (quit) if (quit)
vk->quitting = true; vk->quitting = true;
@ -1141,20 +1141,20 @@ static bool vulkan_alive(void *data)
static bool vulkan_focus(void *data) static bool vulkan_focus(void *data)
{ {
(void)data; (void)data;
return gfx_ctx_ctl(GFX_CTL_FOCUS, NULL); return video_context_driver_focus();
} }
static bool vulkan_suppress_screensaver(void *data, bool enable) static bool vulkan_suppress_screensaver(void *data, bool enable)
{ {
(void)data; (void)data;
bool enabled = enable; bool enabled = enable;
return gfx_ctx_ctl(GFX_CTL_SUPPRESS_SCREENSAVER, &enabled); return video_context_driver_suppress_screensaver(&enabled);
} }
static bool vulkan_has_windowed(void *data) static bool vulkan_has_windowed(void *data)
{ {
(void)data; (void)data;
return gfx_ctx_ctl(GFX_CTL_HAS_WINDOWED, NULL); return video_context_driver_has_windowed();
} }
static bool vulkan_set_shader(void *data, static bool vulkan_set_shader(void *data,
@ -1232,7 +1232,7 @@ static void vulkan_set_video_mode(void *data,
mode.height = height; mode.height = height;
mode.fullscreen = fullscreen; mode.fullscreen = fullscreen;
gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode); video_context_driver_set_video_mode(&mode);
} }
static void vulkan_set_viewport(void *data, unsigned viewport_width, static void vulkan_set_viewport(void *data, unsigned viewport_width,
@ -1253,7 +1253,7 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width,
aspect_data.width = viewport_width; aspect_data.width = viewport_width;
aspect_data.height = viewport_height; aspect_data.height = viewport_height;
gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); video_context_driver_translate_aspect(&aspect_data);
if (settings->video.scale_integer && !force_full) if (settings->video.scale_integer && !force_full)
{ {
@ -1747,10 +1747,10 @@ static bool vulkan_frame(void *data, const void *frame,
retro_perf_stop(&queue_submit); retro_perf_stop(&queue_submit);
retro_perf_start(&swapbuffers); retro_perf_start(&swapbuffers);
gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); video_context_driver_swap_buffers();
retro_perf_stop(&swapbuffers); retro_perf_stop(&swapbuffers);
gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); video_context_driver_update_window_title();
/* Handle spurious swapchain invalidations as soon as we can, /* Handle spurious swapchain invalidations as soon as we can,
* i.e. right after swap buffers. */ * i.e. right after swap buffers. */
@ -1759,7 +1759,7 @@ static bool vulkan_frame(void *data, const void *frame,
gfx_ctx_mode_t mode; gfx_ctx_mode_t mode;
mode.width = width; mode.width = width;
mode.height = height; mode.height = height;
gfx_ctx_ctl(GFX_CTL_SET_RESIZE, &mode); video_context_driver_set_resize(&mode);
vk->should_resize = false; vk->should_resize = false;
} }
@ -1810,7 +1810,7 @@ static void vulkan_apply_state_changes(void *data)
static void vulkan_show_mouse(void *data, bool state) static void vulkan_show_mouse(void *data, bool state)
{ {
(void)data; (void)data;
gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); video_context_driver_show_mouse(&state);
} }
static struct video_shader *vulkan_get_current_shader(void *data) static struct video_shader *vulkan_get_current_shader(void *data)
@ -2117,7 +2117,7 @@ static void vulkan_overlay_enable(void *data, bool enable)
vk->overlay.enable = enable; vk->overlay.enable = enable;
if (vk->fullscreen) if (vk->fullscreen)
gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &enable); video_context_driver_show_mouse(&enable);
} }
static void vulkan_overlay_full_screen(void *data, bool enable) static void vulkan_overlay_full_screen(void *data, bool enable)

View File

@ -469,7 +469,6 @@ static float gfx_ctx_vc_translate_aspect(void *data,
unsigned width, unsigned height) unsigned width, unsigned height)
{ {
(void)data; (void)data;
/* Check for SD televisions: they should always be 4:3. */ /* Check for SD televisions: they should always be 4:3. */
if ((width == 640 || width == 720) && (height == 480 || height == 576)) if ((width == 640 || width == 720) && (height == 480 || height == 576))
return 4.0f / 3.0f; return 4.0f / 3.0f;

View File

@ -89,7 +89,7 @@ static const gfx_ctx_driver_t *current_video_context = NULL;
static void *video_context_data = NULL; static void *video_context_data = NULL;
/** /**
* find_video_driver_context_driver_index: * find_video_context_driver_driver_index:
* @ident : Identifier of resampler driver to find. * @ident : Identifier of resampler driver to find.
* *
* Finds graphics context driver index by @ident name. * Finds graphics context driver index by @ident name.
@ -97,7 +97,7 @@ static void *video_context_data = NULL;
* Returns: graphics context driver index if driver was found, otherwise * Returns: graphics context driver index if driver was found, otherwise
* -1. * -1.
**/ **/
static int find_video_driver_context_index(const char *ident) static int find_video_context_driver_index(const char *ident)
{ {
unsigned i; unsigned i;
for (i = 0; gfx_ctx_drivers[i]; i++) for (i = 0; gfx_ctx_drivers[i]; i++)
@ -111,10 +111,10 @@ static int find_video_driver_context_index(const char *ident)
* *
* Finds previous driver in graphics context driver array. * Finds previous driver in graphics context driver array.
**/ **/
static bool video_driver_context_find_prev_driver(void) bool video_context_driver_find_prev_driver(void)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
int i = find_video_driver_context_index( int i = find_video_context_driver_index(
settings->video.context_driver); settings->video.context_driver);
if (i > 0) if (i > 0)
@ -134,10 +134,10 @@ static bool video_driver_context_find_prev_driver(void)
* *
* Finds next driver in graphics context driver array. * Finds next driver in graphics context driver array.
**/ **/
static bool video_driver_context_find_next_driver(void) bool video_context_driver_find_next_driver(void)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
int i = find_video_driver_context_index(settings->video.context_driver); int i = find_video_context_driver_index(settings->video.context_driver);
if (i >= 0 && gfx_ctx_drivers[i + 1]) if (i >= 0 && gfx_ctx_drivers[i + 1])
{ {
@ -152,7 +152,7 @@ static bool video_driver_context_find_next_driver(void)
} }
/** /**
* video_driver_context_init: * video_context_driver_init:
* @data : Input data. * @data : Input data.
* @ctx : Graphics context driver to initialize. * @ctx : Graphics context driver to initialize.
* @ident : Identifier of graphics context driver to find. * @ident : Identifier of graphics context driver to find.
@ -166,7 +166,7 @@ static bool video_driver_context_find_next_driver(void)
* *
* Returns: graphics context driver if successfully initialized, otherwise NULL. * Returns: graphics context driver if successfully initialized, otherwise NULL.
**/ **/
static const gfx_ctx_driver_t *video_driver_context_init( static const gfx_ctx_driver_t *video_context_driver_init(
void *data, void *data,
const gfx_ctx_driver_t *ctx, const gfx_ctx_driver_t *ctx,
const char *ident, const char *ident,
@ -186,7 +186,7 @@ static const gfx_ctx_driver_t *video_driver_context_init(
ctx->bind_hw_render(ctx_data, ctx->bind_hw_render(ctx_data,
settings->video.shared_context && hw_render_ctx); settings->video.shared_context && hw_render_ctx);
gfx_ctx_ctl(GFX_CTL_SET_VIDEO_CONTEXT_DATA, ctx_data); video_context_driver_set_data(ctx_data);
return ctx; return ctx;
} }
@ -199,7 +199,7 @@ static const gfx_ctx_driver_t *video_driver_context_init(
} }
/** /**
* video_driver_context_find_driver: * video_context_driver_find_driver:
* @data : Input data. * @data : Input data.
* @ident : Identifier of graphics context driver to find. * @ident : Identifier of graphics context driver to find.
* @api : API of higher-level graphics API. * @api : API of higher-level graphics API.
@ -212,21 +212,21 @@ static const gfx_ctx_driver_t *video_driver_context_init(
* *
* Returns: graphics context driver if found, otherwise NULL. * Returns: graphics context driver if found, otherwise NULL.
**/ **/
static const gfx_ctx_driver_t *video_driver_context_find_driver(void *data, static const gfx_ctx_driver_t *video_context_driver_find_driver(void *data,
const char *ident, const char *ident,
enum gfx_ctx_api api, unsigned major, enum gfx_ctx_api api, unsigned major,
unsigned minor, bool hw_render_ctx) unsigned minor, bool hw_render_ctx)
{ {
int i = find_video_driver_context_index(ident); int i = find_video_context_driver_index(ident);
if (i >= 0) if (i >= 0)
return video_driver_context_init(data, gfx_ctx_drivers[i], ident, return video_context_driver_init(data, gfx_ctx_drivers[i], ident,
api, major, minor, hw_render_ctx); api, major, minor, hw_render_ctx);
for (i = 0; gfx_ctx_drivers[i]; i++) for (i = 0; gfx_ctx_drivers[i]; i++)
{ {
const gfx_ctx_driver_t *ctx = const gfx_ctx_driver_t *ctx =
video_driver_context_init(data, gfx_ctx_drivers[i], ident, video_context_driver_init(data, gfx_ctx_drivers[i], ident,
api, major, minor, hw_render_ctx); api, major, minor, hw_render_ctx);
if (ctx) if (ctx)
@ -237,7 +237,7 @@ static const gfx_ctx_driver_t *video_driver_context_find_driver(void *data,
} }
/** /**
* video_driver_context_init_first: * video_context_driver_init_first:
* @data : Input data. * @data : Input data.
* @ident : Identifier of graphics context driver to find. * @ident : Identifier of graphics context driver to find.
* @api : API of higher-level graphics API. * @api : API of higher-level graphics API.
@ -250,257 +250,280 @@ static const gfx_ctx_driver_t *video_driver_context_find_driver(void *data,
* *
* Returns: graphics context driver if found, otherwise NULL. * Returns: graphics context driver if found, otherwise NULL.
**/ **/
const gfx_ctx_driver_t *video_driver_context_init_first(void *data, const gfx_ctx_driver_t *video_context_driver_init_first(void *data,
const char *ident, enum gfx_ctx_api api, unsigned major, const char *ident, enum gfx_ctx_api api, unsigned major,
unsigned minor, bool hw_render_ctx) unsigned minor, bool hw_render_ctx)
{ {
return video_driver_context_find_driver(data, ident, api, return video_context_driver_find_driver(data, ident, api,
major, minor, hw_render_ctx); major, minor, hw_render_ctx);
} }
bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) bool video_context_driver_check_window(gfx_ctx_size_t *size_data)
{ {
uint64_t *frame_count = NULL;
frame_count = video_driver_get_frame_count_ptr();
switch (state) if (!video_context_data || !size_data)
{ return false;
case GFX_CTL_CHECK_WINDOW: if (!current_video_context || !current_video_context->check_window)
{ return false;
uint64_t *frame_count = NULL;
gfx_ctx_size_t *size_data = (gfx_ctx_size_t*)data;
frame_count = video_driver_get_frame_count_ptr();
if (!video_context_data || !size_data) current_video_context->check_window(video_context_data,
return false; size_data->quit,
if (!current_video_context || !current_video_context->check_window) size_data->resize,
return false; size_data->width,
size_data->height, (unsigned int)*frame_count);
return true;
}
current_video_context->check_window(video_context_data, bool video_context_driver_init_image_buffer(const video_info_t *data)
size_data->quit, {
size_data->resize, if (!current_video_context || !current_video_context->image_buffer_init)
size_data->width, return false;
size_data->height, (unsigned int)*frame_count); if (!current_video_context->image_buffer_init(video_context_data, data))
} return false;
break; return true;
case GFX_CTL_FIND_PREV_DRIVER: }
if (!video_driver_context_find_prev_driver())
return false;
break;
case GFX_CTL_FIND_NEXT_DRIVER:
if (!video_driver_context_find_next_driver())
return false;
break;
case GFX_CTL_IMAGE_BUFFER_INIT:
if (!current_video_context || !current_video_context->image_buffer_init)
return false;
if (!current_video_context->image_buffer_init(video_context_data,
(const video_info_t*)data))
return false;
break;
case GFX_CTL_IMAGE_BUFFER_WRITE:
{
gfx_ctx_image_t *img = (gfx_ctx_image_t*)data;
if (!current_video_context || !current_video_context->image_buffer_write) bool video_context_driver_write_to_image_buffer(gfx_ctx_image_t *img)
return false; {
if (!current_video_context->image_buffer_write(video_context_data, if (!current_video_context || !current_video_context->image_buffer_write)
img->frame, img->width, img->height, img->pitch, return false;
img->rgb32, img->index, img->handle)) if (!current_video_context->image_buffer_write(video_context_data,
return false; img->frame, img->width, img->height, img->pitch,
} img->rgb32, img->index, img->handle))
break; return false;
case GFX_CTL_GET_VIDEO_OUTPUT_PREV: return true;
if (!current_video_context }
|| !current_video_context->get_video_output_prev)
return false;
current_video_context->get_video_output_prev(video_context_data);
break;
case GFX_CTL_GET_VIDEO_OUTPUT_NEXT:
if (!current_video_context ||
!current_video_context->get_video_output_next)
return false;
current_video_context->get_video_output_next(video_context_data);
break;
case GFX_CTL_BIND_HW_RENDER:
{
bool *enable = (bool*)data;
if (!current_video_context || !current_video_context->bind_hw_render)
return false;
current_video_context->bind_hw_render(video_context_data, *enable);
}
break;
case GFX_CTL_SET:
if (!data)
return false;
current_video_context = (const gfx_ctx_driver_t*)data;
break;
case GFX_CTL_DESTROY:
current_video_context = NULL;
break;
case GFX_CTL_UPDATE_WINDOW_TITLE:
if (!current_video_context || !current_video_context->update_window_title)
return false;
current_video_context->update_window_title(video_context_data);
break;
case GFX_CTL_SWAP_BUFFERS:
if (!current_video_context || !current_video_context->swap_buffers)
return false;
current_video_context->swap_buffers(video_context_data);
break;
case GFX_CTL_FOCUS:
if (!video_context_data || !current_video_context->has_focus)
return false;
if (!current_video_context->has_focus(video_context_data))
return false;
break;
case GFX_CTL_HAS_WINDOWED:
if (!video_context_data)
return false;
if (!current_video_context->has_windowed(video_context_data))
return false;
break;
case GFX_CTL_FREE:
if (current_video_context->destroy)
current_video_context->destroy(video_context_data);
current_video_context = NULL;
video_context_data = NULL;
break;
case GFX_CTL_GET_VIDEO_OUTPUT_SIZE:
{
gfx_ctx_size_t *size_data = (gfx_ctx_size_t*)data;
if (!size_data)
return false;
if (!current_video_context || !current_video_context->get_video_output_size)
return false;
current_video_context->get_video_output_size(video_context_data,
size_data->width, size_data->height);
}
break;
case GFX_CTL_SWAP_INTERVAL:
{
unsigned *interval = (unsigned*)data;
if (!current_video_context || !current_video_context->swap_interval)
return false;
current_video_context->swap_interval(video_context_data, *interval);
}
break;
case GFX_CTL_PROC_ADDRESS_GET:
{
gfx_ctx_proc_address_t *proc = (gfx_ctx_proc_address_t*)data;
if (!current_video_context || !current_video_context->get_proc_address)
return false;
proc->addr = current_video_context->get_proc_address(proc->sym); bool video_context_driver_get_video_output_prev(void)
} {
break; if (!current_video_context
case GFX_CTL_GET_METRICS: || !current_video_context->get_video_output_prev)
{ return false;
gfx_ctx_metrics_t *metrics = (gfx_ctx_metrics_t*)data; current_video_context->get_video_output_prev(video_context_data);
if (!current_video_context || !current_video_context->get_metrics) return true;
return false; }
if (!current_video_context->get_metrics(video_context_data,
metrics->type, bool video_context_driver_get_video_output_next(void)
metrics->value)) {
return false; if (!current_video_context ||
} !current_video_context->get_video_output_next)
break; return false;
case GFX_CTL_INPUT_DRIVER: current_video_context->get_video_output_next(video_context_data);
{ return true;
gfx_ctx_input_t *inp = (gfx_ctx_input_t*)data; }
if (!current_video_context || !current_video_context->input_driver)
return false; bool video_context_driver_bind_hw_render(bool *enable)
current_video_context->input_driver( {
video_context_data, inp->input, inp->input_data); if (!current_video_context || !current_video_context->bind_hw_render)
} return false;
break; current_video_context->bind_hw_render(video_context_data, *enable);
case GFX_CTL_SUPPRESS_SCREENSAVER: return true;
{ }
bool *bool_data = (bool*)data;
if (!video_context_data || !current_video_context) bool video_context_driver_set(const gfx_ctx_driver_t *data)
return false; {
if (!current_video_context->suppress_screensaver( if (!data)
video_context_data, *bool_data)) return false;
return false; current_video_context = data;
} return true;
break; }
case GFX_CTL_IDENT_GET:
{ void video_context_driver_destroy(void)
gfx_ctx_ident_t *ident = (gfx_ctx_ident_t*)data; {
ident->ident = NULL; current_video_context = NULL;
if (current_video_context) }
ident->ident = current_video_context->ident;
} bool video_context_driver_update_window_title(void)
break; {
case GFX_CTL_SET_VIDEO_MODE: if (!current_video_context || !current_video_context->update_window_title)
{ return false;
gfx_ctx_mode_t *mode_info = (gfx_ctx_mode_t*)data; current_video_context->update_window_title(video_context_data);
if (!current_video_context || !current_video_context->set_video_mode) return true;
return false; }
if (!current_video_context->set_video_mode(
video_context_data, mode_info->width, bool video_context_driver_swap_buffers(void)
mode_info->height, mode_info->fullscreen)) {
return false; if (!current_video_context || !current_video_context->swap_buffers)
} return false;
break; current_video_context->swap_buffers(video_context_data);
case GFX_CTL_SET_RESIZE: return true;
{ }
gfx_ctx_mode_t *mode_info = (gfx_ctx_mode_t*)data;
if (!current_video_context) bool video_context_driver_focus(void)
return false; {
if (!current_video_context->set_resize( if (!video_context_data || !current_video_context->has_focus)
video_context_data, mode_info->width, mode_info->height)) return false;
return false; if (!current_video_context->has_focus(video_context_data))
} return false;
break; return true;
case GFX_CTL_GET_VIDEO_SIZE: }
{
gfx_ctx_mode_t *mode_info = (gfx_ctx_mode_t*)data; bool video_context_driver_translate_aspect(gfx_ctx_aspect_t *aspect)
if (!current_video_context || !current_video_context->get_video_size) {
return false; if (!video_context_data || !aspect)
current_video_context->get_video_size(video_context_data, &mode_info->width, &mode_info->height); return false;
} if (!current_video_context->translate_aspect)
break; return false;
case GFX_CTL_GET_CONTEXT_DATA: *aspect->aspect = current_video_context->translate_aspect(
{ video_context_data, aspect->width, aspect->height);
if (!current_video_context || !current_video_context->get_context_data) return true;
return false; }
*(void**)data = current_video_context->get_context_data(video_context_data);
} bool video_context_driver_has_windowed(void)
break; {
case GFX_CTL_SHOW_MOUSE: if (!video_context_data)
{ return false;
bool *bool_data = (bool*)data; if (!current_video_context->has_windowed(video_context_data))
if (!current_video_context || !current_video_context->show_mouse) return false;
return false; return true;
current_video_context->show_mouse(video_context_data, *bool_data); }
}
break; void video_context_driver_free(void)
case GFX_CTL_SET_VIDEO_CONTEXT_DATA: {
video_context_data = data; if (current_video_context->destroy)
break; current_video_context->destroy(video_context_data);
case GFX_CTL_GET_FLAGS: current_video_context = NULL;
{ video_context_data = NULL;
gfx_ctx_flags_t *flags = (gfx_ctx_flags_t*)data; }
if (!flags)
return false; bool video_context_driver_get_video_output_size(gfx_ctx_size_t *size_data)
if (!current_video_context || !current_video_context->get_flags) {
return false; if (!size_data)
flags->flags = current_video_context->get_flags(video_context_data); return false;
} if (!current_video_context || !current_video_context->get_video_output_size)
break; return false;
case GFX_CTL_SET_FLAGS: current_video_context->get_video_output_size(video_context_data,
{ size_data->width, size_data->height);
gfx_ctx_flags_t *flags = (gfx_ctx_flags_t*)data; return true;
if (!flags) }
return false;
if (!current_video_context || !current_video_context->set_flags) bool video_context_driver_swap_interval(unsigned *interval)
return false; {
current_video_context->set_flags(video_context_data, flags->flags); if (!current_video_context || !current_video_context->swap_interval)
} return false;
break; current_video_context->swap_interval(video_context_data, *interval);
case GFX_CTL_NONE: return true;
default: }
break;
} bool video_context_driver_get_proc_address(gfx_ctx_proc_address_t *proc)
{
if (!current_video_context || !current_video_context->get_proc_address)
return false;
proc->addr = current_video_context->get_proc_address(proc->sym);
return true; return true;
} }
bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics)
{
if (!current_video_context || !current_video_context->get_metrics)
return false;
if (!current_video_context->get_metrics(video_context_data,
metrics->type,
metrics->value))
return false;
return true;
}
bool video_context_driver_input_driver(gfx_ctx_input_t *inp)
{
if (!current_video_context || !current_video_context->input_driver)
return false;
current_video_context->input_driver(
video_context_data, inp->input, inp->input_data);
return true;
}
bool video_context_driver_suppress_screensaver(bool *bool_data)
{
if (!video_context_data || !current_video_context)
return false;
if (!current_video_context->suppress_screensaver(
video_context_data, *bool_data))
return false;
return true;
}
bool video_context_driver_get_ident(gfx_ctx_ident_t *ident)
{
if (!ident)
return false;
ident->ident = NULL;
if (current_video_context)
ident->ident = current_video_context->ident;
return true;
}
bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info)
{
if (!current_video_context || !current_video_context->set_video_mode)
return false;
if (!current_video_context->set_video_mode(
video_context_data, mode_info->width,
mode_info->height, mode_info->fullscreen))
return false;
return true;
}
bool video_context_driver_set_resize(gfx_ctx_mode_t *mode_info)
{
if (!current_video_context)
return false;
if (!current_video_context->set_resize(
video_context_data, mode_info->width, mode_info->height))
return false;
return true;
}
bool video_context_driver_get_video_size(gfx_ctx_mode_t *mode_info)
{
if (!current_video_context || !current_video_context->get_video_size)
return false;
current_video_context->get_video_size(video_context_data,
&mode_info->width, &mode_info->height);
return true;
}
bool video_context_driver_get_context_data(void *data)
{
if (!current_video_context || !current_video_context->get_context_data)
return false;
*(void**)data = current_video_context->get_context_data(video_context_data);
return true;
}
bool video_context_driver_show_mouse(bool *bool_data)
{
if (!current_video_context || !current_video_context->show_mouse)
return false;
current_video_context->show_mouse(video_context_data, *bool_data);
return true;
}
void video_context_driver_set_data(void *data)
{
video_context_data = data;
}
bool video_context_driver_get_flags(gfx_ctx_flags_t *flags)
{
if (!flags)
return false;
if (!current_video_context || !current_video_context->get_flags)
return false;
flags->flags = current_video_context->get_flags(video_context_data);
return true;
}
bool video_context_driver_set_flags(gfx_ctx_flags_t *flags)
{
if (!flags)
return false;
if (!current_video_context || !current_video_context->set_flags)
return false;
current_video_context->set_flags(video_context_data, flags->flags);
return true;
}

View File

@ -58,44 +58,6 @@ enum display_flags
GFX_CTX_FLAGS_GL_CORE_CONTEXT GFX_CTX_FLAGS_GL_CORE_CONTEXT
}; };
enum gfx_ctx_ctl_state
{
GFX_CTL_NONE = 0,
GFX_CTL_CHECK_WINDOW,
GFX_CTL_FOCUS,
GFX_CTL_DESTROY,
GFX_CTL_FREE,
GFX_CTL_SWAP_BUFFERS,
GFX_CTL_HAS_WINDOWED,
GFX_CTL_UPDATE_WINDOW_TITLE,
GFX_CTL_SHOW_MOUSE,
GFX_CTL_SET,
GFX_CTL_BIND_HW_RENDER,
GFX_CTL_GET_VIDEO_OUTPUT_PREV,
GFX_CTL_GET_VIDEO_OUTPUT_NEXT,
GFX_CTL_IMAGE_BUFFER_INIT,
GFX_CTL_IMAGE_BUFFER_WRITE,
/* Finds next driver in graphics context driver array. */
GFX_CTL_FIND_NEXT_DRIVER,
/* Finds previous driver in graphics context driver array. */
GFX_CTL_FIND_PREV_DRIVER,
GFX_CTL_GET_VIDEO_OUTPUT_SIZE,
GFX_CTL_SWAP_INTERVAL,
GFX_CTL_PROC_ADDRESS_GET,
GFX_CTL_TRANSLATE_ASPECT,
GFX_CTL_GET_FLAGS,
GFX_CTL_SET_FLAGS,
GFX_CTL_GET_METRICS,
GFX_CTL_INPUT_DRIVER,
GFX_CTL_SUPPRESS_SCREENSAVER,
GFX_CTL_IDENT_GET,
GFX_CTL_SET_VIDEO_MODE,
GFX_CTL_SET_RESIZE,
GFX_CTL_GET_VIDEO_SIZE,
GFX_CTL_SET_VIDEO_CONTEXT_DATA,
GFX_CTL_GET_CONTEXT_DATA
};
typedef void (*gfx_ctx_proc_t)(void); typedef void (*gfx_ctx_proc_t)(void);
typedef struct gfx_ctx_driver typedef struct gfx_ctx_driver
@ -284,7 +246,7 @@ extern const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev;
extern const gfx_ctx_driver_t gfx_ctx_null; extern const gfx_ctx_driver_t gfx_ctx_null;
/** /**
* video_driver_context_init_first: * video_context_driver_init_first:
* @data : Input data. * @data : Input data.
* @ident : Identifier of graphics context driver to find. * @ident : Identifier of graphics context driver to find.
* @api : API of higher-level graphics API. * @api : API of higher-level graphics API.
@ -297,10 +259,70 @@ extern const gfx_ctx_driver_t gfx_ctx_null;
* *
* Returns: graphics context driver if found, otherwise NULL. * Returns: graphics context driver if found, otherwise NULL.
**/ **/
const gfx_ctx_driver_t *video_driver_context_init_first(void *data, const char *ident, const gfx_ctx_driver_t *video_context_driver_init_first(void *data, const char *ident,
enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx); enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx);
bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data); bool video_context_driver_check_window(gfx_ctx_size_t *size_data);
bool video_context_driver_find_prev_driver(void);
bool video_context_driver_find_next_driver(void);
bool video_context_driver_init_image_buffer(const video_info_t *data);
bool video_context_driver_write_to_image_buffer(gfx_ctx_image_t *img);
bool video_context_driver_get_video_output_prev(void);
bool video_context_driver_get_video_output_next(void);
bool video_context_driver_bind_hw_render(bool *enable);
bool video_context_driver_set(const gfx_ctx_driver_t *data);
void video_context_driver_destroy(void);
bool video_context_driver_update_window_title(void);
bool video_context_driver_swap_buffers(void);
bool video_context_driver_focus(void);
bool video_context_driver_get_video_output_size(gfx_ctx_size_t *size_data);
bool video_context_driver_swap_interval(unsigned *interval);
bool video_context_driver_get_proc_address(gfx_ctx_proc_address_t *proc);
bool video_context_driver_suppress_screensaver(bool *bool_data);
bool video_context_driver_get_ident(gfx_ctx_ident_t *ident);
bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info);
bool video_context_driver_set_resize(gfx_ctx_mode_t *mode_info);
bool video_context_driver_get_video_size(gfx_ctx_mode_t *mode_info);
bool video_context_driver_get_context_data(void *data);
bool video_context_driver_show_mouse(bool *bool_data);
void video_context_driver_set_data(void *data);
bool video_context_driver_get_flags(gfx_ctx_flags_t *flags);
bool video_context_driver_set_flags(gfx_ctx_flags_t *flags);
bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics);
bool video_context_driver_translate_aspect(gfx_ctx_aspect_t *aspect);
bool video_context_driver_input_driver(gfx_ctx_input_t *inp);
bool video_context_driver_has_windowed(void);
void video_context_driver_free(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -792,7 +792,7 @@ bool video_driver_set_video_mode(unsigned width,
mode.height = height; mode.height = height;
mode.fullscreen = fullscreen; mode.fullscreen = fullscreen;
return gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode); return video_context_driver_set_video_mode(&mode);
} }
bool video_driver_get_video_output_size(unsigned *width, unsigned *height) bool video_driver_get_video_output_size(unsigned *width, unsigned *height)
@ -1496,7 +1496,7 @@ bool video_driver_get_next_video_out(void)
return false; return false;
if (!video_driver_poke->get_video_output_next) if (!video_driver_poke->get_video_output_next)
return gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); return video_context_driver_get_video_output_next();
video_driver_poke->get_video_output_next(video_driver_data); video_driver_poke->get_video_output_next(video_driver_data);
return true; return true;
} }
@ -1507,7 +1507,7 @@ bool video_driver_get_prev_video_out(void)
return false; return false;
if (!video_driver_poke->get_video_output_prev) if (!video_driver_poke->get_video_output_prev)
return gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); return video_context_driver_get_video_output_prev();
video_driver_poke->get_video_output_prev(video_driver_data); video_driver_poke->get_video_output_prev(video_driver_data);
return true; return true;
} }

View File

@ -43,7 +43,7 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t
#ifdef HAVE_CG #ifdef HAVE_CG
gfx_ctx_flags_t flags; gfx_ctx_flags_t flags;
gfx_ctx_ctl(GFX_CTL_GET_FLAGS, &flags); video_context_driver_get_flags(&flags);
if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
{ {

View File

@ -411,7 +411,7 @@ float menu_display_get_dpi(void)
if (settings->menu.dpi.override_enable) if (settings->menu.dpi.override_enable)
return settings->menu.dpi.override_value; return settings->menu.dpi.override_value;
else if (!gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics) || !dpi) else if (!video_context_driver_get_metrics(&metrics) || !dpi)
return menu_dpi_override_value; return menu_dpi_override_value;
return dpi; return dpi;

View File

@ -776,7 +776,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info)
} }
#if defined(HAVE_OPENGL) || defined(HAVE_GLES) #if defined(HAVE_OPENGL) || defined(HAVE_GLES)
gfx_ctx_ctl(GFX_CTL_IDENT_GET, &ident_info); video_context_driver_get_ident(&ident_info);
tmp_string = ident_info.ident; tmp_string = ident_info.ident;
strlcpy(tmp, strlcpy(tmp,
@ -797,7 +797,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info)
metrics.type = DISPLAY_METRIC_MM_WIDTH; metrics.type = DISPLAY_METRIC_MM_WIDTH;
metrics.value = &val; metrics.value = &val;
if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics)) if (video_context_driver_get_metrics(&metrics))
{ {
snprintf(tmp, sizeof(tmp), "%s: %.2f", snprintf(tmp, sizeof(tmp), "%s: %.2f",
menu_hash_to_str( menu_hash_to_str(
@ -809,7 +809,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info)
metrics.type = DISPLAY_METRIC_MM_HEIGHT; metrics.type = DISPLAY_METRIC_MM_HEIGHT;
if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics)) if (video_context_driver_get_metrics(&metrics))
{ {
snprintf(tmp, sizeof(tmp), "%s: %.2f", snprintf(tmp, sizeof(tmp), "%s: %.2f",
menu_hash_to_str( menu_hash_to_str(
@ -821,7 +821,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info)
metrics.type = DISPLAY_METRIC_DPI; metrics.type = DISPLAY_METRIC_DPI;
if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics)) if (video_context_driver_get_metrics(&metrics))
{ {
snprintf(tmp, sizeof(tmp), "%s: %.2f", snprintf(tmp, sizeof(tmp), "%s: %.2f",
menu_hash_to_str( menu_hash_to_str(

View File

@ -1108,7 +1108,7 @@ static int menu_input_pointer_post_iterate(
metrics.type = DISPLAY_METRIC_DPI; metrics.type = DISPLAY_METRIC_DPI;
metrics.value = &dpi; metrics.value = &dpi;
gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics); video_context_driver_get_metrics(&metrics);
if (!pointer_oldpressed[0]) if (!pointer_oldpressed[0])
{ {