From cf2c0f69302cab03b09dc6e358b210c686e6f95d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2015 21:06:44 +0200 Subject: [PATCH] Rename rarch_render_cached_frame to video_driver_cached_frame --- command_event.c | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/sdl2_gfx.c | 7 ++++--- gfx/video_driver.c | 33 +++++++++++++++++++++++++++++++++ gfx/video_driver.h | 7 +++++++ gfx/video_thread_wrapper.c | 2 +- menu/menu_display.c | 2 +- retroarch.c | 33 --------------------------------- retroarch.h | 7 ------- runloop.c | 4 ++-- screenshot.c | 4 ++-- 11 files changed, 52 insertions(+), 51 deletions(-) diff --git a/command_event.c b/command_event.c index 412b6c895d..62710f4664 100644 --- a/command_event.c +++ b/command_event.c @@ -1362,7 +1362,7 @@ bool event_command(enum event_command cmd) event_command(EVENT_CMD_AUDIO_STOP); if (settings->video.black_frame_insertion) - rarch_render_cached_frame(); + video_driver_cached_frame(); } else { diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 883c315a26..cb25663868 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2784,7 +2784,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) goto error; } - rarch_render_cached_frame(); + video_driver_cached_frame(); dst = buffer; src = (const uint8_t*)gl->readback_buffer_screenshot; diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index dd5d4d2b42..5f2ce5ceba 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -605,15 +605,16 @@ static void sdl2_gfx_viewport_info(void *data, struct video_viewport *vp) static bool sdl2_gfx_read_viewport(void *data, uint8_t *buffer) { + SDL_Surface *surf = NULL, *bgr24 = NULL; sdl2_video_t *vid = (sdl2_video_t*)data; RARCH_PERFORMANCE_INIT(sdl2_gfx_read_viewport); RARCH_PERFORMANCE_START(sdl2_gfx_read_viewport); - rarch_render_cached_frame(); + video_driver_cached_frame(); - SDL_Surface *surf = SDL_GetWindowSurface(vid->window); - SDL_Surface *bgr24 = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_BGR24, 0); + surf = SDL_GetWindowSurface(vid->window); + bgr24 = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_BGR24, 0); if (!bgr24) { diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 787d61fa7e..673176f254 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -865,6 +865,39 @@ bool video_driver_frame(const void *frame, unsigned width, return false; } +/** + * video_driver_cached_frame: + * + * Renders the current video frame. + **/ +void video_driver_cached_frame(void) +{ + driver_t *driver = driver_get_ptr(); + global_t *global = global_get_ptr(); + runloop_t *runloop = rarch_main_get_ptr(); + void *recording = driver ? driver->recording_data : NULL; + + if (runloop->is_idle) + return; + + /* Cannot allow recording when pushing duped frames. */ + driver->recording_data = NULL; + + /* Not 100% safe, since the library might have + * freed the memory, but no known implementations do this. + * It would be really stupid at any rate ... + */ + if (driver->retro_ctx.frame_cb) + driver->retro_ctx.frame_cb( + (global->frame_cache.data == RETRO_HW_FRAME_BUFFER_VALID) + ? NULL : global->frame_cache.data, + global->frame_cache.width, + global->frame_cache.height, + global->frame_cache.pitch); + + driver->recording_data = recording; +} + void video_driver_get_size(unsigned *width, unsigned *height) { if (width) diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 3b94868c20..1fde52b3b7 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -374,6 +374,13 @@ enum retro_pixel_format video_driver_get_pixel_format(void); void video_driver_set_pixel_format(enum retro_pixel_format fmt); +/** + * video_driver_cached_frame: + * + * Renders the current video frame. + **/ +void video_driver_cached_frame(void); + #ifdef __cplusplus } #endif diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 839745a93a..85764640b9 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -143,7 +143,7 @@ static void thread_loop(void *data) /* We can read safely * * read_viewport() in GL driver calls - * rarch_render_cached_frame() to be able to read from + * video_driver_cached_frame() to be able to read from * back buffer. * * This means frame() callback in threaded wrapper will diff --git a/menu/menu_display.c b/menu/menu_display.c index de7b13b531..a714f51bdf 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -75,7 +75,7 @@ void menu_display_fb(void) } } - rarch_render_cached_frame(); + video_driver_cached_frame(); } bool menu_display_update_pending(void) diff --git a/retroarch.c b/retroarch.c index 5ceded463a..903b6edb08 100644 --- a/retroarch.c +++ b/retroarch.c @@ -53,39 +53,6 @@ #endif #endif -/** - * rarch_render_cached_frame: - * - * Renders the current video frame. - **/ -void rarch_render_cached_frame(void) -{ - driver_t *driver = driver_get_ptr(); - global_t *global = global_get_ptr(); - runloop_t *runloop = rarch_main_get_ptr(); - void *recording = driver ? driver->recording_data : NULL; - - if (runloop->is_idle) - return; - - /* Cannot allow recording when pushing duped frames. */ - driver->recording_data = NULL; - - /* Not 100% safe, since the library might have - * freed the memory, but no known implementations do this. - * It would be really stupid at any rate ... - */ - if (driver->retro_ctx.frame_cb) - driver->retro_ctx.frame_cb( - (global->frame_cache.data == RETRO_HW_FRAME_BUFFER_VALID) - ? NULL : global->frame_cache.data, - global->frame_cache.width, - global->frame_cache.height, - global->frame_cache.pitch); - - driver->recording_data = recording; -} - #include "config.features.h" #define _PSUPP(var, name, desc) printf("\t%s:\n\t\t%s: %s\n", name, desc, _##var##_supp ? "yes" : "no") diff --git a/retroarch.h b/retroarch.h index 845cf0f850..6c2973683e 100644 --- a/retroarch.h +++ b/retroarch.h @@ -93,13 +93,6 @@ void rarch_main_init_wrap(const struct rarch_main_wrap *args, **/ void rarch_main_deinit(void); -/** - * rarch_render_cached_frame: - * - * Renders the current video frame. - **/ -void rarch_render_cached_frame(void); - /** * rarch_replace_config: * @path : Path to config file to replace diff --git a/runloop.c b/runloop.c index 3472855da3..39d15d371c 100644 --- a/runloop.c +++ b/runloop.c @@ -231,7 +231,7 @@ static void check_slowmotion(bool slowmotion_pressed) return; if (settings->video.black_frame_insertion) - rarch_render_cached_frame(); + video_driver_cached_frame(); rarch_main_msg_queue_push(global->rewind.frame_is_reverse ? "Slow motion rewind." : "Slow motion.", 0, 30, true); @@ -471,7 +471,7 @@ static int do_pause_state_checks( if (fullscreen_toggle_pressed) { event_command(EVENT_CMD_FULLSCREEN_TOGGLE); - rarch_render_cached_frame(); + video_driver_cached_frame(); } if (!check_is_oneshot) diff --git a/screenshot.c b/screenshot.c index d803dea8d7..518c1879be 100644 --- a/screenshot.c +++ b/screenshot.c @@ -278,7 +278,7 @@ bool take_screenshot(void) video_driver_set_texture_enable(false, false); if (driver->video) - rarch_render_cached_frame(); + video_driver_cached_frame(); } if (viewport_read) @@ -333,7 +333,7 @@ bool take_screenshot(void) rarch_main_msg_queue_push(msg, 1, runloop->is_paused ? 1 : 180, true); if (runloop->is_paused) - rarch_render_cached_frame(); + video_driver_cached_frame(); return ret; }