From 7a0c7bd712ad1338916d1e8ddd45d82ce4059aba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 18 Jan 2015 23:17:16 +0100 Subject: [PATCH] Split up pixconv code to gfx/video_pixel_converter.c --- Makefile.common | 1 + driver.c | 36 +------------------------ gfx/video_pixel_converter.c | 54 +++++++++++++++++++++++++++++++++++++ gfx/video_pixel_converter.h | 34 +++++++++++++++++++++++ griffin/griffin.c | 1 + 5 files changed, 91 insertions(+), 35 deletions(-) create mode 100644 gfx/video_pixel_converter.c create mode 100644 gfx/video_pixel_converter.h diff --git a/Makefile.common b/Makefile.common index 2ed45788c8..fcd4a50663 100644 --- a/Makefile.common +++ b/Makefile.common @@ -102,6 +102,7 @@ OBJ += frontend/frontend.o \ input/input_driver.o \ gfx/video_driver.o \ gfx/video_monitor.o \ + gfx/video_pixel_converter.o \ osk/osk_driver.o \ camera/camera_driver.o \ menu/menu_driver.o \ diff --git a/driver.c b/driver.c index bd601b4097..297435d6f4 100644 --- a/driver.c +++ b/driver.c @@ -22,6 +22,7 @@ #include "compat/posix_string.h" #include "gfx/video_thread_wrapper.h" #include "gfx/video_monitor.h" +#include "gfx/video_pixel_converter.h" #include "audio/audio_monitor.h" #include "gfx/gfx_common.h" @@ -332,41 +333,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info) return true; } -static void deinit_pixel_converter(void) -{ - scaler_ctx_gen_reset(&driver.scaler); - memset(&driver.scaler, 0, sizeof(driver.scaler)); - free(driver.scaler_out); - driver.scaler_out = NULL; -} - -static bool init_video_pixel_converter(unsigned size) -{ - /* This function can be called multiple times - * without deiniting first on consoles. */ - deinit_pixel_converter(); - - /* If pixel format is not 0RGB1555, we don't need to do - * any internal pixel conversion. */ - if (g_extern.system.pix_fmt != 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"); - - driver.scaler.scaler_type = SCALER_TYPE_POINT; - driver.scaler.in_fmt = SCALER_FMT_0RGB1555; - - /* TODO: Pick either ARGB8888 or RGB565 depending on driver. */ - driver.scaler.out_fmt = SCALER_FMT_RGB565; - - if (!scaler_ctx_gen_filter(&driver.scaler)) - return false; - - driver.scaler_out = calloc(sizeof(uint16_t), size * size); - - return true; -} - static void deinit_video_filter(void) { rarch_softfilter_free(g_extern.filter.filter); diff --git a/gfx/video_pixel_converter.c b/gfx/video_pixel_converter.c new file mode 100644 index 0000000000..9a0bab90b8 --- /dev/null +++ b/gfx/video_pixel_converter.c @@ -0,0 +1,54 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2015 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include "video_pixel_converter.h" +#include +#include "../general.h" + +void deinit_pixel_converter(void) +{ + scaler_ctx_gen_reset(&driver.scaler); + memset(&driver.scaler, 0, sizeof(driver.scaler)); + free(driver.scaler_out); + driver.scaler_out = NULL; +} + +bool init_video_pixel_converter(unsigned size) +{ + /* This function can be called multiple times + * without deiniting first on consoles. */ + deinit_pixel_converter(); + + /* If pixel format is not 0RGB1555, we don't need to do + * any internal pixel conversion. */ + if (g_extern.system.pix_fmt != 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"); + + driver.scaler.scaler_type = SCALER_TYPE_POINT; + driver.scaler.in_fmt = SCALER_FMT_0RGB1555; + + /* TODO: Pick either ARGB8888 or RGB565 depending on driver. */ + driver.scaler.out_fmt = SCALER_FMT_RGB565; + + if (!scaler_ctx_gen_filter(&driver.scaler)) + return false; + + driver.scaler_out = calloc(sizeof(uint16_t), size * size); + + return true; +} diff --git a/gfx/video_pixel_converter.h b/gfx/video_pixel_converter.h new file mode 100644 index 0000000000..d6a8d22f16 --- /dev/null +++ b/gfx/video_pixel_converter.h @@ -0,0 +1,34 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2015 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef _VIDEO_PIXEL_CONVERTER_H +#define _VIDEO_PIXEL_CONVERTER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void deinit_pixel_converter(void); + +bool init_video_pixel_converter(unsigned size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/griffin/griffin.c b/griffin/griffin.c index a16e75a6da..36d7860949 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -507,6 +507,7 @@ DRIVERS ============================================================ */ #include "../gfx/video_driver.c" #include "../gfx/video_monitor.c" +#include "../gfx/video_pixel_converter.c" #include "../input/input_driver.c" #include "../audio/audio_driver.c" #include "../audio/audio_monitor.c"