Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/base/switches.h" | 5 #include "cc/base/switches.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 namespace switches { | 10 namespace switches { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 // Makes pixel tests write their output instead of read it. | 144 // Makes pixel tests write their output instead of read it. |
| 145 const char kCCRebaselinePixeltests[] = "cc-rebaseline-pixeltests"; | 145 const char kCCRebaselinePixeltests[] = "cc-rebaseline-pixeltests"; |
| 146 | 146 |
| 147 // Disable textures using RGBA_4444 layout. | 147 // Disable textures using RGBA_4444 layout. |
| 148 const char kDisable4444Textures[] = "disable-4444-textures"; | 148 const char kDisable4444Textures[] = "disable-4444-textures"; |
| 149 | 149 |
| 150 // Disable touch hit testing in the compositor. | 150 // Disable touch hit testing in the compositor. |
| 151 const char kDisableCompositorTouchHitTesting[] = | 151 const char kDisableCompositorTouchHitTesting[] = |
| 152 "disable-compositor-touch-hit-testing"; | 152 "disable-compositor-touch-hit-testing"; |
| 153 | 153 |
| 154 bool IsLCDTextEnabled() { | 154 struct Switches { |
| 155 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 155 Switches() |
| 156 if (command_line->HasSwitch(cc::switches::kDisableLCDText)) | 156 : has_initialized_switches_(false) |
| 157 return false; | 157 , impl_side_painting_enabled_(false) |
| 158 else if (command_line->HasSwitch(cc::switches::kEnableLCDText)) | 158 , map_image_enabled_(false) |
| 159 return true; | 159 , lcd_text_enabled_(false) { |
| 160 } | |
| 160 | 161 |
| 162 bool has_initialized_switches_ : 1; | |
| 163 bool impl_side_painting_enabled_ : 1; | |
| 164 bool map_image_enabled_ : 1; | |
| 165 bool lcd_text_enabled_ : 1; | |
| 166 }; | |
| 167 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
| |
| 168 | |
| 169 void InitializeSwitchesIfRequired() { | |
| 170 if (g_switches.has_initialized_switches_) | |
| 171 return; | |
| 172 | |
| 173 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 174 // Impl-side painting. | |
| 175 if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) { | |
| 176 g_switches.impl_side_painting_enabled_ = false; | |
| 177 } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) { | |
| 178 g_switches.impl_side_painting_enabled_ = true; | |
| 179 } else { | |
| 161 #if defined(OS_ANDROID) | 180 #if defined(OS_ANDROID) |
| 162 return false; | 181 g_switches.impl_side_painting_enabled_ = true; |
| 163 #else | 182 #else |
| 164 return true; | 183 g_switches.impl_side_painting_enabled_ = false; |
| 165 #endif | 184 #endif |
| 185 } | |
| 186 | |
| 187 // Map-Image. | |
| 188 if (command_line.HasSwitch(cc::switches::kDisableMapImage)) | |
| 189 g_switches.map_image_enabled_ = false; | |
| 190 else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) | |
| 191 g_switches.map_image_enabled_ = true; | |
| 192 else | |
| 193 g_switches.map_image_enabled_ = false; | |
| 194 | |
| 195 // LCD-Text. | |
| 196 if (command_line.HasSwitch(cc::switches::kDisableLCDText)) { | |
| 197 g_switches.lcd_text_enabled_ = false; | |
| 198 } else if (command_line.HasSwitch(cc::switches::kEnableLCDText)) { | |
| 199 g_switches.lcd_text_enabled_ = true; | |
| 200 } else { | |
| 201 #if defined(OS_ANDROID) | |
| 202 g_switches.lcd_text_enabled_ = false; | |
| 203 #else | |
| 204 g_switches.lcd_text_enabled_ = true; | |
| 205 #endif | |
| 206 } | |
| 207 | |
| 208 g_switches.has_initialized_switches_ = true; | |
| 166 } | 209 } |
| 167 | 210 |
| 168 namespace { | |
| 169 bool CheckImplSidePaintingStatus() { | |
| 170 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 171 | |
| 172 if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) | |
| 173 return false; | |
| 174 else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) | |
| 175 return true; | |
| 176 | |
| 177 #if defined(OS_ANDROID) | |
| 178 return true; | |
| 179 #else | |
| 180 return false; | |
| 181 #endif | |
| 182 } | |
| 183 } // namespace | |
| 184 | |
| 185 bool IsImplSidePaintingEnabled() { | 211 bool IsImplSidePaintingEnabled() { |
| 186 static bool enabled = CheckImplSidePaintingStatus(); | 212 InitializeSwitchesIfRequired(); |
| 187 return enabled; | 213 return g_switches.impl_side_painting_enabled_; |
| 188 } | 214 } |
| 189 | 215 |
| 190 bool IsMapImageEnabled() { | 216 bool IsMapImageEnabled() { |
| 191 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 217 InitializeSwitchesIfRequired(); |
| 218 return g_switches.map_image_enabled_; | |
| 219 } | |
| 192 | 220 |
| 193 if (command_line.HasSwitch(cc::switches::kDisableMapImage)) | 221 bool IsLCDTextEnabled() { |
| 194 return false; | 222 InitializeSwitchesIfRequired(); |
| 195 else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) | 223 return g_switches.lcd_text_enabled_; |
| 196 return true; | |
| 197 | |
| 198 return false; | |
| 199 } | 224 } |
| 200 | 225 |
| 201 } // namespace switches | 226 } // namespace switches |
| 202 } // namespace cc | 227 } // namespace cc |
| OLD | NEW |