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

Unified Diff: cc/base/switches.cc

Issue 85753003: Revert of Generic version of caching cc switches to avoid searching of switches on each function call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/switches.cc
diff --git a/cc/base/switches.cc b/cc/base/switches.cc
index 2583c18e60369114e03b4364a15809c399cbcf5c..be4a2c55adfbcb22214a0a92439f59da8fd112e2 100644
--- a/cc/base/switches.cc
+++ b/cc/base/switches.cc
@@ -151,76 +151,51 @@
const char kDisableCompositorTouchHitTesting[] =
"disable-compositor-touch-hit-testing";
-struct Switches {
- Switches()
- : has_initialized_switches_(false)
- , impl_side_painting_enabled_(false)
- , map_image_enabled_(false)
- , lcd_text_enabled_(false) {
- }
-
- bool has_initialized_switches_ : 1;
- bool impl_side_painting_enabled_ : 1;
- bool map_image_enabled_ : 1;
- bool lcd_text_enabled_ : 1;
-};
-static Switches g_switches;
-
-void InitializeSwitchesIfRequired() {
- if (g_switches.has_initialized_switches_)
- return;
-
+bool IsLCDTextEnabled() {
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(cc::switches::kDisableLCDText))
+ return false;
+ else if (command_line->HasSwitch(cc::switches::kEnableLCDText))
+ return true;
+
+#if defined(OS_ANDROID)
+ return false;
+#else
+ return true;
+#endif
+}
+
+namespace {
+bool CheckImplSidePaintingStatus() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- // Impl-side painting.
- if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) {
- g_switches.impl_side_painting_enabled_ = false;
- } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) {
- g_switches.impl_side_painting_enabled_ = true;
- } else {
+
+ if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting))
+ return false;
+ else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting))
+ return true;
+
#if defined(OS_ANDROID)
- g_switches.impl_side_painting_enabled_ = true;
+ return true;
#else
- g_switches.impl_side_painting_enabled_ = false;
+ return false;
#endif
- }
-
- // Map-Image.
+}
+} // namespace
+
+bool IsImplSidePaintingEnabled() {
+ static bool enabled = CheckImplSidePaintingStatus();
+ return enabled;
+}
+
+bool IsMapImageEnabled() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+
if (command_line.HasSwitch(cc::switches::kDisableMapImage))
- g_switches.map_image_enabled_ = false;
+ return false;
else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
- g_switches.map_image_enabled_ = true;
- else
- g_switches.map_image_enabled_ = false;
-
- // LCD-Text.
- if (command_line.HasSwitch(cc::switches::kDisableLCDText)) {
- g_switches.lcd_text_enabled_ = false;
- } else if (command_line.HasSwitch(cc::switches::kEnableLCDText)) {
- g_switches.lcd_text_enabled_ = true;
- } else {
-#if defined(OS_ANDROID)
- g_switches.lcd_text_enabled_ = false;
-#else
- g_switches.lcd_text_enabled_ = true;
-#endif
- }
-
- g_switches.has_initialized_switches_ = true;
-}
-
-bool IsImplSidePaintingEnabled() {
- InitializeSwitchesIfRequired();
- return g_switches.impl_side_painting_enabled_;
-}
-
-bool IsMapImageEnabled() {
- InitializeSwitchesIfRequired();
- return g_switches.map_image_enabled_;
-}
-
-bool IsLCDTextEnabled() {
- InitializeSwitchesIfRequired();
- return g_switches.lcd_text_enabled_;
+ return true;
+
+ return false;
}
} // namespace switches
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698