driver->video_context should be self-contained now to video_context_driver.c

This commit is contained in:
twinaphex 2015-11-23 21:20:21 +01:00
parent 0520a1b3c7
commit 6f18656baa
5 changed files with 34 additions and 14 deletions

View File

@ -764,7 +764,7 @@ static void *d3d_init(const video_info_t *info,
if (input && input_data) if (input && input_data)
{ {
*input = driver->input; *input = driver->input;
*input_data = driver->input_data; *input_data = driver->input_data;
} }
@ -799,7 +799,7 @@ static void *d3d_init(const video_info_t *info,
#endif #endif
#endif #endif
driver->video_context = ctx; gfx_ctx_set(ctx);
if (!d3d_construct(vid, info, input, input_data)) if (!d3d_construct(vid, info, input, input_data))
{ {
@ -819,8 +819,7 @@ static void *d3d_init(const video_info_t *info,
error: error:
if (vid) if (vid)
delete vid; delete vid;
if (driver) gfx_ctx_destroy(ctx);
driver->video_context = NULL;
return NULL; return NULL;
} }

View File

@ -2409,16 +2409,14 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
{ {
unsigned win_width, win_height, temp_width = 0, temp_height = 0; unsigned win_width, win_height, temp_width = 0, temp_height = 0;
bool force_smooth = false; bool force_smooth = false;
gl_t *gl = NULL;
const gfx_ctx_driver_t *ctx_driver = NULL; const gfx_ctx_driver_t *ctx_driver = NULL;
const char *vendor = NULL; const char *vendor = NULL;
const char *renderer = NULL; const char *renderer = NULL;
const char *version = NULL; const char *version = NULL;
struct retro_hw_render_callback *hw_render = NULL; struct retro_hw_render_callback *hw_render = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
driver_t *driver = driver_get_ptr(); driver_t *driver = driver_get_ptr();
gl_t *gl = (gl_t*)calloc(1, sizeof(gl_t));
gl = (gl_t*)calloc(1, sizeof(gl_t));
if (!gl) if (!gl)
return NULL; return NULL;
@ -2426,7 +2424,8 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
if (!ctx_driver) if (!ctx_driver)
goto error; goto error;
driver->video_context = ctx_driver; gfx_ctx_set(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);
@ -2631,8 +2630,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
return gl; return gl;
error: error:
if (ctx_driver) gfx_ctx_destroy(ctx_driver);
ctx_driver->destroy(gl);
free(gl); free(gl);
return NULL; return NULL;
} }

View File

@ -99,7 +99,7 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
if (!ctx) if (!ctx)
goto error; goto error;
driver->video_context = ctx; gfx_ctx_set(ctx);
gfx_ctx_get_video_size(vg, &temp_width, &temp_height); gfx_ctx_get_video_size(vg, &temp_width, &temp_height);
RARCH_LOG("Detecting screen resolution %ux%u.\n", temp_width, temp_height); RARCH_LOG("Detecting screen resolution %ux%u.\n", temp_width, temp_height);
@ -199,8 +199,7 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
error: error:
if (vg) if (vg)
free(vg); free(vg);
if (driver) gfx_ctx_destroy(ctx);
driver->video_context = NULL;
return NULL; return NULL;
} }

View File

@ -85,6 +85,26 @@ void *gfx_ctx_data_get_ptr(void)
return video_context_data; return video_context_data;
} }
void gfx_ctx_set(const gfx_ctx_driver_t *ctx_driver)
{
driver_t *driver = driver_get_ptr();
if (!driver || !ctx_driver)
return;
driver->video_context = ctx_driver;
}
void gfx_ctx_destroy(const gfx_ctx_driver_t *ctx_driver)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (ctx_driver)
gfx_ctx_destroy(ctx_driver);
driver->video_context = NULL;
}
void gfx_ctx_data_set(void *ptr) void gfx_ctx_data_set(void *ptr)
{ {
if (!ptr) if (!ptr)

View File

@ -260,6 +260,10 @@ void gfx_ctx_data_set(void *ptr);
void gfx_ctx_free_data(void); void gfx_ctx_free_data(void);
void gfx_ctx_set(const gfx_ctx_driver_t *ctx_driver);
void gfx_ctx_destroy(const gfx_ctx_driver_t *ctx_driver);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif