mirror of
https://github.com/libretro/RetroArch
synced 2025-02-25 12:41:18 +00:00
Implement GFX_CTL_GET_METRICS
This commit is contained in:
parent
ce41c5bbca
commit
3140e5f980
@ -102,25 +102,6 @@ bool gfx_ctx_set_video_mode(
|
||||
video_context_data, width, height, fullscreen);
|
||||
}
|
||||
|
||||
void gfx_ctx_translate_aspect(float *aspect,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
if (!current_video_context || !current_video_context->translate_aspect)
|
||||
return;
|
||||
|
||||
*aspect = current_video_context->translate_aspect(
|
||||
video_context_data, width, height);
|
||||
}
|
||||
|
||||
bool gfx_ctx_get_metrics(enum display_metric_types type, float *value)
|
||||
{
|
||||
if (!current_video_context || !current_video_context->get_metrics)
|
||||
return false;
|
||||
return current_video_context->get_metrics(video_context_data, type,
|
||||
value);
|
||||
}
|
||||
|
||||
|
||||
bool gfx_ctx_image_buffer_write(const void *frame, unsigned width,
|
||||
unsigned height, unsigned pitch, bool rgb32,
|
||||
unsigned index, void **image_handle)
|
||||
@ -439,6 +420,15 @@ bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data)
|
||||
proc->addr = current_video_context->get_proc_address(proc->sym);
|
||||
}
|
||||
break;
|
||||
case GFX_CTL_GET_METRICS:
|
||||
{
|
||||
gfx_ctx_metrics_t *metrics = (gfx_ctx_metrics_t*)data;
|
||||
if (!current_video_context || !current_video_context->get_metrics)
|
||||
return false;
|
||||
return current_video_context->get_metrics(video_context_data,
|
||||
metrics->type,
|
||||
metrics->value);
|
||||
}
|
||||
case GFX_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
|
@ -74,7 +74,8 @@ enum gfx_ctx_ctl_state
|
||||
GFX_CTL_GET_VIDEO_OUTPUT_SIZE,
|
||||
GFX_CTL_SWAP_INTERVAL,
|
||||
GFX_CTL_PROC_ADDRESS_GET,
|
||||
GFX_CTL_TRANSLATE_ASPECT
|
||||
GFX_CTL_TRANSLATE_ASPECT,
|
||||
GFX_CTL_GET_METRICS
|
||||
};
|
||||
|
||||
typedef void (*gfx_ctx_proc_t)(void);
|
||||
@ -254,8 +255,6 @@ extern const gfx_ctx_driver_t gfx_ctx_null;
|
||||
const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, const char *ident,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx);
|
||||
|
||||
bool gfx_ctx_get_metrics(enum display_metric_types type, float *value);
|
||||
|
||||
bool gfx_ctx_set_video_mode(unsigned width, unsigned height,
|
||||
bool fullscreen);
|
||||
|
||||
|
@ -406,15 +406,19 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_GET_DPI:
|
||||
{
|
||||
gfx_ctx_metrics_t metrics;
|
||||
float *dpi = (float*)data;
|
||||
*dpi = menu_dpi_override_value;
|
||||
|
||||
if (!settings)
|
||||
return true;
|
||||
|
||||
metrics.type = DISPLAY_METRIC_DPI;
|
||||
metrics.value = dpi;
|
||||
|
||||
if (settings->menu.dpi.override_enable)
|
||||
*dpi = settings->menu.dpi.override_value;
|
||||
else if (!gfx_ctx_get_metrics(DISPLAY_METRIC_DPI, dpi) || !*dpi)
|
||||
else if (!gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics) || !*dpi)
|
||||
*dpi = menu_dpi_override_value;
|
||||
}
|
||||
break;
|
||||
|
@ -605,8 +605,13 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info)
|
||||
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
|
||||
|
||||
{
|
||||
gfx_ctx_metrics_t metrics;
|
||||
float val = 0.0f;
|
||||
if (gfx_ctx_get_metrics(DISPLAY_METRIC_MM_WIDTH, &val))
|
||||
|
||||
metrics.type = DISPLAY_METRIC_MM_WIDTH;
|
||||
metrics.value = &val;
|
||||
|
||||
if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics))
|
||||
{
|
||||
snprintf(tmp, sizeof(tmp), "%s: %.2f",
|
||||
menu_hash_to_str(MENU_LABEL_VALUE_SYSTEM_INFO_DISPLAY_METRIC_MM_WIDTH), val);
|
||||
@ -614,7 +619,9 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info)
|
||||
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
|
||||
}
|
||||
|
||||
if (gfx_ctx_get_metrics(DISPLAY_METRIC_MM_HEIGHT, &val))
|
||||
metrics.type = DISPLAY_METRIC_MM_HEIGHT;
|
||||
|
||||
if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics))
|
||||
{
|
||||
snprintf(tmp, sizeof(tmp), "%s: %.2f",
|
||||
menu_hash_to_str(MENU_LABEL_VALUE_SYSTEM_INFO_DISPLAY_METRIC_MM_WIDTH), val);
|
||||
@ -622,7 +629,9 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info)
|
||||
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
|
||||
}
|
||||
|
||||
if (gfx_ctx_get_metrics(DISPLAY_METRIC_DPI, &val))
|
||||
metrics.type = DISPLAY_METRIC_DPI;
|
||||
|
||||
if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics))
|
||||
{
|
||||
snprintf(tmp, sizeof(tmp), "%s: %.2f",
|
||||
menu_hash_to_str(MENU_LABEL_VALUE_SYSTEM_INFO_DISPLAY_METRIC_DPI), val);
|
||||
|
@ -1061,11 +1061,15 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
|
||||
|
||||
if (menu_input->pointer.pressed[0])
|
||||
{
|
||||
gfx_ctx_metrics_t metrics;
|
||||
float dpi;
|
||||
int16_t pointer_x = menu_input_pointer_state(MENU_POINTER_X_AXIS);
|
||||
int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS);
|
||||
float dpi;
|
||||
gfx_ctx_get_metrics(DISPLAY_METRIC_DPI, &dpi);
|
||||
|
||||
metrics.type = DISPLAY_METRIC_DPI;
|
||||
metrics.value = &dpi;
|
||||
|
||||
gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics);
|
||||
|
||||
if (!menu_input->pointer.oldpressed[0])
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user