mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
Create video_viewport_get_system_av_info and video_viewport_get_custom -
move custom viewport and system av info outside of global state
This commit is contained in:
parent
b255b5a325
commit
a053b41223
@ -824,10 +824,11 @@ void audio_driver_frame_is_reverse(void)
|
||||
void audio_monitor_adjust_system_rates(void)
|
||||
{
|
||||
float timing_skew;
|
||||
global_t *global = global_get_ptr();
|
||||
const struct retro_system_timing *info =
|
||||
(const struct retro_system_timing*)&global->system.av_info.timing;
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
const struct retro_system_timing *info =
|
||||
av_info ? (const struct retro_system_timing*)&av_info->timing : NULL;
|
||||
|
||||
if (info->sample_rate <= 0.0)
|
||||
return;
|
||||
|
4
driver.c
4
driver.c
@ -309,10 +309,10 @@ void driver_set_nonblock_state(bool enable)
|
||||
**/
|
||||
bool driver_update_system_av_info(const struct retro_system_av_info *info)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
global->system.av_info = *info;
|
||||
memcpy(av_info, info, sizeof(*av_info));
|
||||
event_command(EVENT_CMD_REINIT);
|
||||
|
||||
/* Cannot continue recording with different parameters.
|
||||
|
@ -1102,9 +1102,11 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
|
||||
case RETRO_ENVIRONMENT_SET_GEOMETRY:
|
||||
{
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
const struct retro_game_geometry *in_geom =
|
||||
(const struct retro_game_geometry*)data;
|
||||
struct retro_game_geometry *geom = &global->system.av_info.geometry;
|
||||
struct retro_game_geometry *geom = av_info ?
|
||||
(struct retro_game_geometry*)&av_info->geometry : NULL;
|
||||
|
||||
RARCH_LOG("Environ SET_GEOMETRY.\n");
|
||||
|
||||
|
@ -518,14 +518,15 @@ static bool d3d_has_windowed(void *data)
|
||||
static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info =-
|
||||
video_viewport_get_system_av_info();
|
||||
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_viewport_set_square_pixel(
|
||||
global->system.av_info.geometry.base_width,
|
||||
global->system.av_info.geometry.base_height);
|
||||
av_info->geometry.base_width,
|
||||
av_info->geometry.base_height);
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
|
@ -1540,14 +1540,15 @@ static void exynos_gfx_viewport_info(void *data, struct video_viewport *vp)
|
||||
static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
struct exynos_video *vid = (struct exynos_video*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_viewport_set_square_pixel(
|
||||
global->system.av_info.geometry.base_width,
|
||||
global->system.av_info.geometry.base_height);
|
||||
av_info->geometry.base_width,
|
||||
av_info->geometry.base_height);
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
|
@ -805,7 +805,7 @@ static void gl_set_viewport(void *data, unsigned viewport_width,
|
||||
#if defined(HAVE_MENU)
|
||||
if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
||||
{
|
||||
const struct video_viewport *custom = &global->console.screen.viewports.custom_vp;
|
||||
const struct video_viewport *custom = video_viewport_get_custom();
|
||||
|
||||
/* GL has bottom-left origin viewport. */
|
||||
x = custom->x;
|
||||
@ -3100,14 +3100,14 @@ static retro_proc_address_t gl_get_proc_address(void *data, const char *sym)
|
||||
static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
gl_t *gl = (gl_t*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
switch (aspect_ratio_idx)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_viewport_set_square_pixel(
|
||||
global->system.av_info.geometry.base_width,
|
||||
global->system.av_info.geometry.base_height);
|
||||
av_info->geometry.base_width,
|
||||
av_info->geometry.base_height);
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
|
@ -435,13 +435,13 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines,
|
||||
static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
gx_video_t *gx = (gx_video_t*)driver->video_data;
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
if (aspect_ratio_idx == ASPECT_RATIO_SQUARE)
|
||||
video_viewport_set_square_pixel(
|
||||
global->system.av_info.geometry.base_width,
|
||||
global->system.av_info.geometry.base_height);
|
||||
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)
|
||||
|
@ -391,6 +391,7 @@ static int omapfb_alloc_mem(omapfb_data_t *pdata)
|
||||
unsigned mem_size;
|
||||
void* mem = NULL;
|
||||
const struct retro_game_geometry *geom = NULL;
|
||||
struct retro_system_av_info *av_info = NULL;
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
assert(pdata->current_state == NULL);
|
||||
@ -423,7 +424,10 @@ static int omapfb_alloc_mem(omapfb_data_t *pdata)
|
||||
}
|
||||
}
|
||||
|
||||
geom = &global->system.av_info.geometry;
|
||||
av_info = video_viewport_get_system_av_info();
|
||||
|
||||
if (av_info)
|
||||
geom = &av_info->geometry;
|
||||
mem_size = geom->max_width * geom->max_height *
|
||||
pdata->bpp * pdata->num_pages;
|
||||
|
||||
|
@ -796,14 +796,14 @@ static void psp_set_filtering(void *data, unsigned index, bool smooth)
|
||||
static void psp_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
{
|
||||
psp1_video_t *psp = (psp1_video_t*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
switch (aspectratio_index)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_viewport_set_square_pixel(
|
||||
global->system.av_info.geometry.base_width,
|
||||
global->system.av_info.geometry.base_height);
|
||||
av_info->geometry.base_width,
|
||||
av_info->geometry.base_height);
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
|
@ -639,13 +639,13 @@ void sdl2_poke_set_filtering(void *data, unsigned index, bool smooth)
|
||||
static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
{
|
||||
sdl2_video_t *vid = (sdl2_video_t*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
switch (aspectratio_index)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_viewport_set_square_pixel(global->system.av_info.geometry.base_width,
|
||||
global->system.av_info.geometry.base_height);
|
||||
video_viewport_set_square_pixel(av_info->geometry.base_width,
|
||||
av_info->geometry.base_height);
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
|
@ -445,14 +445,15 @@ static void sdl_set_filtering(void *data, unsigned index, bool smooth)
|
||||
static void sdl_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
{
|
||||
sdl_video_t *vid = (sdl_video_t*)data;
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
|
||||
switch (aspectratio_index)
|
||||
{
|
||||
case ASPECT_RATIO_SQUARE:
|
||||
video_viewport_set_square_pixel(
|
||||
global->system.av_info.geometry.base_width,
|
||||
global->system.av_info.geometry.base_height);
|
||||
av_info->geometry.base_width,
|
||||
av_info->geometry.base_height);
|
||||
break;
|
||||
|
||||
case ASPECT_RATIO_CORE:
|
||||
|
@ -419,10 +419,11 @@ static void *xv_init(const video_info_t *video,
|
||||
XVisualInfo *visualinfo = NULL;
|
||||
XVisualInfo visualtemplate = {0};
|
||||
XvAdaptorInfo *adaptor_info = NULL;
|
||||
const struct retro_game_geometry *geom = NULL;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
const struct retro_game_geometry *geom = NULL;
|
||||
struct retro_system_av_info *av_info = NULL;
|
||||
xv_t *xv = (xv_t*)calloc(1, sizeof(*xv));
|
||||
if (!xv)
|
||||
return NULL;
|
||||
@ -430,7 +431,11 @@ static void *xv_init(const video_info_t *video,
|
||||
XInitThreads();
|
||||
|
||||
xv->display = XOpenDisplay(NULL);
|
||||
geom = &global->system.av_info.geometry;
|
||||
|
||||
av_info = video_viewport_get_system_av_info();
|
||||
|
||||
if (av_info)
|
||||
geom = &av_info->geometry;
|
||||
|
||||
if (!XShmQueryExtension(xv->display))
|
||||
{
|
||||
|
@ -350,6 +350,8 @@ static void init_video_filter(enum retro_pixel_format colfmt)
|
||||
struct retro_game_geometry *geom = NULL;
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
|
||||
deinit_video_filter();
|
||||
|
||||
@ -366,7 +368,7 @@ static void init_video_filter(enum retro_pixel_format colfmt)
|
||||
return;
|
||||
}
|
||||
|
||||
geom = (struct retro_game_geometry*)&global->system.av_info.geometry;
|
||||
geom = av_info ? (struct retro_game_geometry*)&av_info->geometry : NULL;
|
||||
width = geom->max_width;
|
||||
height = geom->max_height;
|
||||
|
||||
@ -474,11 +476,14 @@ void init_video(void)
|
||||
driver_t *driver = driver_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
|
||||
init_video_filter(global->system.pix_fmt);
|
||||
event_command(EVENT_CMD_SHADER_DIR_INIT);
|
||||
|
||||
geom = (const struct retro_game_geometry*)&global->system.av_info.geometry;
|
||||
if (av_info)
|
||||
geom = (const struct retro_game_geometry*)&av_info->geometry;
|
||||
max_dim = max(geom->max_width, geom->max_height);
|
||||
scale = next_pow2(max_dim) / RARCH_SCALE_BASE;
|
||||
scale = max(scale, 1);
|
||||
@ -876,12 +881,17 @@ void video_driver_set_size_height(unsigned height)
|
||||
void video_monitor_adjust_system_rates(void)
|
||||
{
|
||||
float timing_skew;
|
||||
global_t *global = global_get_ptr();
|
||||
const struct retro_system_timing *info =
|
||||
(const struct retro_system_timing*)&global->system.av_info.timing;
|
||||
const struct retro_system_timing *info = NULL;
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
global->system.force_nonblock = false;
|
||||
if (global)
|
||||
global->system.force_nonblock = false;
|
||||
|
||||
if (av_info)
|
||||
info = (const struct retro_system_timing*)&av_info->timing;
|
||||
|
||||
if (info->fps <= 0.0)
|
||||
return;
|
||||
|
@ -51,6 +51,8 @@ char rotation_lut[4][32] =
|
||||
"270 deg"
|
||||
};
|
||||
|
||||
static struct retro_system_av_info video_viewport_av_info;
|
||||
|
||||
/**
|
||||
* video_viewport_set_square_pixel:
|
||||
* @width : Width.
|
||||
@ -90,8 +92,9 @@ void video_viewport_set_square_pixel(unsigned width, unsigned height)
|
||||
**/
|
||||
void video_viewport_set_core(void)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_game_geometry *geom = &global->system.av_info.geometry;
|
||||
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;
|
||||
@ -112,11 +115,11 @@ void video_viewport_set_core(void)
|
||||
void video_viewport_set_config(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
if (settings->video.aspect_ratio < 0.0f)
|
||||
{
|
||||
struct retro_game_geometry *geom = &global->system.av_info.geometry;
|
||||
struct retro_game_geometry *geom = &av_info->geometry;
|
||||
|
||||
if (geom && geom->aspect_ratio > 0.0f && settings->video.aspect_ratio_auto)
|
||||
aspectratio_lut[ASPECT_RATIO_CONFIG].value = geom->aspect_ratio;
|
||||
@ -156,15 +159,13 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
|
||||
{
|
||||
int padding_x = 0, padding_y = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!vp)
|
||||
return;
|
||||
|
||||
if (settings->video.aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
||||
{
|
||||
const struct video_viewport *custom =
|
||||
&global->console.screen.viewports.custom_vp;
|
||||
struct video_viewport *custom = video_viewport_get_custom();
|
||||
|
||||
if (custom)
|
||||
{
|
||||
@ -179,7 +180,8 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
|
||||
unsigned base_width;
|
||||
/* Use system reported sizes as these define the
|
||||
* geometry for the "normal" case. */
|
||||
unsigned base_height = global->system.av_info.geometry.base_height;
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
unsigned base_height = av_info ? av_info->geometry.base_height : 0;
|
||||
|
||||
if (base_height == 0)
|
||||
base_height = 1;
|
||||
@ -219,3 +221,16 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
|
||||
vp->x = padding_x / 2;
|
||||
vp->y = padding_y / 2;
|
||||
}
|
||||
|
||||
struct retro_system_av_info *video_viewport_get_system_av_info(void)
|
||||
{
|
||||
return (struct retro_system_av_info*)&video_viewport_av_info;
|
||||
}
|
||||
|
||||
struct video_viewport *video_viewport_get_custom(void)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
if (!global)
|
||||
return NULL;
|
||||
return &global->console.screen.viewports.custom_vp;
|
||||
}
|
||||
|
@ -137,6 +137,10 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
|
||||
unsigned width, unsigned height,
|
||||
float aspect_ratio, bool keep_aspect);
|
||||
|
||||
struct retro_system_av_info *video_viewport_get_system_av_info(void);
|
||||
|
||||
struct video_viewport *video_viewport_get_custom(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -270,18 +270,18 @@ static int action_iterate_menu_viewport(char *s, size_t len, const char *label,
|
||||
struct retro_game_geometry *geom = NULL;
|
||||
const char *base_msg = NULL;
|
||||
unsigned type = 0;
|
||||
global_t *global = global_get_ptr();
|
||||
video_viewport_t *custom = &global->console.screen.viewports.custom_vp;
|
||||
video_viewport_t *custom = video_viewport_get_custom();
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
if (!menu)
|
||||
return -1;
|
||||
|
||||
menu_list_get_last_stack(menu_list, NULL, NULL, &type);
|
||||
|
||||
geom = (struct retro_game_geometry*)&global->system.av_info.geometry;
|
||||
geom = (struct retro_game_geometry*)&av_info->geometry;
|
||||
|
||||
if (settings->video.scale_integer)
|
||||
{
|
||||
|
@ -291,7 +291,7 @@ bool recording_init(void)
|
||||
global_t *global = global_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_system_av_info *info = &global->system.av_info;
|
||||
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
||||
|
||||
if (!global->record.enable)
|
||||
return false;
|
||||
@ -310,8 +310,8 @@ bool recording_init(void)
|
||||
}
|
||||
|
||||
RARCH_LOG("Custom timing given: FPS: %.4f, Sample rate: %.4f\n",
|
||||
(float)global->system.av_info.timing.fps,
|
||||
(float)global->system.av_info.timing.sample_rate);
|
||||
(float)av_info->timing.fps,
|
||||
(float)av_info->timing.sample_rate);
|
||||
|
||||
strlcpy(recording_file, global->record.path, sizeof(recording_file));
|
||||
|
||||
@ -320,14 +320,14 @@ bool recording_init(void)
|
||||
global->record.output_dir,
|
||||
global->record.path, sizeof(recording_file));
|
||||
|
||||
params.out_width = info->geometry.base_width;
|
||||
params.out_height = info->geometry.base_height;
|
||||
params.fb_width = info->geometry.max_width;
|
||||
params.fb_height = info->geometry.max_height;
|
||||
params.out_width = av_info->geometry.base_width;
|
||||
params.out_height = av_info->geometry.base_height;
|
||||
params.fb_width = av_info->geometry.max_width;
|
||||
params.fb_height = av_info->geometry.max_height;
|
||||
params.channels = 2;
|
||||
params.filename = recording_file;
|
||||
params.fps = global->system.av_info.timing.fps;
|
||||
params.samplerate = global->system.av_info.timing.sample_rate;
|
||||
params.fps = av_info->timing.fps;
|
||||
params.samplerate = av_info->timing.sample_rate;
|
||||
params.pix_fmt = (global->system.pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888) ?
|
||||
FFEMU_PIX_ARGB8888 : FFEMU_PIX_RGB565;
|
||||
params.config = NULL;
|
||||
|
@ -1085,9 +1085,10 @@ static void validate_cpu_features(void)
|
||||
void rarch_init_system_av_info(void)
|
||||
{
|
||||
runloop_t *runloop = rarch_main_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
|
||||
pretro_get_system_av_info(&global->system.av_info);
|
||||
pretro_get_system_av_info(av_info);
|
||||
runloop->frames.limit.last_time = rarch_get_time_usec();
|
||||
}
|
||||
|
||||
|
@ -645,10 +645,10 @@ static void rarch_limit_frame_time(void)
|
||||
retro_time_t to_sleep_ms = 0;
|
||||
runloop_t *runloop = rarch_main_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
retro_time_t current = rarch_get_time_usec();
|
||||
double effective_fps = global->system.av_info.timing.fps
|
||||
* settings->fastforward_ratio;
|
||||
struct retro_system_av_info *av_info =
|
||||
video_viewport_get_system_av_info();
|
||||
double effective_fps = av_info->timing.fps * settings->fastforward_ratio;
|
||||
double mft_f = 1000000.0f / effective_fps;
|
||||
|
||||
runloop->frames.limit.minimum_time = (retro_time_t) roundf(mft_f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user