Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Unified Diff: ui/gfx/display.cc

Issue 992383002: Fix for the WebInputEventBuilderTest.TestMouseEventScale content_unittests failures on the DrMemory… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/gfx/display.h ('K') | « ui/gfx/display.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/display.cc
diff --git a/ui/gfx/display.cc b/ui/gfx/display.cc
index c79dcea9ed1dcfedc7a2959cb67710a89a20841e..c596a9aca34201bcd6033526f6fd34546ad04fd1 100644
--- a/ui/gfx/display.cc
+++ b/ui/gfx/display.cc
@@ -19,6 +19,16 @@
namespace gfx {
namespace {
+// This variable tracks whether the forced device scale factor switch needs to
+// be read from the command line, i.e. if it is set to -1 then the command line
+// is checked.
+int g_HasForcedDeviceScaleFactor = -1;
+
+// This variable caches the forced device scale factor value which is read off
+// the command line. If the cache is invalidated by setting this variable to
+// -1.0, we read the forced device scale factor again.
+float g_ForcedDeviceScaleFactor = -1.0;
+
bool HasForceDeviceScaleFactorImpl() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kForceDeviceScaleFactor);
@@ -44,16 +54,22 @@ const int64 Display::kInvalidDisplayID = -1;
// static
float Display::GetForcedDeviceScaleFactor() {
- static const float kForcedDeviceScaleFactor =
- GetForcedDeviceScaleFactorImpl();
- return kForcedDeviceScaleFactor;
+ if (g_ForcedDeviceScaleFactor < 0)
scottmg 2015/03/10 23:02:01 I think it would be less complex to have bool
ananta 2015/03/10 23:31:57 Sadly that would be tricky. Given that we have two
+ g_ForcedDeviceScaleFactor = GetForcedDeviceScaleFactorImpl();
+ return g_ForcedDeviceScaleFactor;
}
//static
bool Display::HasForceDeviceScaleFactor() {
- static const bool kHasForceDeviceScaleFactor =
- HasForceDeviceScaleFactorImpl();
- return kHasForceDeviceScaleFactor;
+ if (g_HasForcedDeviceScaleFactor == -1)
+ g_HasForcedDeviceScaleFactor = HasForceDeviceScaleFactorImpl();
+ return !!g_HasForcedDeviceScaleFactor;
+}
+
+// static
+void Display::ResetForceDeviceScaleFactor() {
+ g_HasForcedDeviceScaleFactor = -1;
+ g_ForcedDeviceScaleFactor = -1.0;
}
Display::Display()
« ui/gfx/display.h ('K') | « ui/gfx/display.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698