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

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 boneheaded error 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
« no previous file with comments | « 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..edfc48ea4be96889fc5f484eea60bc13bb5595f1 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_has_forced_device_scale_factor = -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_forced_device_scale_factor = -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_forced_device_scale_factor < 0)
+ g_forced_device_scale_factor = GetForcedDeviceScaleFactorImpl();
+ return g_forced_device_scale_factor;
}
//static
bool Display::HasForceDeviceScaleFactor() {
- static const bool kHasForceDeviceScaleFactor =
- HasForceDeviceScaleFactorImpl();
- return kHasForceDeviceScaleFactor;
+ if (g_has_forced_device_scale_factor == -1)
+ g_has_forced_device_scale_factor = HasForceDeviceScaleFactorImpl();
+ return !!g_has_forced_device_scale_factor;
+}
+
+// static
+void Display::ResetForceDeviceScaleFactorForTesting() {
+ g_has_forced_device_scale_factor = -1;
+ g_forced_device_scale_factor = -1.0;
}
Display::Display()
« no previous file with comments | « ui/gfx/display.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698