Skip to content

Commit 9a0dd47

Browse files
committedFeb 5, 2015
Fix performance regression
1 parent 929e0b0 commit 9a0dd47

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

Diff for: ‎src/porting.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type)
647647

648648
#ifndef __ANDROID__
649649
#ifdef XORG_USED
650-
float getDisplayDensity()
650+
651+
static float calcDisplayDensity()
651652
{
652653
const char* current_display = getenv("DISPLAY");
653654

@@ -665,14 +666,22 @@ float getDisplayDensity()
665666

666667
XCloseDisplay(x11display);
667668

668-
return (std::max(dpi_height,dpi_width) / 96.0);
669+
return std::max(dpi_height,dpi_width) / 96.0;
669670
}
670671
}
671672

672673
/* return manually specified dpi */
673674
return g_settings->getFloat("screen_dpi")/96.0;
674675
}
675676

677+
678+
float getDisplayDensity()
679+
{
680+
static float cached_display_density = calcDisplayDensity();
681+
return cached_display_density;
682+
}
683+
684+
676685
#else
677686
float getDisplayDensity()
678687
{

0 commit comments

Comments
 (0)
Please sign in to comment.