From d2b76a7d13316dc42285e9282a02bdce05852628 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2015 20:59:12 +0200 Subject: [PATCH] Move pix_fmt to video_state --- dynamic.c | 2 +- gfx/drivers/psp1_gfx.c | 2 +- gfx/video_driver.c | 15 +++++++++++++-- gfx/video_driver.h | 4 ++++ gfx/video_pixel_converter.c | 3 +-- libretro_version_1.c | 2 +- record/record_driver.c | 2 +- runloop.h | 1 - screenshot.c | 8 ++------ 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/dynamic.c b/dynamic.c index 0633cfda14..dfd2e2c778 100644 --- a/dynamic.c +++ b/dynamic.c @@ -692,7 +692,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) return false; } - global->system.pix_fmt = pix_fmt; + video_driver_set_pixel_format(pix_fmt); break; } diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 67a69fed90..0fb524f2ec 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -357,7 +357,7 @@ static void *psp_init(const video_info_t *video, psp->bpp_log2 = 1; pixel_format = - (global->system.pix_fmt == RETRO_PIXEL_FORMAT_0RGB1555) + (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_0RGB1555) ? GU_PSM_5551 : GU_PSM_5650 ; lut_pixel_format = GU_PSM_T16; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index c07e796435..787d61fa7e 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -33,6 +33,7 @@ typedef struct video_driver_state retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; struct retro_hw_render_callback hw_render_callback; uint64_t frame_time_samples_count; + enum retro_pixel_format pix_fmt; unsigned video_width; unsigned video_height; @@ -483,7 +484,7 @@ void init_video(void) struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - init_video_filter(global->system.pix_fmt); + init_video_filter(video_state.pix_fmt); event_command(EVENT_CMD_SHADER_DIR_INIT); if (av_info) @@ -561,7 +562,7 @@ void init_video(void) video.input_scale = scale; video.rgb32 = video_state.filter.filter ? video_state.filter.out_rgb32 : - (global->system.pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888); + (video_state.pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888); tmp = (const input_driver_t*)driver->input; /* Need to grab the "real" video driver interface on a reinit. */ @@ -1181,3 +1182,13 @@ void *video_driver_frame_filter_get_buf_ptr(void) { return video_state.filter.buffer; } + +enum retro_pixel_format video_driver_get_pixel_format(void) +{ + return video_state.pix_fmt; +} + +void video_driver_set_pixel_format(enum retro_pixel_format fmt) +{ + video_state.pix_fmt = fmt; +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 58a23d287e..3b94868c20 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -370,6 +370,10 @@ rarch_softfilter_t *video_driver_frame_filter_get_ptr(void); void *video_driver_frame_filter_get_buf_ptr(void); +enum retro_pixel_format video_driver_get_pixel_format(void); + +void video_driver_set_pixel_format(enum retro_pixel_format fmt); + #ifdef __cplusplus } #endif diff --git a/gfx/video_pixel_converter.c b/gfx/video_pixel_converter.c index 7c67ce77f3..4a4467aa21 100644 --- a/gfx/video_pixel_converter.c +++ b/gfx/video_pixel_converter.c @@ -31,7 +31,6 @@ void deinit_pixel_converter(void) bool init_video_pixel_converter(unsigned size) { driver_t *driver = driver_get_ptr(); - global_t *global = global_get_ptr(); /* This function can be called multiple times * without deiniting first on consoles. */ @@ -39,7 +38,7 @@ bool init_video_pixel_converter(unsigned size) /* If pixel format is not 0RGB1555, we don't need to do * any internal pixel conversion. */ - if (global->system.pix_fmt != RETRO_PIXEL_FORMAT_0RGB1555) + if (video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555) return true; RARCH_WARN("0RGB1555 pixel format is deprecated, and will be slower. For 15/16-bit, RGB565 format is preferred.\n"); diff --git a/libretro_version_1.c b/libretro_version_1.c index 8f2ba2ecf2..0a08e61036 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -53,7 +53,7 @@ static bool video_frame_scale(const void *data, if (!data) return false; - if (global->system.pix_fmt != RETRO_PIXEL_FORMAT_0RGB1555) + if (video_driver_get_pixel_format() != RETRO_PIXEL_FORMAT_0RGB1555) return false; if (data == RETRO_HW_FRAME_BUFFER_VALID) return false; diff --git a/record/record_driver.c b/record/record_driver.c index 417dda372c..c3624ee816 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -329,7 +329,7 @@ bool recording_init(void) params.filename = recording_file; params.fps = av_info->timing.fps; params.samplerate = av_info->timing.sample_rate; - params.pix_fmt = (global->system.pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888) ? + params.pix_fmt = (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) ? FFEMU_PIX_ARGB8888 : FFEMU_PIX_RGB565; params.config = NULL; diff --git a/runloop.h b/runloop.h index 85075a0341..1e34b0f060 100644 --- a/runloop.h +++ b/runloop.h @@ -156,7 +156,6 @@ typedef struct global unsigned rotation; bool shutdown; unsigned performance_level; - enum retro_pixel_format pix_fmt; bool block_extract; bool force_nonblock; diff --git a/screenshot.c b/screenshot.c index edd5c90457..d803dea8d7 100644 --- a/screenshot.c +++ b/screenshot.c @@ -129,7 +129,6 @@ static void dump_content(FILE *file, const void *frame, { size_t line_size; int i, j; - global_t *global = NULL; union { const uint8_t *u8; @@ -143,7 +142,6 @@ static void dump_content(FILE *file, const void *frame, u.u8 = (const uint8_t*)frame; line_size = (width * 3 + 3) & ~3; - global = global_get_ptr(); for (i = 0; i < height; i++) { @@ -157,7 +155,7 @@ static void dump_content(FILE *file, const void *frame, for (j = 0; j < height; j++, u.u8 += pitch) dump_line_bgr(lines[j], u.u8, width); } - else if (global->system.pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888) + else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) { for (j = 0; j < height; j++, u.u8 += pitch) dump_line_32(lines[j], u.u32, width); @@ -351,13 +349,11 @@ bool screenshot_dump(const char *folder, const void *frame, FILE *file = NULL; uint8_t *out_buffer = NULL; bool ret = false; - global_t *global = global_get_ptr(); driver_t *driver = driver_get_ptr(); (void)file; (void)out_buffer; (void)scaler; - (void)global; (void)driver; fill_dated_filename(shotname, IMG_EXT, sizeof(shotname)); @@ -396,7 +392,7 @@ bool screenshot_dump(const char *folder, const void *frame, if (bgr24) scaler.in_fmt = SCALER_FMT_BGR24; - else if (global->system.pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888) + else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) scaler.in_fmt = SCALER_FMT_ARGB8888; else scaler.in_fmt = SCALER_FMT_RGB565;