Chromium Code Reviews| Index: cc/base/switches.cc |
| diff --git a/cc/base/switches.cc b/cc/base/switches.cc |
| index be4a2c55adfbcb22214a0a92439f59da8fd112e2..2583c18e60369114e03b4364a15809c399cbcf5c 100644 |
| --- a/cc/base/switches.cc |
| +++ b/cc/base/switches.cc |
| @@ -151,51 +151,76 @@ const char kDisable4444Textures[] = "disable-4444-textures"; |
| const char kDisableCompositorTouchHitTesting[] = |
| "disable-compositor-touch-hit-testing"; |
| -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; |
| +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; |
|
vivekg
2013/11/20 01:50:15
How about moving this global variable as local sta
danakj
2013/11/20 01:55:21
Then it would also have to return a const Switches
|
| + |
| +void InitializeSwitchesIfRequired() { |
| + if (g_switches.has_initialized_switches_) |
| + return; |
| + 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 defined(OS_ANDROID) |
| - return false; |
| + g_switches.impl_side_painting_enabled_ = true; |
| #else |
| - return true; |
| + g_switches.impl_side_painting_enabled_ = false; |
| #endif |
| -} |
| - |
| -namespace { |
| -bool CheckImplSidePaintingStatus() { |
| - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| - |
| - if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) |
| - return false; |
| - else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) |
| - return true; |
| + } |
| + // Map-Image. |
| + if (command_line.HasSwitch(cc::switches::kDisableMapImage)) |
| + g_switches.map_image_enabled_ = 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) |
| - return true; |
| + g_switches.lcd_text_enabled_ = false; |
| #else |
| - return false; |
| + g_switches.lcd_text_enabled_ = true; |
| #endif |
| + } |
| + |
| + g_switches.has_initialized_switches_ = true; |
| } |
| -} // namespace |
| bool IsImplSidePaintingEnabled() { |
| - static bool enabled = CheckImplSidePaintingStatus(); |
| - return enabled; |
| + InitializeSwitchesIfRequired(); |
| + return g_switches.impl_side_painting_enabled_; |
| } |
| bool IsMapImageEnabled() { |
| - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| - |
| - if (command_line.HasSwitch(cc::switches::kDisableMapImage)) |
| - return false; |
| - else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) |
| - return true; |
| + InitializeSwitchesIfRequired(); |
| + return g_switches.map_image_enabled_; |
| +} |
| - return false; |
| +bool IsLCDTextEnabled() { |
| + InitializeSwitchesIfRequired(); |
| + return g_switches.lcd_text_enabled_; |
| } |
| } // namespace switches |