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 |