Create video_driver_viewport_info

This commit is contained in:
twinaphex 2015-03-22 21:28:50 +01:00
parent ecf6b2c702
commit e3eb9fe9f0
9 changed files with 59 additions and 27 deletions

View File

@ -231,7 +231,7 @@ uintptr_t video_driver_get_current_framebuffer(void)
{
#ifdef HAVE_FBO
driver_t *driver = driver_get_ptr();
if (driver->video_poke && driver->video_poke->get_current_framebuffer)
if (driver && driver->video_poke && driver->video_poke->get_current_framebuffer)
return driver->video_poke->get_current_framebuffer(driver->video_data);
#endif
return 0;
@ -240,7 +240,7 @@ uintptr_t video_driver_get_current_framebuffer(void)
retro_proc_address_t video_driver_get_proc_address(const char *sym)
{
driver_t *driver = driver_get_ptr();
if (driver && driver->video_poke && driver->video_poke->get_proc_address)
if (driver && driver && driver->video_poke && driver->video_poke->get_proc_address)
return driver->video_poke->get_proc_address(driver->video_data, sym);
return NULL;
}
@ -540,7 +540,7 @@ void init_video(void)
/* Force custom viewport to have sane parameters. */
custom_vp->width = width;
custom_vp->height = height;
driver->video->viewport_info(driver->video_data, custom_vp);
video_driver_viewport_info(custom_vp);
}
video_driver_set_rotation(
@ -572,6 +572,8 @@ bool video_driver_has_windowed(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return false;
if (!driver->video)
return false;
@ -586,6 +588,8 @@ void video_driver_set_nonblock_state(bool toggle)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (!driver->video)
return;
@ -597,6 +601,8 @@ bool video_driver_set_rotation(unsigned rotation)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return false;
if (!driver->video)
return false;
if (!driver->video->set_rotation)
@ -612,6 +618,8 @@ void video_driver_set_video_mode(unsigned width,
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (!driver->video_data)
return;
if (!driver->video_poke)
@ -627,6 +635,8 @@ bool video_driver_get_video_output_size(unsigned *width, unsigned *height)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return false;
if (!driver->video_data)
return false;
if (!driver->video_poke)
@ -643,6 +653,8 @@ void video_driver_set_aspect_ratio(unsigned aspectratio_index)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (!driver->video_data)
return;
if (!driver->video_poke)
@ -658,6 +670,8 @@ void video_driver_show_mouse(bool state)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (!driver->video_data)
return;
if (!driver->video_poke)
@ -673,6 +687,8 @@ void video_driver_set_osd_msg(const char *msg,
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (!driver->video_data)
return;
if (!driver->video_poke)
@ -688,6 +704,8 @@ void video_driver_set_texture_enable(bool enable, bool fullscreen)
#ifdef HAVE_MENU
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (!driver->video_data)
return;
if (!driver->video_poke)
@ -705,6 +723,8 @@ void video_driver_set_texture_frame(const void *frame, bool rgb32,
#ifdef HAVE_MENU
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (!driver->video_data)
return;
if (!driver->video_poke)
@ -715,3 +735,21 @@ void video_driver_set_texture_frame(const void *frame, bool rgb32,
driver->video_data, frame, rgb32, width, height, alpha);
#endif
}
bool video_driver_viewport_info(struct video_viewport *vp)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return false;
if (!driver->video_data)
return false;
if (!driver->video)
return false;
if (!driver->video->viewport_info)
return false;
driver->video->viewport_info(driver->video_data, vp);
return true;
}

View File

@ -296,6 +296,8 @@ void video_driver_set_texture_enable(bool enable, bool full_screen);
void video_driver_set_texture_frame(const void *frame, bool rgb32,
unsigned width, unsigned height, float alpha);
bool video_driver_viewport_info(struct video_viewport *vp);
#ifdef __cplusplus
}
#endif

View File

@ -295,12 +295,13 @@ static void x_input_poll_mouse(x11_input_t *x11)
/* Somewhat hacky, but seem to do the job. */
if (x11->grab_mouse && driver->video->focus(driver->video_data))
{
int mid_w, mid_h;
struct video_viewport vp = {0};
if (driver->video && driver->video->viewport_info)
driver->video->viewport_info(driver->video_data, &vp);
int mid_w = vp.full_width >> 1;
int mid_h = vp.full_height >> 1;
video_driver_viewport_info(&vp);
mid_w = vp.full_width >> 1;
mid_h = vp.full_height >> 1;
if (x11->mouse_x != mid_w || x11->mouse_y != mid_h)
{

View File

@ -133,16 +133,10 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y,
{
int scaled_screen_x, scaled_screen_y, scaled_x, scaled_y;
struct video_viewport vp = {0};
bool have_viewport_info = false;
driver_t *driver = driver_get_ptr();
have_viewport_info = driver->video && driver->video->viewport_info;
if (!have_viewport_info)
if (!video_driver_viewport_info(&vp))
return false;
driver->video->viewport_info(driver->video_data, &vp);
scaled_screen_x = (2 * mouse_x * 0x7fff) / (int)vp.full_width - 0x7fff;
scaled_screen_y = (2 * mouse_y * 0x7fff) / (int)vp.full_height - 0x7fff;
if (scaled_screen_x < -0x7fff || scaled_screen_x > 0x7fff)

View File

@ -461,10 +461,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action)
if (!settings->video.scale_integer)
{
video_viewport_t vp;
if (driver->video_data && driver->video &&
driver->video->viewport_info)
driver->video->viewport_info(driver->video_data, &vp);
video_driver_viewport_info(&vp);
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT)
{

View File

@ -881,9 +881,7 @@ static int action_ok_custom_viewport(const char *path,
MENU_SETTINGS_CUSTOM_VIEWPORT,
idx);
if (driver->video_data && driver->video &&
driver->video->viewport_info)
driver->video->viewport_info(driver->video_data, custom);
video_driver_viewport_info(custom);
aspectratio_lut[ASPECT_RATIO_CUSTOM].value =
(float)custom->width / custom->height;

View File

@ -107,8 +107,7 @@ void recording_dump_frame(const void *data, unsigned width,
{
struct video_viewport vp = {0};
if (driver->video && driver->video->viewport_info)
driver->video->viewport_info(driver->video_data, &vp);
video_driver_viewport_info(&vp);
if (!vp.width || !vp.height)
{
@ -230,8 +229,7 @@ bool recording_init(void)
{
struct video_viewport vp = {0};
if (driver->video && driver->video->viewport_info)
driver->video->viewport_info(driver->video_data, &vp);
video_driver_viewport_info(&vp);
if (!vp.width || !vp.height)
{

View File

@ -183,8 +183,7 @@ static bool take_screenshot_viewport(void)
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
if (driver->video && driver->video->viewport_info)
driver->video->viewport_info(driver->video_data, &vp);
video_driver_viewport_info(&vp);
if (!vp.width || !vp.height)
return false;

View File

@ -511,3 +511,8 @@ void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration
bool flush)
{
}
bool video_driver_viewport_info(struct video_viewport *vp)
{
return false;
}