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 class CCSwitchHandler { |
danakj
2013/11/13 19:37:40
you're already in the cc:: namespace. How about ju
| |
155 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 155 public: |
156 if (command_line->HasSwitch(cc::switches::kDisableLCDText)) | 156 static bool isImplSidePaintingEnabled(); |
danakj
2013/11/13 19:37:40
IsImplSidePaintingEnabled <- capitalized
for all
| |
157 return false; | 157 static bool isMapImageEnabled(); |
158 else if (command_line->HasSwitch(cc::switches::kEnableLCDText)) | 158 static bool isLCDTextEnabled(); |
159 return true; | |
160 | 159 |
161 #if defined(OS_ANDROID) | 160 private: |
162 return false; | 161 static void initializeCCSwitchesIfRequired(); |
163 #else | 162 |
164 return true; | 163 private: |
165 #endif | 164 static bool s_has_initialized_switches_; |
danakj
2013/11/13 19:37:40
no trailing _ on static variables. they are not in
| |
165 static bool s_impl_side_painting_enabled_; | |
166 static bool s_map_image_enabled_; | |
167 static bool s_lcd_text_enabled_; | |
168 }; | |
169 | |
170 bool CCSwitchHandler::isImplSidePaintingEnabled() { | |
171 initializeCCSwitchesIfRequired(); | |
172 return s_impl_side_painting_enabled_; | |
166 } | 173 } |
167 | 174 |
168 namespace { | 175 bool CCSwitchHandler::isMapImageEnabled() { |
169 bool CheckImplSidePaintingStatus() { | 176 initializeCCSwitchesIfRequired(); |
177 return s_map_image_enabled_; | |
178 } | |
179 | |
180 bool CCSwitchHandler::isLCDTextEnabled() { | |
181 initializeCCSwitchesIfRequired(); | |
182 return s_lcd_text_enabled_; | |
183 } | |
184 | |
185 void CCSwitchHandler::initializeCCSwitchesIfRequired() { | |
186 if (s_has_initialized_switches_) | |
187 return; | |
188 | |
170 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 189 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
190 // Impl-side painting. | |
191 if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) { | |
192 s_impl_side_painting_enabled_ = false; | |
193 } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) { | |
194 s_impl_side_painting_enabled_ = true; | |
195 } else { | |
196 #if defined(OS_ANDROID) | |
197 s_impl_side_painting_enabled_ = true; | |
198 #else | |
199 s_impl_side_painting_enabled_ = false; | |
200 #endif | |
201 } | |
171 | 202 |
172 if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) | 203 // Map-Image. |
173 return false; | 204 if (command_line.HasSwitch(cc::switches::kDisableMapImage)) |
174 else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) | 205 s_map_image_enabled_ = false; |
175 return true; | 206 else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) |
207 s_map_image_enabled_ = true; | |
208 else | |
209 s_map_image_enabled_ = false; | |
176 | 210 |
211 // LCD-Text. | |
212 if (command_line.HasSwitch(cc::switches::kDisableLCDText)) { | |
213 s_lcd_text_enabled_ = false; | |
214 } else if (command_line.HasSwitch(cc::switches::kEnableLCDText)) { | |
215 s_lcd_text_enabled_ = true; | |
216 } else { | |
177 #if defined(OS_ANDROID) | 217 #if defined(OS_ANDROID) |
178 return true; | 218 s_lcd_text_enabled_ = false; |
179 #else | 219 #else |
180 return false; | 220 s_lcd_text_enabled_ = true; |
181 #endif | 221 #endif |
222 } | |
223 | |
224 s_has_initialized_switches_ = true; | |
182 } | 225 } |
183 } // namespace | 226 |
227 bool CCSwitchHandler::s_has_initialized_switches_ = false; | |
228 bool CCSwitchHandler::s_impl_side_painting_enabled_ = false; | |
229 bool CCSwitchHandler::s_map_image_enabled_ = false; | |
230 bool CCSwitchHandler::s_lcd_text_enabled_ = false; | |
184 | 231 |
185 bool IsImplSidePaintingEnabled() { | 232 bool IsImplSidePaintingEnabled() { |
186 static bool enabled = CheckImplSidePaintingStatus(); | 233 return CCSwitchHandler::isImplSidePaintingEnabled(); |
187 return enabled; | |
188 } | 234 } |
189 | 235 |
190 bool IsMapImageEnabled() { | 236 bool IsMapImageEnabled() { |
191 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 237 return CCSwitchHandler::isMapImageEnabled(); |
238 } | |
192 | 239 |
193 if (command_line.HasSwitch(cc::switches::kDisableMapImage)) | 240 bool IsLCDTextEnabled() { |
194 return false; | 241 return CCSwitchHandler::isLCDTextEnabled(); |
195 else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) | |
196 return true; | |
197 | |
198 return false; | |
199 } | 242 } |
200 | 243 |
201 } // namespace switches | 244 } // namespace switches |
202 } // namespace cc | 245 } // namespace cc |
OLD | NEW |