aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Robbins <kde.psych@gmail.com>2015-02-05 17:22:10 +1000
committerCraig Robbins <kde.psych@gmail.com>2015-02-05 17:34:10 +1000
commit9a0dd47057cad18522e43d159a06c856dfdeeef4 (patch)
tree0e10e58c6473277e0388c532508269b68392b390
parent929e0b0ad8a1e2a7b373f5661e52e2384a24916d (diff)
downloadminetest-9a0dd47057cad18522e43d159a06c856dfdeeef4.tar.gz
minetest-9a0dd47057cad18522e43d159a06c856dfdeeef4.tar.bz2
minetest-9a0dd47057cad18522e43d159a06c856dfdeeef4.zip
Fix performance regression
-rw-r--r--src/porting.cpp13
1 files 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()
{