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 struct Switches { | 154 bool IsLCDTextEnabled() { |
155 Switches() | 155 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
156 : has_initialized_switches_(false) | 156 if (command_line->HasSwitch(cc::switches::kDisableLCDText)) |
157 , impl_side_painting_enabled_(false) | 157 return false; |
158 , map_image_enabled_(false) | 158 else if (command_line->HasSwitch(cc::switches::kEnableLCDText)) |
159 , lcd_text_enabled_(false) { | 159 return true; |
160 } | |
161 | 160 |
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; | |
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 { | |
180 #if defined(OS_ANDROID) | 161 #if defined(OS_ANDROID) |
181 g_switches.impl_side_painting_enabled_ = true; | 162 return false; |
182 #else | 163 #else |
183 g_switches.impl_side_painting_enabled_ = false; | 164 return true; |
184 #endif | 165 #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; | |
209 } | 166 } |
210 | 167 |
| 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 |
211 bool IsImplSidePaintingEnabled() { | 185 bool IsImplSidePaintingEnabled() { |
212 InitializeSwitchesIfRequired(); | 186 static bool enabled = CheckImplSidePaintingStatus(); |
213 return g_switches.impl_side_painting_enabled_; | 187 return enabled; |
214 } | 188 } |
215 | 189 |
216 bool IsMapImageEnabled() { | 190 bool IsMapImageEnabled() { |
217 InitializeSwitchesIfRequired(); | 191 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
218 return g_switches.map_image_enabled_; | |
219 } | |
220 | 192 |
221 bool IsLCDTextEnabled() { | 193 if (command_line.HasSwitch(cc::switches::kDisableMapImage)) |
222 InitializeSwitchesIfRequired(); | 194 return false; |
223 return g_switches.lcd_text_enabled_; | 195 else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) |
| 196 return true; |
| 197 |
| 198 return false; |
224 } | 199 } |
225 | 200 |
226 } // namespace switches | 201 } // namespace switches |
227 } // namespace cc | 202 } // namespace cc |
OLD | NEW |