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

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: Created 7 years, 1 month 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 else if (command_line->HasSwitch(cc::switches::kEnableLCDText)) 158 else if (command_line->HasSwitch(cc::switches::kEnableLCDText))
159 return true; 159 return true;
160 160
161 #if defined(OS_ANDROID) 161 #if defined(OS_ANDROID)
162 return false; 162 return false;
163 #else 163 #else
164 return true; 164 return true;
165 #endif 165 #endif
166 } 166 }
167 167
168 namespace { 168 // impl side painting
danakj 2013/11/11 17:57:53 The variable is called impl_side_painting, so I do
169 bool CheckImplSidePaintingStatus() { 169 static bool implSidePaintingStatus;
danakj 2013/11/11 17:57:53 this is blink style, you want g_impl_side_painting
170 // map-image flag
danakj 2013/11/11 17:57:53 same with this comment
171 static bool mapImageStatus;
172
173 static void InitializeCCSwitchesIfRequired() {
174 static bool has_initialized_ccswitches = false;
175 if (has_initialized_ccswitches)
176 return;
177
170 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 178 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
179 // impl-side painting
danakj 2013/11/11 17:57:53 // Impl-side painting. (capitals and punctuation
180 if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) {
181 implSidePaintingStatus = false;
182 } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) {
183 implSidePaintingStatus = true;
184 } else {
185 #if defined(OS_ANDROID)
186 implSidePaintingStatus = true;
187 #else
188 implSidePaintingStatus = false;
189 #endif
190 }
171 191
172 if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) 192 // map-image flag
danakj 2013/11/11 17:57:53 // Map-image flag.
173 return false; 193 if (command_line.HasSwitch(cc::switches::kDisableMapImage))
174 else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) 194 mapImageStatus = false;
175 return true; 195 else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
196 mapImageStatus = true;
176 197
177 #if defined(OS_ANDROID) 198 has_initialized_ccswitches = true;
178 return true;
179 #else
180 return false;
181 #endif
182 } 199 }
183 } // namespace
184 200
185 bool IsImplSidePaintingEnabled() { 201 bool IsImplSidePaintingEnabled() {
186 static bool enabled = CheckImplSidePaintingStatus(); 202 InitializeCCSwitchesIfRequired();
187 return enabled; 203 return implSidePaintingStatus;
188 } 204 }
189 205
190 bool IsMapImageEnabled() { 206 bool IsMapImageEnabled() {
191 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 207 InitializeCCSwitchesIfRequired();
192 208 return mapImageStatus;
193 if (command_line.HasSwitch(cc::switches::kDisableMapImage))
194 return false;
195 else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
196 return true;
197
198 return false;
199 } 209 }
200 210
201 } // namespace switches 211 } // namespace switches
202 } // namespace cc 212 } // 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