From ac8d58b7bbcf81c96feb292fa88ed313e9c667d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2015 21:13:25 +0200 Subject: [PATCH] Create video_driver_cached_frame_set --- gfx/video_driver.c | 19 +++++++++++++++---- gfx/video_driver.h | 3 +++ libretro_version_1.c | 5 +---- screenshot.c | 6 ++---- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 673176f254..0f99a074a7 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -617,10 +617,7 @@ void init_video(void) event_command(EVENT_CMD_OVERLAY_DEINIT); event_command(EVENT_CMD_OVERLAY_INIT); - global->frame_cache.width = 4; - global->frame_cache.height = 4; - global->frame_cache.pitch = 8; - global->frame_cache.data = &dummy_pixels; + video_driver_cached_frame_set(&dummy_pixels, 4, 4, 8); #if defined(PSP) video_driver_set_texture_frame(&dummy_pixels, false, 1, 1, 1.0f); @@ -898,6 +895,20 @@ void video_driver_cached_frame(void) driver->recording_data = recording; } +void video_driver_cached_frame_set(const void *data, unsigned width, + unsigned height, size_t pitch) +{ + global_t *global = global_get_ptr(); + + if (!global) + return; + + global->frame_cache.data = data; + global->frame_cache.width = width; + global->frame_cache.height = height; + global->frame_cache.pitch = pitch; +} + void video_driver_get_size(unsigned *width, unsigned *height) { if (width) diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 1fde52b3b7..015886c632 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -381,6 +381,9 @@ void video_driver_set_pixel_format(enum retro_pixel_format fmt); **/ void video_driver_cached_frame(void); +void video_driver_cached_frame_set(const void *data, unsigned width, + unsigned height, size_t pitch); + #ifdef __cplusplus } #endif diff --git a/libretro_version_1.c b/libretro_version_1.c index bcf75f448d..8e1dc136ba 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -94,10 +94,7 @@ static void video_frame(const void *data, unsigned width, if (!driver->video_active) return; - global->frame_cache.data = data; - global->frame_cache.width = width; - global->frame_cache.height = height; - global->frame_cache.pitch = pitch; + video_driver_cached_frame_set(data, width, height, pitch); if (video_frame_scale(data, width, height, pitch)) { diff --git a/screenshot.c b/screenshot.c index 518c1879be..8e8a52938c 100644 --- a/screenshot.c +++ b/screenshot.c @@ -307,10 +307,8 @@ bool take_screenshot(void) else ret = false; - global->frame_cache.data = old_data; - global->frame_cache.width = old_width; - global->frame_cache.height = old_height; - global->frame_cache.pitch = old_pitch; + video_driver_cached_frame_set(old_data, + old_width, old_height, old_pitch); } else {