Refactor away video_viewport_set_core

This commit is contained in:
twinaphex 2015-11-21 12:45:36 +01:00
parent cf5533ccaa
commit 4db97a5300
13 changed files with 76 additions and 80 deletions

View File

@ -502,7 +502,7 @@ static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
break;
case ASPECT_RATIO_CORE:
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:

View File

@ -784,7 +784,7 @@ static void ctr_set_aspect_ratio(void* data, unsigned aspectratio_index)
break;
case ASPECT_RATIO_CORE:
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:

View File

@ -1556,7 +1556,7 @@ static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
break;
case ASPECT_RATIO_CORE:
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:

View File

@ -3278,7 +3278,7 @@ static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
break;
case ASPECT_RATIO_CORE:
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:

View File

@ -451,14 +451,20 @@ static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
const struct retro_system_av_info *av_info =
(const struct retro_system_av_info*)video_viewport_get_system_av_info();
if (aspect_ratio_idx == ASPECT_RATIO_SQUARE)
video_viewport_set_square_pixel(
av_info->geometry.base_width,
av_info->geometry.base_height);
else if (aspect_ratio_idx == ASPECT_RATIO_CORE)
video_viewport_set_core();
else if (aspect_ratio_idx == ASPECT_RATIO_CONFIG)
video_viewport_set_config();
switch (aspect_ratio_idx)
{
case ASPECT_RATIO_SQUARE:
video_viewport_set_square_pixel(
av_info->geometry.base_width,
av_info->geometry.base_height);
break;
case ASPECT_RATIO_CORE:
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:
video_viewport_set_config();
break;
}
video_driver_set_aspect_ratio_value(
aspectratio_lut[aspect_ratio_idx].value);

View File

@ -804,7 +804,7 @@ static void psp_set_aspect_ratio(void *data, unsigned aspectratio_index)
break;
case ASPECT_RATIO_CORE:
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:

View File

@ -667,7 +667,7 @@ static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspectratio_index)
break;
case ASPECT_RATIO_CORE:
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:

View File

@ -454,7 +454,7 @@ static void sdl_set_aspect_ratio(void *data, unsigned aspectratio_index)
break;
case ASPECT_RATIO_CORE:
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:

View File

@ -509,7 +509,7 @@ static void vita_set_aspect_ratio(void *data, unsigned aspectratio_index)
break;
case ASPECT_RATIO_CORE:
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
break;
case ASPECT_RATIO_CONFIG:

View File

@ -67,6 +67,40 @@ typedef struct video_driver_state
static video_driver_state_t video_state;
char rotation_lut[4][32] =
{
"Normal",
"90 deg",
"180 deg",
"270 deg"
};
struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ "4:3", 1.3333f },
{ "16:9", 1.7778f },
{ "16:10", 1.6f },
{ "16:15", 16.0f / 15.0f },
{ "1:1", 1.0f },
{ "2:1", 2.0f },
{ "3:2", 1.5f },
{ "3:4", 0.75f },
{ "4:1", 4.0f },
{ "4:4", 1.0f },
{ "5:4", 1.25f },
{ "6:5", 1.2f },
{ "7:9", 0.7777f },
{ "8:3", 2.6666f },
{ "8:7", 1.1428f },
{ "19:12", 1.5833f },
{ "19:14", 1.3571f },
{ "30:17", 1.7647f },
{ "32:9", 3.5555f },
{ "Config", 0.0f },
{ "Square pixel", 1.0f },
{ "Core provided", 1.0f },
{ "Custom", 0.0f }
};
static const video_driver_t *video_drivers[] = {
#ifdef HAVE_OPENGL
&video_gl,
@ -503,7 +537,7 @@ static bool init_video(void)
/* Update core-dependent aspect ratio values. */
video_viewport_set_square_pixel(geom->base_width, geom->base_height);
video_viewport_set_core();
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL);
video_viewport_set_config();
/* Update CUSTOM viewport. */
@ -1224,6 +1258,23 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
switch (state)
{
case RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE:
{
struct retro_system_av_info *av_info =
video_viewport_get_system_av_info();
struct retro_game_geometry *geom = &av_info->geometry;
if (!geom || geom->base_width <= 0.0f || geom->base_height <= 0.0f)
return false;
/* Fallback to 1:1 pixel ratio if none provided */
if (geom->aspect_ratio > 0.0f)
aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio;
else
aspectratio_lut[ASPECT_RATIO_CORE].value =
(float)geom->base_width / geom->base_height;
}
return true;
case RARCH_DISPLAY_CTL_RESET_CUSTOM_VIEWPORT:
{
struct video_viewport *custom_vp = video_viewport_get_custom();

View File

@ -237,6 +237,8 @@ enum rarch_display_ctl_state
RARCH_DISPLAY_CTL_HAS_WINDOWED,
RARCH_DISPLAY_CTL_IS_FOCUSED,
RARCH_DISPLAY_CTL_SET_ASPECT_RATIO,
/* Sets viewport to aspect ratio set by core. */
RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE,
RARCH_DISPLAY_CTL_RESET_CUSTOM_VIEWPORT,
RARCH_DISPLAY_CTL_READ_VIEWPORT,
RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE,

View File

@ -16,40 +16,6 @@
#include "../general.h"
struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = {
{ "4:3", 1.3333f },
{ "16:9", 1.7778f },
{ "16:10", 1.6f },
{ "16:15", 16.0f / 15.0f },
{ "1:1", 1.0f },
{ "2:1", 2.0f },
{ "3:2", 1.5f },
{ "3:4", 0.75f },
{ "4:1", 4.0f },
{ "4:4", 1.0f },
{ "5:4", 1.25f },
{ "6:5", 1.2f },
{ "7:9", 0.7777f },
{ "8:3", 2.6666f },
{ "8:7", 1.1428f },
{ "19:12", 1.5833f },
{ "19:14", 1.3571f },
{ "30:17", 1.7647f },
{ "32:9", 3.5555f },
{ "Config", 0.0f },
{ "Square pixel", 1.0f },
{ "Core provided", 1.0f },
{ "Custom", 0.0f }
};
char rotation_lut[4][32] =
{
"Normal",
"90 deg",
"180 deg",
"270 deg"
};
static struct retro_system_av_info video_viewport_av_info;
/**
@ -84,28 +50,6 @@ void video_viewport_set_square_pixel(unsigned width, unsigned height)
aspectratio_lut[ASPECT_RATIO_SQUARE].value = (float)aspect_x / aspect_y;
}
/**
* video_viewport_set_core:
*
* Sets viewport to aspect ratio set by core.
**/
void video_viewport_set_core(void)
{
struct retro_system_av_info *av_info =
video_viewport_get_system_av_info();
struct retro_game_geometry *geom = &av_info->geometry;
if (!geom || geom->base_width <= 0.0f || geom->base_height <= 0.0f)
return;
/* Fallback to 1:1 pixel ratio if none provided */
if (geom->aspect_ratio > 0.0f)
aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio;
else
aspectratio_lut[ASPECT_RATIO_CORE].value =
(float)geom->base_width / geom->base_height;
}
/**
* video_viewport_set_config:
*

View File

@ -109,13 +109,6 @@ extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END];
**/
void video_viewport_set_square_pixel(unsigned width, unsigned height);
/**
* video_viewport_set_core:
*
* Sets viewport to aspect ratio set by core.
**/
void video_viewport_set_core(void);
/**
* video_viewport_set_config:
*