Dont' try to access driver->video_context_data directly

This commit is contained in:
twinaphex 2015-11-23 20:56:06 +01:00
parent 41b46975f9
commit 1f87c6d9e2
7 changed files with 41 additions and 67 deletions

View File

@ -135,8 +135,8 @@ static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx)
static void gfx_ctx_glx_destroy(void *data) static void gfx_ctx_glx_destroy(void *data)
{ {
driver_t *driver = driver_get_ptr(); gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data; gfx_ctx_data_get_ptr();
if (!glx) if (!glx)
return; return;
@ -144,16 +144,13 @@ static void gfx_ctx_glx_destroy(void *data)
(void)data; (void)data;
ctx_glx_destroy_resources(glx); ctx_glx_destroy_resources(glx);
gfx_ctx_free_data();
if (driver->video_context_data)
free(driver->video_context_data);
driver->video_context_data = NULL;
} }
static void gfx_ctx_glx_swap_interval(void *data, unsigned interval) static void gfx_ctx_glx_swap_interval(void *data, unsigned interval)
{ {
driver_t *driver = driver_get_ptr(); gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data; gfx_ctx_data_get_ptr();
glx->g_interval = interval; glx->g_interval = interval;
@ -178,9 +175,8 @@ static void gfx_ctx_glx_swap_interval(void *data, unsigned interval)
static void gfx_ctx_glx_swap_buffers(void *data) static void gfx_ctx_glx_swap_buffers(void *data)
{ {
driver_t *driver = driver_get_ptr(); gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data;
if (glx->g_is_double) if (glx->g_is_double)
glXSwapBuffers(g_x11_dpy, glx->g_glx_win); glXSwapBuffers(g_x11_dpy, glx->g_glx_win);
@ -289,8 +285,9 @@ static bool gfx_ctx_glx_set_video_mode(void *data,
XSetWindowAttributes swa = {0}; XSetWindowAttributes swa = {0};
int (*old_handler)(Display*, XErrorEvent*) = NULL; int (*old_handler)(Display*, XErrorEvent*) = NULL;
driver_t *driver = driver_get_ptr(); driver_t *driver = driver_get_ptr();
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)
gfx_ctx_data_get_ptr();
x11_install_sighandlers(); x11_install_sighandlers();
@ -578,8 +575,8 @@ static void gfx_ctx_glx_show_mouse(void *data, bool state)
static void gfx_ctx_glx_bind_hw_render(void *data, bool enable) static void gfx_ctx_glx_bind_hw_render(void *data, bool enable)
{ {
driver_t *driver = driver_get_ptr(); gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)driver->video_context_data; gfx_ctx_data_get_ptr();
if (!glx) if (!glx)
return; return;

View File

@ -207,8 +207,8 @@ static void gfx_ctx_ps3_update_window_title(void *data)
static void gfx_ctx_ps3_get_video_size(void *data, static void gfx_ctx_ps3_get_video_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height)
{ {
driver_t *driver = driver_get_ptr(); gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*)
gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*)driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data; (void)data;
@ -327,8 +327,8 @@ static void gfx_ctx_ps3_destroy_resources(gfx_ctx_ps3_data_t *ps3)
static void gfx_ctx_ps3_destroy(void *data) static void gfx_ctx_ps3_destroy(void *data)
{ {
driver_t *driver = driver_get_ptr(); gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*)
gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*)driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data; (void)data;
@ -337,9 +337,7 @@ static void gfx_ctx_ps3_destroy(void *data)
gfx_ctx_ps3_destroy_resources(ps3); gfx_ctx_ps3_destroy_resources(ps3);
if (driver->video_context_data) gfx_ctx_free_data();
free(driver->video_context_data);
driver->video_context_data = NULL;
} }
static void gfx_ctx_ps3_input_driver(void *data, static void gfx_ctx_ps3_input_driver(void *data,

View File

@ -111,8 +111,7 @@ error:
static void sdl_ctx_destroy(void *data) static void sdl_ctx_destroy(void *data)
{ {
driver_t *driver = driver_get_ptr(); gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)gfx_ctx_data_get_ptr();
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data;
if (!sdl) if (!sdl)
return; return;
@ -120,10 +119,7 @@ static void sdl_ctx_destroy(void *data)
(void)data; (void)data;
sdl_ctx_destroy_resources(sdl); sdl_ctx_destroy_resources(sdl);
gfx_ctx_free_data();
if (driver->video_context_data)
free(driver->video_context_data);
driver->video_context_data = NULL;
} }
static bool sdl_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, static bool sdl_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major,
@ -172,7 +168,7 @@ static bool sdl_ctx_set_video_mode(void *data, unsigned width, unsigned height,
unsigned fsflag = 0; unsigned fsflag = 0;
driver_t *driver = driver_get_ptr(); driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data; gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)gfx_ctx_data_get_ptr();
(void)data; (void)data;
@ -242,7 +238,7 @@ static void sdl_ctx_get_video_size(void *data,
{ {
driver_t *driver = driver_get_ptr(); driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data; gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)gfx_ctx_data_get_ptr();
if (!sdl) if (!sdl)
return; return;
@ -279,9 +275,8 @@ static void sdl_ctx_update_window_title(void *data)
{ {
char buf[128] = {0}; char buf[128] = {0};
char buf_fps[128] = {0}; char buf_fps[128] = {0};
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data; gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)gfx_ctx_data_get_ptr();
if (!sdl) if (!sdl)
return; return;
@ -303,8 +298,7 @@ static void sdl_ctx_check_window(void *data, bool *quit, bool *resize,unsigned *
unsigned *height, unsigned frame_count) unsigned *height, unsigned frame_count)
{ {
SDL_Event event; SDL_Event event;
driver_t *driver = driver_get_ptr(); gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)gfx_ctx_data_get_ptr();
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data;
(void)data; (void)data;
@ -367,8 +361,7 @@ static bool sdl_ctx_has_focus(void *data)
unsigned flags; unsigned flags;
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
driver_t *driver = driver_get_ptr(); gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)gfx_ctx_data_get_ptr();
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data;
flags = (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS); flags = (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS);
return (SDL_GetWindowFlags(sdl->g_win) & flags) == flags; return (SDL_GetWindowFlags(sdl->g_win) & flags) == flags;
#else #else
@ -395,8 +388,7 @@ static bool sdl_ctx_has_windowed(void *data)
static void sdl_ctx_swap_buffers(void *data) static void sdl_ctx_swap_buffers(void *data)
{ {
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
driver_t *driver = driver_get_ptr(); gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)gfx_ctx_data_get_ptr();
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data;
SDL_GL_SwapWindow(sdl->g_win); SDL_GL_SwapWindow(sdl->g_win);
#else #else
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();

View File

@ -65,9 +65,8 @@ static void shell_surface_handle_configure(void *data,
struct wl_shell_surface *shell_surface, struct wl_shell_surface *shell_surface,
uint32_t edges, int32_t width, int32_t height) uint32_t edges, int32_t width, int32_t height)
{ {
driver_t *driver = driver_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data; (void)data;
(void)shell_surface; (void)shell_surface;
@ -97,9 +96,8 @@ static const struct wl_shell_surface_listener shell_surface_listener = {
static void registry_handle_global(void *data, struct wl_registry *reg, static void registry_handle_global(void *data, struct wl_registry *reg,
uint32_t id, const char *interface, uint32_t version) uint32_t id, const char *interface, uint32_t version)
{ {
driver_t *driver = driver_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data; (void)data;
(void)version; (void)version;
@ -169,9 +167,8 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl)
static void flush_wayland_fd(void) static void flush_wayland_fd(void)
{ {
struct pollfd fd = {0}; struct pollfd fd = {0};
driver_t *driver = driver_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data; gfx_ctx_data_get_ptr();
wl_display_dispatch_pending(wl->g_dpy); wl_display_dispatch_pending(wl->g_dpy);
wl_display_flush(wl->g_dpy); wl_display_flush(wl->g_dpy);
@ -221,9 +218,8 @@ static void gfx_ctx_wl_check_window(void *data, bool *quit,
static void gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height)
{ {
driver_t *driver = driver_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data; (void)data;
@ -234,10 +230,9 @@ static void gfx_ctx_wl_update_window_title(void *data)
{ {
char buf[128] = {0}; char buf[128] = {0};
char buf_fps[128] = {0}; char buf_fps[128] = {0};
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data; (void)data;
@ -252,9 +247,8 @@ static void gfx_ctx_wl_update_window_title(void *data)
static void gfx_ctx_wl_get_video_size(void *data, static void gfx_ctx_wl_get_video_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height)
{ {
driver_t *driver = driver_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data; (void)data;
@ -384,9 +378,7 @@ error:
if (wl) if (wl)
free(wl); free(wl);
if (driver->video_context_data) gfx_ctx_free_data();
free(driver->video_context_data);
driver->video_context_data = NULL;
return false; return false;
} }
@ -455,9 +447,8 @@ static EGLint *egl_fill_attribs(EGLint *attr)
static void gfx_ctx_wl_destroy(void *data) static void gfx_ctx_wl_destroy(void *data)
{ {
driver_t *driver = driver_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data; gfx_ctx_data_get_ptr();
(void)data; (void)data;
@ -466,9 +457,7 @@ static void gfx_ctx_wl_destroy(void *data)
gfx_ctx_wl_destroy_resources(wl); gfx_ctx_wl_destroy_resources(wl);
if (driver->video_context_data) gfx_ctx_free_data();
free(driver->video_context_data);
driver->video_context_data = NULL;
} }
static bool gfx_ctx_wl_set_video_mode(void *data, static bool gfx_ctx_wl_set_video_mode(void *data,
@ -476,10 +465,9 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
bool fullscreen) bool fullscreen)
{ {
EGLint egl_attribs[16]; EGLint egl_attribs[16];
driver_t *driver = driver_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data;
EGLint *attr = NULL; EGLint *attr = NULL;
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
gfx_ctx_data_get_ptr();
egl_install_sighandlers(); egl_install_sighandlers();
@ -696,9 +684,8 @@ static const struct wl_pointer_listener pointer_listener = {
static void seat_handle_capabilities(void *data, static void seat_handle_capabilities(void *data,
struct wl_seat *seat, unsigned caps) struct wl_seat *seat, unsigned caps)
{ {
driver_t *driver = driver_get_ptr();
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
driver->video_context_data; gfx_ctx_data_get_ptr();
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !wl->g_wl_keyboard) if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !wl->g_wl_keyboard)
{ {

View File

@ -79,7 +79,7 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
}; };
const void *gfx_ctx_data_get_ptr(void) void *gfx_ctx_data_get_ptr(void)
{ {
driver_t *driver = driver_get_ptr(); driver_t *driver = driver_get_ptr();
if (!driver) if (!driver)

View File

@ -254,7 +254,7 @@ void gfx_ctx_input_driver(void *data,
retro_proc_address_t gfx_ctx_get_proc_address(const char *sym); retro_proc_address_t gfx_ctx_get_proc_address(const char *sym);
const void *gfx_ctx_data_get_ptr(void); void *gfx_ctx_data_get_ptr(void);
void gfx_ctx_free_data(void); void gfx_ctx_free_data(void);

View File

@ -800,7 +800,7 @@ bool video_driver_set_video_mode(unsigned width,
return true; return true;
} }
return gfx_ctx_set_video_mode(driver->video_context_data, width, height, fullscreen); return gfx_ctx_set_video_mode(gfx_ctx_data_get_ptr(), width, height, fullscreen);
} }
bool video_driver_get_video_output_size(unsigned *width, unsigned *height) bool video_driver_get_video_output_size(unsigned *width, unsigned *height)
@ -1467,14 +1467,14 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
poke->get_video_output_next(video_data); poke->get_video_output_next(video_data);
return true; return true;
} }
return gfx_ctx_get_video_output_next(driver->video_context_data); return gfx_ctx_get_video_output_next(gfx_ctx_data_get_ptr());
case RARCH_DISPLAY_CTL_GET_PREV_VIDEO_OUT: case RARCH_DISPLAY_CTL_GET_PREV_VIDEO_OUT:
if (poke && poke->get_video_output_prev) if (poke && poke->get_video_output_prev)
{ {
poke->get_video_output_prev(video_data); poke->get_video_output_prev(video_data);
return true; return true;
} }
return gfx_ctx_get_video_output_next(driver->video_context_data); return gfx_ctx_get_video_output_next(gfx_ctx_data_get_ptr());
case RARCH_DISPLAY_CTL_INIT: case RARCH_DISPLAY_CTL_INIT:
return init_video(); return init_video();
case RARCH_DISPLAY_CTL_DEINIT: case RARCH_DISPLAY_CTL_DEINIT: