Skip to content

Commit 3cee59a

Browse files
committed
(video_driver) Cleanups
1 parent 49ac382 commit 3cee59a

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

gfx/video_driver.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,18 +1702,17 @@ static void video_driver_set_viewport_config(
17021702
}
17031703

17041704
static void video_driver_set_viewport_square_pixel(
1705-
struct retro_game_geometry *geom)
1705+
struct retro_game_geometry *geom,
1706+
unsigned int rotation)
17061707
{
17071708
unsigned _len, i, aspect_x, aspect_y;
1708-
unsigned int rotation = 0;
17091709
unsigned highest = 1;
17101710
unsigned width = geom->base_width;
17111711
unsigned height = geom->base_height;
17121712

17131713
if (width == 0 || height == 0)
17141714
return;
17151715

1716-
rotation = retroarch_get_rotation();
17171716
_len = MIN(width, height);
17181717

17191718
for (i = 1; i < _len; i++)
@@ -1966,7 +1965,6 @@ float video_driver_get_core_aspect(void)
19661965
/* Flip rotated aspect */
19671966
if ((retroarch_get_rotation() + retroarch_get_core_requested_rotation()) % 2)
19681967
return (1.0f / out_aspect);
1969-
19701968
return out_aspect;
19711969
}
19721970

@@ -2123,11 +2121,13 @@ void video_driver_set_aspect_ratio(void)
21232121
video_driver_state_t *video_st = &video_driver_st;
21242122
const video_poke_interface_t *poke = video_st->poke;
21252123
unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
2124+
unsigned int rotation = retroarch_get_rotation();
21262125

21272126
switch (aspect_ratio_idx)
21282127
{
21292128
case ASPECT_RATIO_SQUARE:
2130-
video_driver_set_viewport_square_pixel(&video_st->av_info.geometry);
2129+
video_driver_set_viewport_square_pixel(&video_st->av_info.geometry,
2130+
rotation);
21312131
break;
21322132

21332133
case ASPECT_RATIO_CORE:
@@ -2264,15 +2264,17 @@ void video_viewport_get_scaled_aspect2(struct video_viewport *vp,
22642264
* Gets viewport scaling dimensions based on
22652265
* scaled integer aspect ratio.
22662266
**/
2267-
static void video_viewport_get_scaled_integer(struct video_viewport *vp,
2267+
static void video_viewport_get_scaled_integer(
2268+
video_driver_state_t *video_st,
2269+
settings_t *settings,
2270+
struct video_viewport *vp,
22682271
unsigned width, unsigned height,
22692272
float aspect_ratio, bool keep_aspect,
2270-
bool y_down)
2273+
bool y_down,
2274+
unsigned int rotation)
22712275
{
22722276
int x = 0;
22732277
int y = 0;
2274-
settings_t *settings = config_get_ptr();
2275-
video_driver_state_t *video_st = &video_driver_st;
22762278
unsigned video_aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
22772279
unsigned scaling = settings->uints.video_scale_integer_scaling;
22782280
unsigned axis = settings->uints.video_scale_integer_axis;
@@ -2282,7 +2284,6 @@ static void video_viewport_get_scaled_integer(struct video_viewport *vp,
22822284
float vp_bias_y = settings->floats.video_vp_bias_y;
22832285
unsigned content_width = video_st->frame_cache_width;
22842286
unsigned content_height = video_st->frame_cache_height;
2285-
unsigned int rotation = retroarch_get_rotation();
22862287
#if defined(RARCH_MOBILE)
22872288
if (width < height)
22882289
{
@@ -2623,6 +2624,7 @@ void video_driver_update_viewport(
26232624
const gfx_ctx_driver_t *ctx = &video_st->current_video_context;
26242625
void *ctx_data = (void*)video_st->context_data;
26252626
float video_driver_aspect_ratio = video_st->aspect_ratio;
2627+
unsigned int rotation = retroarch_get_rotation();
26262628

26272629
vp->x = 0;
26282630
vp->y = 0;
@@ -2685,11 +2687,12 @@ void video_driver_update_viewport(
26852687
#endif
26862688

26872689
if (video_scale_integer && !force_full)
2688-
video_viewport_get_scaled_integer(
2690+
video_viewport_get_scaled_integer(video_st,
2691+
settings,
26892692
vp,
26902693
vp->full_width,
26912694
vp->full_height,
2692-
video_driver_aspect_ratio, keep_aspect, y_down);
2695+
video_driver_aspect_ratio, keep_aspect, y_down, rotation);
26932696
else if (keep_aspect && !force_full)
26942697
{
26952698
/* Calculate device_aspect, using translate_aspect if available
@@ -3502,6 +3505,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
35023505
struct retro_game_geometry *geom = &video_st->av_info.geometry;
35033506
const enum retro_pixel_format
35043507
video_driver_pix_fmt = video_st->pix_fmt;
3508+
unsigned int rotation = retroarch_get_rotation();
35053509
#ifdef HAVE_VIDEO_FILTER
35063510
const char *path_softfilter_plugin = settings->paths.path_softfilter_plugin;
35073511

@@ -3534,7 +3538,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
35343538
sizeof(aspectratio_lut[ASPECT_RATIO_FULL].name));
35353539

35363540
/* Update core-dependent aspect ratio values. */
3537-
video_driver_set_viewport_square_pixel(geom);
3541+
video_driver_set_viewport_square_pixel(geom, rotation);
35383542
video_driver_set_viewport_core();
35393543
video_driver_set_viewport_config(geom,
35403544
settings->floats.video_aspect_ratio,
@@ -3620,7 +3624,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
36203624

36213625
/* rotated games send unrotated width/height and
36223626
* require special handling here because of it */
3623-
if ((retroarch_get_rotation() % 2))
3627+
if (rotation % 2)
36243628
{
36253629
/* Determine nominal window size based on
36263630
* core geometry */
@@ -3798,7 +3802,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
37983802
video_st->current_video->viewport_info(video_st->data, custom_vp);
37993803
}
38003804

3801-
video_driver_set_rotation(retroarch_get_rotation() % 4);
3805+
video_driver_set_rotation(rotation % 4);
38023806

38033807
video_st->current_video->suppress_screensaver(video_st->data,
38043808
settings->bools.ui_suspend_screensaver_enable);
@@ -3884,6 +3888,7 @@ void video_driver_frame(const void *data, unsigned width,
38843888
video_driver_state_t *video_st = &video_driver_st;
38853889
const video_driver_t *vid = video_st->current_video;
38863890
runloop_state_t *runloop_st = runloop_state_get_ptr();
3891+
unsigned int rotation = retroarch_get_rotation();
38873892
const enum retro_pixel_format
38883893
video_driver_pix_fmt = video_st->pix_fmt;
38893894
bool runloop_idle = (runloop_st->flags & RUNLOOP_FLAG_IDLE) ? true : false;
@@ -4313,7 +4318,6 @@ void video_driver_frame(const void *data, unsigned width,
43134318
float scale = ((float)video_info.height / 480)
43144319
* 0.50f * (DEFAULT_FONT_SIZE / video_info.font_size);
43154320
struct retro_system_av_info *av_info = &video_st->av_info;
4316-
unsigned rotation = retroarch_get_rotation();
43174321
unsigned red = 235;
43184322
unsigned green = 235;
43194323
unsigned blue = 235;
@@ -4530,7 +4534,7 @@ void video_driver_frame(const void *data, unsigned width,
45304534
native_width, width,
45314535
height,
45324536
video_st->core_hz,
4533-
retroarch_get_rotation() & 1,
4537+
rotation & 1,
45344538
video_info.crt_switch_resolution,
45354539
video_info.crt_switch_center_adjust,
45364540
video_info.crt_switch_porch_adjust,

0 commit comments

Comments
 (0)