diff --git a/gfx/video_driver.c b/gfx/video_driver.c index bc1efa9d0f..fecc4436ff 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2077,6 +2077,7 @@ void video_driver_frame(const void *data, unsigned width, unsigned height, size_t pitch) { static char video_driver_msg[256]; + static struct retro_perf_counter video_frame_conv = {0}; unsigned output_width = 0; unsigned output_height = 0; unsigned output_pitch = 0; @@ -2086,6 +2087,9 @@ void video_driver_frame(const void *data, unsigned width, if (!video_driver_active) return; + performance_counter_init(&video_frame_conv, "video_frame_conv"); + performance_counter_start(&video_frame_conv); + if (video_driver_scaler_ptr && data && (video_driver_pix_fmt == RETRO_PIXEL_FORMAT_0RGB1555) && (data != RETRO_HW_FRAME_BUFFER_VALID) && @@ -2098,6 +2102,8 @@ void video_driver_frame(const void *data, unsigned width, pitch = video_driver_scaler_ptr->scaler->out_stride; } + performance_counter_stop(&video_frame_conv); + video_driver_cached_frame_set(data, width, height, pitch); /* Slightly messy code, diff --git a/gfx/video_frame.c b/gfx/video_frame.c index 99448cee7d..e2a3ac8eea 100644 --- a/gfx/video_frame.c +++ b/gfx/video_frame.c @@ -17,9 +17,6 @@ #include -#include "../performance_counters.h" - -#include "video_driver.h" #include "video_frame.h" void video_frame_convert_rgb16_to_rgb32( @@ -148,8 +145,7 @@ void video_frame_convert_argb8888_to_abgr8888( void video_frame_convert_to_bgr24( void *data, void *output, const void *input, - int width, int height, int in_pitch, - bool bgr24) + int width, int height, int in_pitch) { struct scaler_ctx *scaler = (struct scaler_ctx*)data; @@ -157,12 +153,6 @@ void video_frame_convert_to_bgr24( scaler->in_height = height; scaler->out_width = width; scaler->out_height = height; - if (bgr24) - scaler->in_fmt = SCALER_FMT_BGR24; - else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) - scaler->in_fmt = SCALER_FMT_ARGB8888; - else - scaler->in_fmt = SCALER_FMT_RGB565; scaler->out_fmt = SCALER_FMT_BGR24; scaler->scaler_type = SCALER_TYPE_POINT; scaler_ctx_gen_filter(scaler); @@ -197,10 +187,6 @@ bool video_pixel_frame_scale( size_t pitch) { struct scaler_ctx *scaler = (struct scaler_ctx*)scaler_data; - static struct retro_perf_counter video_frame_conv = {0}; - - performance_counter_init(&video_frame_conv, "video_frame_conv"); - performance_counter_start(&video_frame_conv); scaler->in_width = width; scaler->in_height = height; @@ -211,7 +197,5 @@ bool video_pixel_frame_scale( scaler_ctx_scale(scaler, output, data); - performance_counter_stop(&video_frame_conv); - return true; } diff --git a/gfx/video_frame.h b/gfx/video_frame.h index da1ecfea7f..bef2234625 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -60,8 +60,7 @@ void video_frame_convert_argb8888_to_abgr8888( void video_frame_convert_to_bgr24( void *data, void *output, const void *input, - int width, int height, int in_pitch, - bool bgr24); + int width, int height, int in_pitch); void video_frame_convert_rgba_to_bgr( const void *src_data, diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index 4647441d57..32059e46c4 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -105,13 +105,23 @@ static void task_screenshot_handler(retro_task_t *task) ret = true; state->surf->Release(); #elif defined(HAVE_RPNG) - video_frame_convert_to_bgr24( - &state->scaler, - state->out_buffer, - (const uint8_t*)state->frame + ((int)state->height - 1) * state->pitch, - state->width, state->height, - -state->pitch, - state->bgr24); + { + struct scaler_ctx *scaler = (struct scaler_ctx*)&state->scaler; + + if (state->bgr24) + scaler->in_fmt = SCALER_FMT_BGR24; + else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) + scaler->in_fmt = SCALER_FMT_ARGB8888; + else + scaler->in_fmt = SCALER_FMT_RGB565; + + video_frame_convert_to_bgr24( + scaler, + state->out_buffer, + (const uint8_t*)state->frame + ((int)state->height - 1) * state->pitch, + state->width, state->height, + -state->pitch); + } scaler_ctx_gen_reset(&state->scaler);