Create GFX_CTL_CHECK_WINDOW

This commit is contained in:
twinaphex 2016-02-13 19:53:14 +01:00
parent b9a5c326cd
commit 46c9ff36ef
5 changed files with 57 additions and 37 deletions

View File

@ -841,14 +841,20 @@ static void d3d_set_nonblock_state(void *data, bool state)
static bool d3d_alive(void *data)
{
unsigned temp_width = 0, temp_height = 0;
bool ret = false;
d3d_video_t *d3d = (d3d_video_t*)data;
bool quit = false;
bool resize = false;
gfx_ctx_size_t size_data;
unsigned temp_width = 0;
unsigned temp_height = 0;
bool ret = false;
d3d_video_t *d3d = (d3d_video_t*)data;
bool quit = false;
bool resize = false;
if (gfx_ctx_check_window(&quit, &resize,
&temp_width, &temp_height))
size_data.quit = &quit;
size_data.resize = &resize;
size_data.width = &temp_width;
size_data.height = &temp_height;
if (gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data))
{
if (quit)
d3d->quitting = quit;

View File

@ -2675,16 +2675,23 @@ error:
static bool gl_alive(void *data)
{
unsigned temp_width = 0, temp_height = 0;
bool ret = false;
bool quit = false, resize = false;
gl_t *gl = (gl_t*)data;
gfx_ctx_size_t size_data;
unsigned temp_width = 0;
unsigned temp_height = 0;
bool ret = false;
bool quit = false;
bool resize = false;
gl_t *gl = (gl_t*)data;
/* Needed because some context drivers don't track their sizes */
video_driver_get_size(&temp_width, &temp_height);
if (gfx_ctx_check_window(&quit,
&resize, &temp_width, &temp_height))
size_data.quit = &quit;
size_data.resize = &resize;
size_data.width = &temp_width;
size_data.height = &temp_height;
if (gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data))
{
if (quit)
gl->quitting = true;

View File

@ -359,12 +359,18 @@ static bool vg_frame(void *data, const void *frame,
static bool vg_alive(void *data)
{
bool quit;
unsigned temp_width = 0, temp_height = 0;
vg_t *vg = (vg_t*)data;
gfx_ctx_size_t size_data;
bool quit = false;
unsigned temp_width = 0;
unsigned temp_height = 0;
vg_t *vg = (vg_t*)data;
gfx_ctx_check_window(&quit,
&vg->should_resize, &temp_width, &temp_height);
size_data.quit = &quit;
size_data.resize = &vg->should_resize;
size_data.width = &temp_width;
size_data.height = &temp_height;
gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data);
if (temp_width != 0 && temp_height != 0)
video_driver_set_size(&temp_width, &temp_height);

View File

@ -137,22 +137,6 @@ retro_proc_address_t gfx_ctx_get_proc_address(const char *sym)
return current_video_context->get_proc_address(sym);
}
bool gfx_ctx_check_window(bool *quit, bool *resize,
unsigned *width, unsigned *height)
{
uint64_t *frame_count;
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
if (!video_context_data)
return false;
current_video_context->check_window(video_context_data, quit,
resize, width, height, (unsigned int)*frame_count);
return true;
}
bool gfx_ctx_suppress_screensaver(bool enable)
{
if (video_context_data && current_video_context)
@ -359,6 +343,23 @@ bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data)
{
switch (state)
{
case GFX_CTL_CHECK_WINDOW:
{
uint64_t *frame_count = NULL;
gfx_ctx_size_t *size_data = (gfx_ctx_size_t*)data;
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
if (!video_context_data)
return false;
current_video_context->check_window(video_context_data,
size_data->quit,
size_data->resize,
size_data->width,
size_data->height, (unsigned int)*frame_count);
}
break;
case GFX_CTL_FIND_PREV_DRIVER:
return gfx_ctl_find_prev_driver();
case GFX_CTL_FIND_NEXT_DRIVER:

View File

@ -54,6 +54,7 @@ enum display_metric_types
enum gfx_ctx_ctl_state
{
GFX_CTL_NONE = 0,
GFX_CTL_CHECK_WINDOW,
GFX_CTL_FOCUS,
GFX_CTL_DESTROY,
GFX_CTL_FREE,
@ -173,6 +174,8 @@ typedef struct gfx_ctx_driver
typedef struct gfx_ctx_size
{
bool *quit;
bool *resize;
unsigned *width;
unsigned *height;
} gfx_ctx_size_t;
@ -225,9 +228,6 @@ bool gfx_ctx_image_buffer_write(const void *frame,
unsigned width, unsigned height, unsigned pitch, bool rgb32,
unsigned index, void **image_handle);
bool gfx_ctx_check_window(bool *quit, bool *resize,
unsigned *width, unsigned *height);
bool gfx_ctx_suppress_screensaver(bool enable);
void gfx_ctx_get_video_size(unsigned *width, unsigned *height);