From 09dda14549fc13231311fd522a07a75e923889aa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 20 Nov 2015 15:41:20 +0100 Subject: [PATCH] Add RARCH_DISPLAY_CTL_READ_VIEWPORT --- gfx/video_driver.c | 20 ++++++++++---------- gfx/video_driver.h | 3 +-- record/record_driver.c | 2 +- screenshot.c | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 752b82b73e..ace202abf0 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -716,16 +716,6 @@ bool video_driver_viewport_info(struct video_viewport *vp) return false; } -bool video_driver_read_viewport(uint8_t *buffer) -{ - driver_t *driver = driver_get_ptr(); - const video_driver_t *video = video_driver_ctx_get_ptr(driver); - - if (video && video->read_viewport) - return video->read_viewport(driver->video_data, - buffer); - return false; -} #ifdef HAVE_OVERLAY bool video_driver_overlay_interface(const video_overlay_interface_t **iface) @@ -1181,6 +1171,16 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) switch (state) { + case RARCH_DISPLAY_CTL_READ_VIEWPORT: + { + driver_t *driver = driver_get_ptr(); + const video_driver_t *video = video_driver_ctx_get_ptr(driver); + + if (video && video->read_viewport) + return video->read_viewport(driver->video_data, + (uint8_t*)data); + return false; + } case RARCH_DISPLAY_CTL_CACHED_FRAME_HAS_VALID_FB: if (!video_state.frame_cache.data) return false; diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 2cc07c2b77..d3acbf5554 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -225,6 +225,7 @@ enum rarch_display_ctl_state RARCH_DISPLAY_CTL_FRAME_FILTER_IS_32BIT, RARCH_DISPLAY_CTL_HAS_WINDOWED, RARCH_DISPLAY_CTL_IS_FOCUSED, + RARCH_DISPLAY_CTL_READ_VIEWPORT, /* Renders the current video frame. */ RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, RARCH_DISPLAY_CTL_CACHED_FRAME_HAS_VALID_FB, @@ -316,8 +317,6 @@ void video_driver_set_texture_frame(const void *frame, bool rgb32, bool video_driver_viewport_info(struct video_viewport *vp); -bool video_driver_read_viewport(uint8_t *buffer); - bool video_driver_set_shader(enum rarch_shader_type type, const char *path); diff --git a/record/record_driver.c b/record/record_driver.c index 22a0479aa8..3a13d5ed3f 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -205,7 +205,7 @@ void recording_dump_frame(const void *data, unsigned width, /* Big bottleneck. * Since we might need to do read-backs asynchronously, * it might take 3-4 times before this returns true. */ - if (!video_driver_read_viewport(global->record.gpu_buffer)) + if (!video_driver_ctl(RARCH_DISPLAY_CTL_READ_VIEWPORT, global->record.gpu_buffer)) return; ffemu_data.pitch = global->record.gpu_width * 3; diff --git a/screenshot.c b/screenshot.c index 93b5182af7..67079f410a 100644 --- a/screenshot.c +++ b/screenshot.c @@ -143,7 +143,7 @@ static bool take_screenshot_viewport(void) if (!(buffer = (uint8_t*)malloc(vp.width * vp.height * 3))) return false; - if (!video_driver_read_viewport(buffer)) + if (!video_driver_ctl(RARCH_DISPLAY_CTL_READ_VIEWPORT, buffer)) goto done; screenshot_dir = settings->screenshot_directory;