Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: cc/base/switches.cc

Issue 69123002: Generic version of caching cc switches to avoid searching of switches on each function call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified GPU Rasterization switch accordingly. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Makes pixel tests write their output instead of read it. 149 // Makes pixel tests write their output instead of read it.
150 const char kCCRebaselinePixeltests[] = "cc-rebaseline-pixeltests"; 150 const char kCCRebaselinePixeltests[] = "cc-rebaseline-pixeltests";
151 151
152 // Disable textures using RGBA_4444 layout. 152 // Disable textures using RGBA_4444 layout.
153 const char kDisable4444Textures[] = "disable-4444-textures"; 153 const char kDisable4444Textures[] = "disable-4444-textures";
154 154
155 // Disable touch hit testing in the compositor. 155 // Disable touch hit testing in the compositor.
156 const char kDisableCompositorTouchHitTesting[] = 156 const char kDisableCompositorTouchHitTesting[] =
157 "disable-compositor-touch-hit-testing"; 157 "disable-compositor-touch-hit-testing";
158 158
159 bool IsLCDTextEnabled() { 159 static bool g_has_initialized_switches = false;
160 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 160 static bool g_impl_side_painting_enabled = false;
161 if (command_line->HasSwitch(cc::switches::kDisableLCDText)) 161 static bool g_map_image_enabled = false;
162 return false; 162 static bool g_lcd_text_enabled = false;
163 else if (command_line->HasSwitch(cc::switches::kEnableLCDText)) 163 static bool g_gpu_rasterization_enabled = false;
164 return true;
165 164
165 static void InitializeSwitchesIfNeeded() {
166 if (!g_has_initialized_switches) {
167 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
168 // Impl-side painting.
169 if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) {
170 g_impl_side_painting_enabled = false;
171 } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) {
172 g_impl_side_painting_enabled = true;
173 } else {
166 #if defined(OS_ANDROID) 174 #if defined(OS_ANDROID)
167 return false; 175 g_impl_side_painting_enabled = true;
168 #else 176 #else
169 return true; 177 g_impl_side_painting_enabled = false;
170 #endif 178 #endif
179 }
180
181 // Map-Image.
182 if (command_line.HasSwitch(cc::switches::kDisableMapImage))
183 g_map_image_enabled = false;
184 else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
185 g_map_image_enabled = true;
186 else
187 g_map_image_enabled = false;
188
189 // LCD-Text.
190 if (command_line.HasSwitch(cc::switches::kDisableLCDText)) {
191 g_lcd_text_enabled = false;
192 } else if (command_line.HasSwitch(cc::switches::kEnableLCDText)) {
193 g_lcd_text_enabled = true;
194 } else {
195 #if defined(OS_ANDROID)
196 g_lcd_text_enabled = false;
197 #else
198 g_lcd_text_enabled = true;
199 #endif
200 }
201
202 // GPU Rasterization.
203 if(command_line.HasSwitch(cc::switches::kEnableGPURasterization)) {
204 g_gpu_rasterization_enabled = true;
205 }
206 g_has_initialized_switches = true;
207 }
171 } 208 }
172 209
173 namespace {
174 bool CheckImplSidePaintingStatus() {
175 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
176
177 if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting))
178 return false;
179 else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting))
180 return true;
181
182 #if defined(OS_ANDROID)
183 return true;
184 #else
185 return false;
186 #endif
187 }
188 } // namespace
189
190 bool IsImplSidePaintingEnabled() { 210 bool IsImplSidePaintingEnabled() {
191 static bool enabled = CheckImplSidePaintingStatus(); 211 InitializeSwitchesIfNeeded();
192 return enabled; 212 return g_impl_side_painting_enabled;
193 } 213 }
194 214
195 bool IsGPURasterizationEnabled() { 215 bool IsGPURasterizationEnabled() {
196 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 216 InitializeSwitchesIfNeeded();
197 return command_line.HasSwitch(cc::switches::kEnableGPURasterization); 217 return g_gpu_rasterization_enabled;
198 } 218 }
199 219
200 bool IsMapImageEnabled() { 220 bool IsMapImageEnabled() {
201 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 221 InitializeSwitchesIfNeeded();
222 return g_map_image_enabled;
223 }
202 224
203 if (command_line.HasSwitch(cc::switches::kDisableMapImage)) 225 bool IsLCDTextEnabled() {
204 return false; 226 InitializeSwitchesIfNeeded();
205 else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) 227 return g_lcd_text_enabled;
206 return true;
207
208 return false;
209 } 228 }
210 229
211 } // namespace switches 230 } // namespace switches
212 } // namespace cc 231 } // namespace cc
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698