From 34515fd7f575bdff4e656f330e2380e4649c69c4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 9 Mar 2013 03:20:33 +0100 Subject: [PATCH] (RARCH_CONSOLE) Integrate rarch-console_video into gfx_common --- console/griffin/griffin.c | 1 - console/rarch_console_video.c | 88 ------------------------------- console/rarch_console_video.h | 97 ----------------------------------- frontend/menu/rgui.c | 2 +- frontend/menu/rmenu.c | 3 +- frontend/menu/rmenu_xui.cpp | 2 +- gfx/gfx_common.c | 70 +++++++++++++++++++++++++ gfx/gfx_common.h | 81 +++++++++++++++++++++++++++++ gfx/gl.c | 8 +-- gx/gx_video.c | 5 +- xdk/xdk_d3d.cpp | 4 +- 11 files changed, 160 insertions(+), 201 deletions(-) delete mode 100644 console/rarch_console_video.c delete mode 100644 console/rarch_console_video.h diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index c2e763f06c..3414acb4e1 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -438,7 +438,6 @@ MENU #endif #ifdef HAVE_RMENU -#include "../rarch_console_video.c" #include "../../frontend/menu/rmenu_settings.c" #if defined(_XBOX360) diff --git a/console/rarch_console_video.c b/console/rarch_console_video.c deleted file mode 100644 index ba504c6c9e..0000000000 --- a/console/rarch_console_video.c +++ /dev/null @@ -1,88 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2013 - Hans-Kristian Arntzen - * Copyright (C) 2011-2013 - 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 - -#include "../general.h" - -#include "rarch_console_video.h" - -struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { - { "1:1", 1.0f }, - { "2:1", 2.0f }, - { "3:2", 1.5f }, - { "3:4", 0.75f }, - { "4:1", 4.0f }, - { "4:3", 1.3333f }, - { "4:4", 1.0f }, - { "5:4", 1.25f }, - { "6:5", 1.2f }, - { "7:9", 0.7777f }, - { "8:3", 2.6666f }, - { "8:7", 1.1428f }, - { "16:9", 1.7778f }, - { "16:10", 1.6f }, - { "16:15", 3.2f }, - { "19:12", 1.5833f }, - { "19:14", 1.3571f }, - { "30:17", 1.7647f }, - { "32:9", 3.5555f }, - { "Auto", 1.0f }, - { "Core Provided", 1.0f }, - { "Custom", 0.0f } -}; - -char rotation_lut[ASPECT_RATIO_END][32] = -{ - "Normal", - "Vertical", - "Flipped", - "Flipped Rotated" -}; - -void rarch_set_auto_viewport(unsigned width, unsigned height) -{ - if(width == 0 || height == 0) - return; - - unsigned aspect_x, aspect_y, len, highest, i; - - len = width < height ? width : height; - highest = 1; - for (i = 1; i < len; i++) - { - if ((width % i) == 0 && (height % i) == 0) - highest = i; - } - - aspect_x = width / highest; - aspect_y = height / highest; - - snprintf(aspectratio_lut[ASPECT_RATIO_AUTO].name, sizeof(aspectratio_lut[ASPECT_RATIO_AUTO].name), "%d:%d (Auto)", aspect_x, aspect_y); - aspectratio_lut[ASPECT_RATIO_AUTO].value = (float) aspect_x / aspect_y; -} - -void rarch_set_core_viewport(void) -{ - if (!g_extern.main_is_init) - return; - - // fallback to 1:1 pixel ratio if none provided - if (g_extern.system.av_info.geometry.aspect_ratio == 0.0) - aspectratio_lut[ASPECT_RATIO_CORE].value = (float) g_extern.system.av_info.geometry.base_width / g_extern.system.av_info.geometry.base_height; - else - aspectratio_lut[ASPECT_RATIO_CORE].value = g_extern.system.av_info.geometry.aspect_ratio; -} diff --git a/console/rarch_console_video.h b/console/rarch_console_video.h deleted file mode 100644 index 1b2a39e181..0000000000 --- a/console/rarch_console_video.h +++ /dev/null @@ -1,97 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2013 - Hans-Kristian Arntzen - * Copyright (C) 2011-2013 - 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 RARCH_CONSOLE_VIDEO_H__ -#define RARCH_CONSOLE_VIDEO_H__ - -#define MIN_SCALING_FACTOR (1.0f) - -#if defined(__CELLOS_LV2__) -#define MAX_SCALING_FACTOR (5.0f) -#else -#define MAX_SCALING_FACTOR (2.0f) -#endif - - -enum aspect_ratio -{ - ASPECT_RATIO_1_1 = 0, - ASPECT_RATIO_2_1, - ASPECT_RATIO_3_2, - ASPECT_RATIO_3_4, - ASPECT_RATIO_4_1, - ASPECT_RATIO_4_3, - ASPECT_RATIO_4_4, - ASPECT_RATIO_5_4, - ASPECT_RATIO_6_5, - ASPECT_RATIO_7_9, - ASPECT_RATIO_8_3, - ASPECT_RATIO_8_7, - ASPECT_RATIO_16_9, - ASPECT_RATIO_16_10, - ASPECT_RATIO_16_15, - ASPECT_RATIO_19_12, - ASPECT_RATIO_19_14, - ASPECT_RATIO_30_17, - ASPECT_RATIO_32_9, - ASPECT_RATIO_AUTO, - ASPECT_RATIO_CORE, - ASPECT_RATIO_CUSTOM, - - ASPECT_RATIO_END, -}; - -#define LAST_ASPECT_RATIO ASPECT_RATIO_CUSTOM - -enum rotation -{ - ORIENTATION_NORMAL = 0, - ORIENTATION_VERTICAL, - ORIENTATION_FLIPPED, - ORIENTATION_FLIPPED_ROTATED, - ORIENTATION_END -}; - -#define LAST_ORIENTATION (ORIENTATION_END-1) - -extern char rotation_lut[ASPECT_RATIO_END][32]; - -/* ABGR color format defines */ - -#define WHITE 0xffffffffu -#define RED 0xff0000ffu -#define GREEN 0xff00ff00u -#define BLUE 0xffff0000u -#define YELLOW 0xff00ffffu -#define PURPLE 0xffff00ffu -#define CYAN 0xffffff00u -#define ORANGE 0xff0063ffu -#define SILVER 0xff8c848cu -#define LIGHTBLUE 0xFFFFE0E0U -#define LIGHTORANGE 0xFFE0EEFFu - -struct aspect_ratio_elem -{ - char name[64]; - float value; -}; - -extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; - -extern void rarch_set_auto_viewport(unsigned width, unsigned height); -extern void rarch_set_core_viewport(void); - -#endif diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index dd0ecc9515..7b1cd69357 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -22,7 +22,7 @@ #include "rgui.h" #include "utils/file_list.h" #include "rmenu_settings.h" -#include "../../console/rarch_console_video.h" +#include "../../gfx/gfx_common.h" #include "../../screenshot.h" #define TERM_START_X 15 diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 53c8f2f1a5..6dcc9eb74e 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -33,8 +33,7 @@ #include "../../gfx/image.h" -#include "../../console/rarch_console_video.h" - +#include "../../gfx/gfx_common.h" #include "../../gfx/gfx_context.h" #include "../../file.h" diff --git a/frontend/menu/rmenu_xui.cpp b/frontend/menu/rmenu_xui.cpp index 4869add564..e14a547397 100644 --- a/frontend/menu/rmenu_xui.cpp +++ b/frontend/menu/rmenu_xui.cpp @@ -25,8 +25,8 @@ #include "../../console/rarch_console.h" #include "rmenu_settings.h" -#include "../../console/rarch_console_video.h" +#include "../../gfx/gfx_common.h" #include "../../gfx/gfx_context.h" #include "../../message.h" diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index c70bf7af70..790a17bc26 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -169,3 +169,73 @@ void gfx_scale_integer(struct rarch_viewport *vp, unsigned width, unsigned heigh vp->y = padding_y >> 1; } +#ifdef HAVE_RMENU + +struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { + { "1:1", 1.0f }, + { "2:1", 2.0f }, + { "3:2", 1.5f }, + { "3:4", 0.75f }, + { "4:1", 4.0f }, + { "4:3", 1.3333f }, + { "4:4", 1.0f }, + { "5:4", 1.25f }, + { "6:5", 1.2f }, + { "7:9", 0.7777f }, + { "8:3", 2.6666f }, + { "8:7", 1.1428f }, + { "16:9", 1.7778f }, + { "16:10", 1.6f }, + { "16:15", 3.2f }, + { "19:12", 1.5833f }, + { "19:14", 1.3571f }, + { "30:17", 1.7647f }, + { "32:9", 3.5555f }, + { "Auto", 1.0f }, + { "Core Provided", 1.0f }, + { "Custom", 0.0f } +}; + +char rotation_lut[ASPECT_RATIO_END][32] = +{ + "Normal", + "Vertical", + "Flipped", + "Flipped Rotated" +}; + +void gfx_set_auto_viewport(unsigned width, unsigned height) +{ + if(width == 0 || height == 0) + return; + + unsigned aspect_x, aspect_y, len, highest, i; + + len = width < height ? width : height; + highest = 1; + for (i = 1; i < len; i++) + { + if ((width % i) == 0 && (height % i) == 0) + highest = i; + } + + aspect_x = width / highest; + aspect_y = height / highest; + + snprintf(aspectratio_lut[ASPECT_RATIO_AUTO].name, sizeof(aspectratio_lut[ASPECT_RATIO_AUTO].name), "%d:%d (Auto)", aspect_x, aspect_y); + aspectratio_lut[ASPECT_RATIO_AUTO].value = (float) aspect_x / aspect_y; +} + +void gfx_set_core_viewport(void) +{ + if (!g_extern.main_is_init) + return; + + // fallback to 1:1 pixel ratio if none provided + if (g_extern.system.av_info.geometry.aspect_ratio == 0.0) + aspectratio_lut[ASPECT_RATIO_CORE].value = (float) g_extern.system.av_info.geometry.base_width / g_extern.system.av_info.geometry.base_height; + else + aspectratio_lut[ASPECT_RATIO_CORE].value = g_extern.system.av_info.geometry.aspect_ratio; +} + +#endif diff --git a/gfx/gfx_common.h b/gfx/gfx_common.h index 90124617f8..d546fad56c 100644 --- a/gfx/gfx_common.h +++ b/gfx/gfx_common.h @@ -40,6 +40,87 @@ void gfx_set_dwm(void); void gfx_scale_integer(struct rarch_viewport *vp, unsigned win_width, unsigned win_height, float aspect_ratio, bool keep_aspect); +#ifdef HAVE_RMENU + +#define MIN_SCALING_FACTOR (1.0f) + +#if defined(__CELLOS_LV2__) +#define MAX_SCALING_FACTOR (5.0f) +#else +#define MAX_SCALING_FACTOR (2.0f) +#endif + + +enum aspect_ratio +{ + ASPECT_RATIO_1_1 = 0, + ASPECT_RATIO_2_1, + ASPECT_RATIO_3_2, + ASPECT_RATIO_3_4, + ASPECT_RATIO_4_1, + ASPECT_RATIO_4_3, + ASPECT_RATIO_4_4, + ASPECT_RATIO_5_4, + ASPECT_RATIO_6_5, + ASPECT_RATIO_7_9, + ASPECT_RATIO_8_3, + ASPECT_RATIO_8_7, + ASPECT_RATIO_16_9, + ASPECT_RATIO_16_10, + ASPECT_RATIO_16_15, + ASPECT_RATIO_19_12, + ASPECT_RATIO_19_14, + ASPECT_RATIO_30_17, + ASPECT_RATIO_32_9, + ASPECT_RATIO_AUTO, + ASPECT_RATIO_CORE, + ASPECT_RATIO_CUSTOM, + + ASPECT_RATIO_END, +}; + +#define LAST_ASPECT_RATIO ASPECT_RATIO_CUSTOM + +enum rotation +{ + ORIENTATION_NORMAL = 0, + ORIENTATION_VERTICAL, + ORIENTATION_FLIPPED, + ORIENTATION_FLIPPED_ROTATED, + ORIENTATION_END +}; + +#define LAST_ORIENTATION (ORIENTATION_END-1) + +extern char rotation_lut[ASPECT_RATIO_END][32]; + +/* ABGR color format defines */ + +#define WHITE 0xffffffffu +#define RED 0xff0000ffu +#define GREEN 0xff00ff00u +#define BLUE 0xffff0000u +#define YELLOW 0xff00ffffu +#define PURPLE 0xffff00ffu +#define CYAN 0xffffff00u +#define ORANGE 0xff0063ffu +#define SILVER 0xff8c848cu +#define LIGHTBLUE 0xFFFFE0E0U +#define LIGHTORANGE 0xFFE0EEFFu + +struct aspect_ratio_elem +{ + char name[64]; + float value; +}; + +extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; + +extern void gfx_set_auto_viewport(unsigned width, unsigned height); +extern void gfx_set_core_viewport(void); + +#endif + #ifdef __cplusplus } #endif diff --git a/gfx/gl.c b/gfx/gl.c index c8f009dbab..6f1179ea81 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -49,10 +49,6 @@ #include "shader_common.h" -#ifdef HAVE_RMENU -#include "../console/rarch_console_video.h" -#endif - #ifdef __CELLOS_LV2__ #define FPS_COUNTER #endif @@ -2097,9 +2093,9 @@ static void gl_set_aspect_ratio(void *data, unsigned aspectratio_index) gl_t *gl = driver.video_data; if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_AUTO) - rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + gfx_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); else if(g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE) - rarch_set_core_viewport(); + gfx_set_core_viewport(); g_settings.video.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value; g_settings.video.force_aspect = false; diff --git a/gx/gx_video.c b/gx/gx_video.c index c7ddc86e56..b9cc658c81 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -17,7 +17,6 @@ #include "../driver.h" #include "../general.h" -#include "../console/rarch_console_video.h" #include "../gfx/fonts/bitmap.h" #include "../frontend/menu/rgui.h" #include "../gfx/gfx_common.h" @@ -276,9 +275,9 @@ void gx_set_aspect_ratio(void *data, unsigned aspectratio_idx) gx_video_t *gx = (gx_video_t*)driver.video_data; if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_AUTO) - rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + gfx_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); else if(g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE) - rarch_set_core_viewport(); + gfx_set_core_viewport(); g_settings.video.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value; g_settings.video.force_aspect = false; diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index 655366206b..98a6053d38 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -994,9 +994,9 @@ static void xdk_d3d_set_aspect_ratio(void *data, unsigned aspectratio_index) xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_AUTO) - rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + gfx_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); else if (g_settings.video.aspect_ratio_idx == ASPECT_RATIO_CORE) - rarch_set_core_viewport(); + gfx_set_core_viewport(); g_settings.video.aspect_ratio = aspectratio_lut[g_settings.video.aspect_ratio_idx].value; g_settings.video.force_aspect = false;