From 9a0dd47057cad18522e43d159a06c856dfdeeef4 Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Thu, 5 Feb 2015 17:22:10 +1000 Subject: [PATCH] Fix performance regression --- src/porting.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/porting.cpp b/src/porting.cpp index e99d08426..8a685539b 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -647,7 +647,8 @@ const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type) #ifndef __ANDROID__ #ifdef XORG_USED -float getDisplayDensity() + +static float calcDisplayDensity() { const char* current_display = getenv("DISPLAY"); @@ -665,7 +666,7 @@ float getDisplayDensity() XCloseDisplay(x11display); - return (std::max(dpi_height,dpi_width) / 96.0); + return std::max(dpi_height,dpi_width) / 96.0; } } @@ -673,6 +674,14 @@ float getDisplayDensity() return g_settings->getFloat("screen_dpi")/96.0; } + +float getDisplayDensity() +{ + static float cached_display_density = calcDisplayDensity(); + return cached_display_density; +} + + #else float getDisplayDensity() { -- 2.25.1