From f1a572822bb419913c7000c2818602483edd6321 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 14 Feb 2016 05:42:27 +0100 Subject: [PATCH] Create RARCH_DISPLAY_CTL_VIEWPORT_INFO --- gfx/video_driver.c | 15 +++++++-------- gfx/video_driver.h | 5 ++--- input/drivers/x11_input.c | 2 +- input/input_driver.c | 2 +- menu/menu_input.c | 2 +- menu/menu_setting.c | 14 +++++++------- record/record_driver.c | 4 ++-- screenshot.c | 2 +- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 681f075727..fa0a738b5a 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -742,7 +742,8 @@ static bool init_video(void) /* Force custom viewport to have sane parameters. */ custom_vp->width = width; custom_vp->height = height; - video_driver_viewport_info(custom_vp); + + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, custom_vp); } video_driver_set_rotation( @@ -841,13 +842,6 @@ void video_driver_set_texture_frame(const void *frame, bool rgb32, #endif } -bool video_driver_viewport_info(struct video_viewport *vp) -{ - if (!current_video || !current_video->viewport_info) - return false; - current_video->viewport_info(video_driver_data, vp); - return true; -} #ifdef HAVE_OVERLAY @@ -1728,6 +1722,11 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) return false; return video_driver_poke->get_current_software_framebuffer( video_driver_data, (struct retro_framebuffer *)data); + case RARCH_DISPLAY_CTL_VIEWPORT_INFO: + if (!current_video || !current_video->viewport_info) + return false; + current_video->viewport_info(video_driver_data, (struct video_viewport*)data); + break; case RARCH_DISPLAY_CTL_NONE: default: break; diff --git a/gfx/video_driver.h b/gfx/video_driver.h index be738ee734..a448282669 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -156,7 +156,8 @@ enum rarch_display_ctl_state RARCH_DISPLAY_CTL_GPU_RECORD_GET, RARCH_DISPLAY_CTL_GPU_RECORD_INIT, RARCH_DISPLAY_CTL_GPU_RECORD_DEINIT, - RARCH_DISPLAY_CTL_GET_CURRENT_SOFTWARE_FRAMEBUFFER + RARCH_DISPLAY_CTL_GET_CURRENT_SOFTWARE_FRAMEBUFFER, + RARCH_DISPLAY_CTL_VIEWPORT_INFO }; typedef struct video_info @@ -402,8 +403,6 @@ 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); - bool video_driver_set_shader(enum rarch_shader_type type, const char *path); diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index e2affb9b8c..1354788c24 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -317,7 +317,7 @@ static void x_input_poll_mouse(x11_input_t *x11) int mid_w, mid_h; struct video_viewport vp = {0}; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); mid_w = vp.full_width >> 1; mid_h = vp.full_height >> 1; diff --git a/input/input_driver.c b/input/input_driver.c index d2a678146b..df8df2c1dd 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -369,7 +369,7 @@ 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}; - if (!video_driver_viewport_info(&vp)) + if (!video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp)) return false; scaled_screen_x = (2 * mouse_x * 0x7fff) / (int)vp.full_width - 0x7fff; diff --git a/menu/menu_input.c b/menu/menu_input.c index dd8ca29101..f0ee93b48a 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -784,7 +784,7 @@ static int menu_input_mouse(unsigned *action) const struct retro_keybind *binds[MAX_USERS]; menu_input_t *menu_input = menu_input_get_ptr(); - if (!video_driver_viewport_info(&vp)) + if (!video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp)) return -1; if (menu_input->mouse.hwheeldown) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index b9cb6666e6..08d70d6942 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -568,7 +568,7 @@ static int setting_uint_action_left_custom_viewport_width(void *data, bool wrapa if (!settings || !av_info) return -1; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (custom->width <= 1) custom->width = 1; @@ -595,7 +595,7 @@ static int setting_uint_action_right_custom_viewport_width(void *data, bool wrap if (!settings || !av_info) return -1; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (settings->video.scale_integer) custom->width += geom->base_width; @@ -620,7 +620,7 @@ static int setting_uint_action_left_custom_viewport_height(void *data, bool wrap if (!settings || !av_info) return -1; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (custom->height <= 1) custom->height = 1; @@ -647,7 +647,7 @@ static int setting_uint_action_right_custom_viewport_height(void *data, bool wra if (!settings || !av_info) return -1; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (settings->video.scale_integer) custom->height += geom->base_height; @@ -2158,7 +2158,7 @@ static int setting_action_start_custom_viewport_width(void *data) if (!settings || !av_info) return -1; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (settings->video.scale_integer) custom->width = ((custom->width + geom->base_width - 1) / @@ -2184,7 +2184,7 @@ static int setting_action_start_custom_viewport_height(void *data) if (!settings || !av_info) return -1; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (settings->video.scale_integer) custom->height = ((custom->height + geom->base_height - 1) / @@ -2855,7 +2855,7 @@ void general_write_handler(void *data) struct retro_game_geometry *geom = (struct retro_game_geometry*) &av_info->geometry; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (*setting->value.boolean) { diff --git a/record/record_driver.c b/record/record_driver.c index 336f167dc4..31349d4ee5 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -192,7 +192,7 @@ void recording_dump_frame(const void *data, unsigned width, uint8_t *gpu_buf = NULL; struct video_viewport vp = {0}; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (!vp.width || !vp.height) { @@ -350,7 +350,7 @@ bool recording_init(void) unsigned gpu_size; struct video_viewport vp = {0}; - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (!vp.width || !vp.height) { diff --git a/screenshot.c b/screenshot.c index d53e7e0961..6c4b991400 100644 --- a/screenshot.c +++ b/screenshot.c @@ -128,7 +128,7 @@ static bool take_screenshot_viewport(void) settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - video_driver_viewport_info(&vp); + video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); if (!vp.width || !vp.height) return false;