Add get_metrics to poke interface

This commit is contained in:
twinaphex 2020-08-02 19:25:45 +02:00
parent 416363e9fd
commit 119689c940
42 changed files with 236 additions and 156 deletions

View File

@ -243,6 +243,7 @@ static void caca_set_texture_frame(void *data,
}
static const video_poke_interface_t caca_poke_interface = {
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,

View File

@ -1247,6 +1247,7 @@ static uint32_t ctr_get_flags(void *data)
}
static const video_poke_interface_t ctr_poke_interface = {
NULL, /* get_metrics */
ctr_get_flags,
ctr_load_texture,
ctr_unload_texture,

View File

@ -1754,10 +1754,11 @@ static void d3d10_get_video_output_next(void *data)
}
static const video_poke_interface_t d3d10_poke_interface = {
win32_get_metrics,
d3d10_get_flags,
d3d10_gfx_load_texture,
d3d10_gfx_unload_texture,
NULL, /* set_video_mode */
NULL, /* set_video_mode */
#ifndef __WINRT__
win32_get_refresh_rate,
#else

View File

@ -1835,10 +1835,11 @@ static void d3d11_get_video_output_next(void *data)
}
static const video_poke_interface_t d3d11_poke_interface = {
win32_get_metrics,
d3d11_get_flags,
d3d11_gfx_load_texture,
d3d11_gfx_unload_texture,
NULL, /* set_video_mode */
NULL, /* set_video_mode */
#ifndef __WINRT__
win32_get_refresh_rate,
#else

View File

@ -1834,10 +1834,11 @@ static void d3d12_get_video_output_next(void *data)
}
static const video_poke_interface_t d3d12_poke_interface = {
win32_get_metrics,
d3d12_get_flags,
d3d12_gfx_load_texture,
d3d12_gfx_unload_texture,
NULL, /* set_video_mode */
NULL, /* set_video_mode */
#ifndef __WINRT__
win32_get_refresh_rate,
#else

View File

@ -1794,6 +1794,7 @@ static uint32_t d3d8_get_flags(void *data)
}
static const video_poke_interface_t d3d_poke_interface = {
win32_get_metrics,
d3d8_get_flags,
d3d8_load_texture,
d3d8_unload_texture,

View File

@ -1966,6 +1966,7 @@ static uint32_t d3d9_get_flags(void *data)
}
static const video_poke_interface_t d3d9_poke_interface = {
win32_get_metrics,
d3d9_get_flags,
d3d9_load_texture,
d3d9_unload_texture,

View File

@ -580,6 +580,7 @@ static uint32_t dispmanx_get_flags(void *data)
}
static const video_poke_interface_t dispmanx_poke_interface = {
NULL, /* get_metrics */
dispmanx_get_flags,
NULL,
NULL,
@ -606,7 +607,6 @@ static const video_poke_interface_t dispmanx_poke_interface = {
static void dispmanx_gfx_get_poke_interface(void *data,
const video_poke_interface_t **iface)
{
(void)data;
*iface = &dispmanx_poke_interface;
}

View File

@ -933,6 +933,7 @@ static void drm_set_aspect_ratio (void *data, unsigned aspect_ratio_idx)
}
static const video_poke_interface_t drm_poke_interface = {
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,

View File

@ -1368,25 +1368,12 @@ static void exynos_gfx_set_nonblock_state(void *data, bool state,
vid->data->sync = !state;
}
static bool exynos_gfx_alive(void *data)
{
(void)data;
return true; /* always alive */
}
/* always alive */
static bool exynos_gfx_alive(void *data) { return true; }
/* drm device always has focus */
static bool exynos_gfx_focus(void *data) { return true; }
static bool exynos_gfx_focus(void *data)
{
(void)data;
return true; /* drm device always has focus */
}
static bool exynos_gfx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static bool exynos_gfx_suppress_screensaver(void *data, bool enable) { return false; }
static void exynos_gfx_set_rotation(void *data, unsigned rotation)
{
@ -1418,19 +1405,16 @@ static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
vid->aspect_changed = true;
}
static void exynos_apply_state_changes(void *data)
{
(void)data;
}
static void exynos_set_texture_frame(void *data, const void *frame, bool rgb32,
static void exynos_set_texture_frame(void *data,
const void *frame, bool rgb32,
unsigned width, unsigned height, float alpha)
{
const enum exynos_buffer_type buf_type = defaults[EXYNOS_IMAGE_MENU].buf_type;
struct exynos_video *vid = data;
struct exynos_data *pdata = vid->data;
struct g2d_image *src = pdata->src[EXYNOS_IMAGE_MENU];
const unsigned size = width * height * (rgb32 ? 4 : 2);
const enum exynos_buffer_type buf_type =
defaults[EXYNOS_IMAGE_MENU].buf_type;
struct exynos_video *vid = data;
struct exynos_data *pdata = vid->data;
struct g2d_image *src = pdata->src[EXYNOS_IMAGE_MENU];
const unsigned size = width * height * (rgb32 ? 4 : 2);
if (exynos_realloc_buffer(pdata, buf_type, size) != 0)
return;
@ -1461,21 +1445,13 @@ static void exynos_set_texture_enable(void *data, bool state, bool full_screen)
vid->menu_active = state;
}
static void exynos_apply_state_changes(void *data) { }
static void exynos_set_osd_msg(void *data, const char *msg,
const struct font_params *params)
{
(void)data;
(void)msg;
(void)params;
}
static void exynos_show_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
const struct font_params *params) { }
static void exynos_show_mouse(void *data, bool state) { }
static const video_poke_interface_t exynos_poke_interface = {
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,

View File

@ -273,35 +273,8 @@ static void fpga_gfx_free(void *data)
do_mmap_op(&fpga->regOp);
}
static bool fpga_gfx_set_shader(void *data,
enum rarch_shader_type type, const char *path)
{
(void)data;
(void)type;
(void)path;
return false;
}
static void fpga_gfx_set_rotation(void *data,
unsigned rotation)
{
(void)data;
(void)rotation;
}
static void fpga_gfx_viewport_info(void *data,
struct video_viewport *vp)
{
(void)data;
(void)vp;
}
static bool fpga_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle)
{
(void)data;
(void)buffer;
return true;
}
@ -336,24 +309,25 @@ static void fpga_set_texture_frame(void *data,
}
}
static bool fpga_gfx_set_shader(void *data,
enum rarch_shader_type type, const char *path) { return false; }
static void fpga_gfx_set_rotation(void *data,
unsigned rotation) { }
static void fpga_gfx_viewport_info(void *data,
struct video_viewport *vp) { }
static void fpga_set_osd_msg(void *data,
const char *msg,
const void *params, void *font)
{
}
const void *params, void *font) { }
static void fpga_get_video_output_size(void *data,
unsigned *width, unsigned *height) { }
static void fpga_get_video_output_prev(void *data) { }
static void fpga_get_video_output_next(void *data) { }
static void fpga_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen)
{
}
bool fullscreen) { }
static const video_poke_interface_t fpga_poke_interface = {
NULL,
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
fpga_set_video_mode,
NULL,

View File

@ -645,6 +645,7 @@ static uint32_t gcm_get_flags(void *data)
}
static const video_poke_interface_t gcm_poke_interface = {
NULL, /* get_metrics */
gcm_get_flags,
NULL, /* load_texture */
NULL, /* unload_texture */

View File

@ -682,6 +682,7 @@ static void gdi_get_video_output_next(void *data)
}
static const video_poke_interface_t gdi_poke_interface = {
win32_get_metrics,
gdi_get_flags,
gdi_load_texture,
gdi_unload_texture,

View File

@ -4532,7 +4532,20 @@ static uint32_t gl2_get_flags(void *data)
return flags;
}
static bool gl2_get_metrics(void *data, enum display_metric_types type,
float *value)
{
gl_t *gl = (gl_t*)data;
if ( gl
&& gl->ctx_data
&& gl->ctx_driver
&& gl->ctx_driver->get_metrics)
return gl->ctx_driver->get_metrics(gl->ctx_data, type, value);
return false;
}
static const video_poke_interface_t gl2_poke_interface = {
gl2_get_metrics,
gl2_get_flags,
gl2_load_texture,
gl2_unload_texture,
@ -4559,7 +4572,6 @@ static const video_poke_interface_t gl2_poke_interface = {
static void gl2_get_poke_interface(void *data,
const video_poke_interface_t **iface)
{
(void)data;
*iface = &gl2_poke_interface;
}

View File

@ -1386,7 +1386,20 @@ static uint32_t gl1_get_flags(void *data)
return flags;
}
static bool gl1_get_metrics(void *data, enum display_metric_types type,
float *value)
{
gl1_t *gl1 = (gl1_t*)data;
if ( gl1
&& gl1->ctx_data
&& gl1->ctx_driver
&& gl1->ctx_driver->get_metrics)
return gl1->ctx_driver->get_metrics(gl1->ctx_data, type, value);
return false;
}
static const video_poke_interface_t gl1_poke_interface = {
gl1_get_metrics,
gl1_get_flags,
gl1_load_texture,
gl1_unload_texture,

View File

@ -2240,7 +2240,20 @@ static retro_proc_address_t gl_core_get_proc_address(
return NULL;
}
static bool gl_core_get_metrics(void *data, enum display_metric_types type,
float *value)
{
gl_core_t *gl = (gl_core_t*)data;
if ( gl
&& gl->ctx_data
&& gl->ctx_driver
&& gl->ctx_driver->get_metrics)
return gl->ctx_driver->get_metrics(gl->ctx_data, type, value);
return false;
}
static const video_poke_interface_t gl_core_poke_interface = {
gl_core_get_metrics,
gl_core_get_flags,
gl_core_load_texture,
gl_core_unload_texture,

View File

@ -1717,6 +1717,7 @@ static uint32_t wiiu_gfx_get_flags(void *data)
}
static const video_poke_interface_t wiiu_poke_interface = {
NULL, /* get_metrics */
wiiu_gfx_get_flags,
wiiu_gfx_load_texture,
wiiu_gfx_unload_texture,

View File

@ -1326,11 +1326,12 @@ static uint32_t gx_get_flags(void *data)
}
static const video_poke_interface_t gx_poke_interface = {
NULL, /* get_metrics */
gx_get_flags,
NULL,
NULL,
gx_set_video_mode,
NULL, /* get_refresh_rate */
NULL, /* get_refresh_rate */
NULL,
gx_get_video_output_size,
gx_get_video_output_prev,

View File

@ -59,14 +59,15 @@ static uint32_t metal_get_flags(void *data);
#pragma mark Graphics Context for Metal
// The graphics context for the Metal driver is just a stubbed out version
// It supports getting metrics such as dpi which is needed for iOS/tvOS
// It supports getting metrics such as DPI which is needed for iOS/tvOS
static bool metal_gfx_ctx_get_metrics(void *data, enum display_metric_types type,
float *value)
static bool metal_gfx_ctx_get_metrics(
void *data, enum display_metric_types type,
float *value)
{
#ifdef HAVE_COCOATOUCH
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat scale = [[UIScreen mainScreen] scale];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat scale = [[UIScreen mainScreen] scale];
float displayHeight = screenRect.size.height;
float physicalWidth = screenRect.size.width * scale;
float physicalHeight = screenRect.size.height * scale;
@ -400,6 +401,7 @@ static uint32_t metal_get_flags(void *data)
}
static const video_poke_interface_t metal_poke_interface = {
.get_metrics = metal_gfx_ctx_get_metrics,
.get_flags = metal_get_flags,
.load_texture = metal_load_texture,
.unload_texture = metal_unload_texture,

View File

@ -421,7 +421,8 @@ static void network_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen) { }
static const video_poke_interface_t network_poke_interface = {
NULL,
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,
network_set_video_mode,

View File

@ -382,27 +382,28 @@ static void oga_gfx_viewport_info(void *data, struct video_viewport *vp)
}
static const video_poke_interface_t oga_poke_interface = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
oga_set_texture_frame,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
oga_set_texture_frame,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
void oga_set_rotation(void *data, unsigned rotation)

View File

@ -1099,6 +1099,7 @@ static float omap_get_refresh_rate(void *data)
}
static const video_poke_interface_t omap_gfx_poke_interface = {
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,

View File

@ -407,11 +407,12 @@ static bool ps2_get_hw_render_interface(void* data,
}
static const video_poke_interface_t ps2_poke_interface = {
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,
NULL,
NULL, /* get_refresh_rate */
NULL, /* get_refresh_rate */
ps2_set_filtering,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */

View File

@ -783,6 +783,7 @@ static uint32_t psp_get_flags(void *data)
}
static const video_poke_interface_t psp_poke_interface = {
NULL, /* get_metrics */
psp_get_flags,
NULL,
NULL,

View File

@ -698,6 +698,7 @@ static void sdl2_grab_mouse_toggle(void *data)
static uint32_t sdl2_get_flags(void *data) { return 0; }
static video_poke_interface_t sdl2_video_poke_interface = {
NULL, /* get_metrics */
sdl2_get_flags,
NULL,
NULL,

View File

@ -266,6 +266,7 @@ static void sdl_dingux_apply_state_changes(void *data) { }
static uint32_t sdl_dingux_get_flags(void *data) { return 0; }
static const video_poke_interface_t sdl_dingux_poke_interface = {
NULL, /* get_metrics */
sdl_dingux_get_flags,
NULL,
NULL,

View File

@ -521,6 +521,7 @@ static uint32_t sdl_get_flags(void *data)
}
static const video_poke_interface_t sdl_poke_interface = {
NULL, /* get_metrics */
sdl_get_flags,
NULL,
NULL,

View File

@ -516,7 +516,8 @@ static void sixel_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen) { }
static const video_poke_interface_t sixel_poke_interface = {
NULL,
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,
sixel_set_video_mode,

View File

@ -932,6 +932,7 @@ static float sunxi_get_refresh_rate (void *data)
}
static const video_poke_interface_t sunxi_poke_interface = {
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,

View File

@ -377,6 +377,7 @@ static void switch_set_texture_enable(void *data, bool enable, bool full_screen)
}
static const video_poke_interface_t switch_poke_interface = {
NULL, /* get_metrics */
NULL, /* get_flags */
NULL, /* load_texture */
NULL, /* unload_texture */

View File

@ -652,27 +652,28 @@ void switch_overlay_interface(void *data, const video_overlay_interface_t **ifac
#endif
static const video_poke_interface_t switch_poke_interface = {
NULL, /* get_flags */
NULL, /* load_texture */
NULL, /* unload_texture */
NULL, /* set_video_mode */
NULL, /* get_refresh_rate */
NULL, /* set_filtering */
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_current_framebuffer */
NULL, /* get_proc_address */
switch_set_aspect_ratio, /* set_aspect_ratio */
switch_apply_state_changes, /* apply_state_changes */
switch_set_texture_frame,
switch_set_texture_enable,
font_driver_render_msg,
NULL, /* show_mouse */
NULL, /* grab_mouse_toggle */
NULL, /* get_current_shader */
NULL, /* get_current_software_framebuffer */
NULL, /* get_hw_render_interface */
NULL, /* get_metrics */
NULL, /* get_flags */
NULL, /* load_texture */
NULL, /* unload_texture */
NULL, /* set_video_mode */
NULL, /* get_refresh_rate */
NULL, /* set_filtering */
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_current_framebuffer */
NULL, /* get_proc_address */
switch_set_aspect_ratio, /* set_aspect_ratio */
switch_apply_state_changes, /* apply_state_changes */
switch_set_texture_frame,
switch_set_texture_enable,
font_driver_render_msg,
NULL, /* show_mouse */
NULL, /* grab_mouse_toggle */
NULL, /* get_current_shader */
NULL, /* get_current_software_framebuffer */
NULL, /* get_hw_render_interface */
};
static void switch_get_poke_interface(void *data,

View File

@ -483,10 +483,49 @@ static bool vg_suppress_screensaver(void *data, bool enable)
return false;
}
static bool vg_get_metrics(void *data, enum display_metric_types type,
float *value)
{
vg_t *vg = (vg_t*)data;
if (vg && vg->ctx_data &&
vg->ctx_driver && vg->ctx_driver->get_metrics)
return vg->ctx_driver->get_metrics(vg->ctx_data, type, value);
return false;
}
static const video_poke_interface_t vg_poke_interface = {
vg_get_metrics, /* get_metrics */
NULL, /* get_flags */
NULL, /* load_texture */
NULL, /* unload_texture */
NULL, /* set_video_mode */
NULL, /* get_refresh_rate */
NULL,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_current_framebuffer */
NULL, /* get_proc_address */
NULL, /* set_aspect_ratio */
NULL, /* apply_state_changes */
NULL, /* set_texture_frame */
NULL, /* set_texture_enable */
NULL, /* render_msg */
NULL, /* show_mouse */
NULL,
NULL, /* get_current_shader */
NULL, /* get_current_software_framebuffer */
NULL /* get_hw_render_interface */
};
static bool vg_set_shader(void *data,
enum rarch_shader_type type, const char *path) { return false; }
static void vg_get_poke_interface(void *data,
const video_poke_interface_t **iface) { }
const video_poke_interface_t **iface)
{
*iface = &vg_poke_interface;
}
static bool vg_has_windowed(void *data)
{

View File

@ -359,6 +359,7 @@ static void vga_set_texture_frame(void *data,
static uint32_t vga_get_flags(void *data) { return 0; }
static const video_poke_interface_t vga_poke_interface = {
NULL, /* get_metrics */
vga_get_flags,
NULL,
NULL,

View File

@ -775,6 +775,7 @@ static uint32_t vita_get_flags(void *data)
}
static const video_poke_interface_t vita_poke_interface = {
NULL, /* get_metrics */
vita_get_flags,
vita_load_texture,
vita_unload_texture,

View File

@ -2567,7 +2567,20 @@ static void vulkan_get_video_output_next(void *data)
vk->ctx_driver->get_video_output_next(vk->ctx_data);
}
static bool vulkan_get_metrics(void *data, enum display_metric_types type,
float *value)
{
vk_t *vk = (vk_t*)data;
if ( vk
&& vk->ctx_data
&& vk->ctx_driver
&& vk->ctx_driver->get_metrics)
return vk->ctx_driver->get_metrics(vk->ctx_data, type, value);
return false;
}
static const video_poke_interface_t vulkan_poke_interface = {
vulkan_get_metrics,
vulkan_get_flags,
vulkan_load_texture,
vulkan_unload_texture,

View File

@ -179,6 +179,7 @@ static void xshm_show_mouse(void *data, bool state) { }
static void xshm_grab_mouse_toggle(void *data) { }
static video_poke_interface_t xshm_video_poke_interface = {
NULL, /* get_metrics */
NULL, /* get_flags */
NULL,
NULL,

View File

@ -1092,6 +1092,7 @@ static void xv_viewport_info(void *data, struct video_viewport *vp)
static uint32_t xv_get_flags(void *data) { return 0; }
static video_poke_interface_t xv_video_poke_interface = {
NULL, /* get_metrics */
xv_get_flags,
NULL,
NULL,

View File

@ -299,7 +299,7 @@ float gfx_display_get_dpi_scale_internal(unsigned width, unsigned height)
diagonal_pixels = (float)sqrt(
(double)((width * width) + (height * height)));
/* TODO/FIXME: On Mac, calling video_context_driver_get_metrics()
/* TODO/FIXME: On Mac, calling video_driver_get_metrics()
* here causes RetroArch to crash (EXC_BAD_ACCESS). This is
* unfortunate, and needs to be fixed at the gfx context driver
* level. Until this is done, all we can do is fallback to using
@ -322,7 +322,7 @@ float gfx_display_get_dpi_scale_internal(unsigned width, unsigned height)
metrics.type = DISPLAY_METRIC_DPI;
metrics.value = &dpi;
if (video_context_driver_get_metrics(&metrics) && (dpi > 0.0f))
if (video_driver_get_metrics(&metrics) && (dpi > 0.0f))
{
float display_size;
float dpi_scale;
@ -433,7 +433,7 @@ float gfx_display_get_dpi_scale(unsigned width, unsigned height)
/* Scale is based on display metrics - these are a fixed
* hardware property. To minimise performance overheads
* we therefore only call video_context_driver_get_metrics()
* we therefore only call video_driver_get_metrics()
* on first run, or when the current video resolution changes */
if (!scale_cached ||
(width != last_width) ||
@ -498,7 +498,7 @@ float gfx_display_get_widget_dpi_scale(
/* Scale is based on display metrics - these are a fixed
* hardware property. To minimise performance overheads
* we therefore only call video_context_driver_get_metrics()
* we therefore only call video_driver_get_metrics()
* on first run, or when the current video resolution changes */
if (!scale_cached ||
(width != last_width) ||

View File

@ -1260,6 +1260,15 @@ static struct video_shader *thread_get_current_shader(void *data)
return thr->poke->get_current_shader(thr->driver_data);
}
static bool thread_get_metrics(void *data, enum display_metric_types type,
float *value)
{
thread_video_t *thr = (thread_video_t*)data;
if (!thr || !thr->poke || !thr->poke->get_metrics)
return false;
return thr->poke->get_metrics(thr->driver_data, type, value);
}
static uint32_t thread_get_flags(void *data)
{
thread_video_t *thr = (thread_video_t*)data;
@ -1269,6 +1278,7 @@ static uint32_t thread_get_flags(void *data)
}
static const video_poke_interface_t thread_poke = {
thread_get_metrics,
thread_get_flags,
thread_load_texture,
thread_unload_texture,

View File

@ -1255,7 +1255,7 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
metrics.type = DISPLAY_METRIC_MM_WIDTH;
metrics.value = &val;
if (video_context_driver_get_metrics(&metrics))
if (video_driver_get_metrics(&metrics))
{
snprintf(tmp, sizeof(tmp), "%s: %.2f",
msg_hash_to_str(
@ -1269,7 +1269,7 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
metrics.type = DISPLAY_METRIC_MM_HEIGHT;
if (video_context_driver_get_metrics(&metrics))
if (video_driver_get_metrics(&metrics))
{
snprintf(tmp, sizeof(tmp), "%s: %.2f",
msg_hash_to_str(
@ -1283,7 +1283,7 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
metrics.type = DISPLAY_METRIC_DPI;
if (video_context_driver_get_metrics(&metrics))
if (video_driver_get_metrics(&metrics))
{
snprintf(tmp, sizeof(tmp), "%s: %.2f",
msg_hash_to_str(

View File

@ -25237,19 +25237,21 @@ static float menu_input_get_dpi(struct rarch_state *p_rarch)
/* Regardless of menu driver, need 'actual' screen DPI
* Note: DPI is a fixed hardware property. To minimise performance
* overheads we therefore only call video_context_driver_get_metrics()
* overheads we therefore only call video_driver_get_metrics()
* on first run, or when the current video resolution changes */
if (!dpi_cached ||
(p_rarch->video_driver_width != last_video_width) ||
(p_rarch->video_driver_height != last_video_height))
{
/* Note: If video_context_driver_get_metrics() fails,
struct gfx_ctx_metrics metrs;
/* Note: If video_driver_get_metrics() fails,
* we don't know what happened to dpi - so ensure it
* is reset to a sane value */
if (!p_rarch->current_video_context.get_metrics(
p_rarch->video_context_data,
DISPLAY_METRIC_DPI,
&dpi))
metrs.type = DISPLAY_METRIC_DPI;
metrs.value = &dpi;
if (!video_driver_get_metrics(&metrs))
dpi = 0.0f;
dpi_cached = true;
@ -30784,8 +30786,6 @@ bool video_driver_started_fullscreen(void)
/* Stub functions */
static bool get_metrics_null(void *data, enum display_metric_types type,
float *value) { return false; }
static bool set_resize_null(void *a, unsigned b, unsigned c) { return false; }
/**
@ -30889,9 +30889,6 @@ static void video_context_driver_reset(void)
{
struct rarch_state *p_rarch = &rarch_st;
if (!p_rarch->current_video_context.get_metrics)
p_rarch->current_video_context.get_metrics = get_metrics_null;
if (!p_rarch->current_video_context.set_resize)
p_rarch->current_video_context.set_resize = set_resize_null;
}
@ -30919,7 +30916,7 @@ void video_context_driver_destroy(void)
p_rarch->current_video_context.get_video_output_size = NULL;
p_rarch->current_video_context.get_video_output_prev = NULL;
p_rarch->current_video_context.get_video_output_next = NULL;
p_rarch->current_video_context.get_metrics = get_metrics_null;
p_rarch->current_video_context.get_metrics = NULL;
p_rarch->current_video_context.translate_aspect = NULL;
p_rarch->current_video_context.update_window_title = NULL;
p_rarch->current_video_context.check_window = NULL;
@ -33495,10 +33492,12 @@ void video_context_driver_free(void)
p_rarch->video_context_data = NULL;
}
bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics)
bool video_driver_get_metrics(gfx_ctx_metrics_t *metrics)
{
struct rarch_state *p_rarch = &rarch_st;
return p_rarch->current_video_context.get_metrics(
if (!p_rarch->video_driver_poke || !p_rarch->video_driver_poke->get_metrics)
return false;
return p_rarch->video_driver_poke->get_metrics(
p_rarch->video_context_data,
metrics->type,
metrics->value);

View File

@ -1380,6 +1380,7 @@ struct aspect_ratio_elem
typedef struct video_poke_interface
{
get_metrics_cb get_metrics;
uint32_t (*get_flags)(void *data);
uintptr_t (*load_texture)(void *video_data, void *data,
bool threaded, enum texture_filter_type filter_type);
@ -1781,7 +1782,7 @@ bool video_context_driver_get_refresh_rate(float *refresh_rate);
bool video_context_driver_set_flags(gfx_ctx_flags_t *flags);
bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics);
bool video_driver_get_metrics(gfx_ctx_metrics_t *metrics);
bool video_context_driver_input_driver(gfx_ctx_input_t *inp);