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

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

Issue 73923003: Shared Raster Worker Threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WIP - realigning code to get number of raster threads + nits Created 6 years, 12 months 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
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 #include "base/strings/string_number_conversions.h"
8 9
9 namespace cc { 10 namespace cc {
10 namespace switches { 11 namespace switches {
11 12
12 // On platforms where checkerboards are used, prefer background colors instead 13 // On platforms where checkerboards are used, prefer background colors instead
13 // of checkerboards. 14 // of checkerboards.
14 const char kBackgroundColorInsteadOfCheckerboard[] = 15 const char kBackgroundColorInsteadOfCheckerboard[] =
15 "background-color-instead-of-checkerboard"; 16 "background-color-instead-of-checkerboard";
16 17
17 // Disables LCD text. 18 // Disables LCD text.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 #else 180 #else
180 return false; 181 return false;
181 #endif 182 #endif
182 } 183 }
183 184
184 bool CheckGPURasterizationStatus() { 185 bool CheckGPURasterizationStatus() {
185 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 186 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
186 return command_line.HasSwitch(switches::kEnableGPURasterization); 187 return command_line.HasSwitch(switches::kEnableGPURasterization);
187 } 188 }
188 189
190 size_t CheckNumRasterThreads() {
191 const int kMinRasterThreads = 1;
192 const int kMaxRasterThreads = 64;
193 const int kDefaultNumRasterThreads = 1;
194
195 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
196 int num_threads = kDefaultNumRasterThreads;
reveman 2013/12/28 14:45:48 Please move this just above the "base::StringToInt
sohanjg 2013/12/30 06:49:36 Done.
197 if (command_line.HasSwitch(switches::kNumRasterThreads)) {
198 std::string string_value =
199 command_line.GetSwitchValueASCII(switches::kNumRasterThreads);
200 if ((base::StringToInt(string_value, &num_threads) &&
201 num_threads >= kMinRasterThreads && num_threads <= kMaxRasterThreads))
202 return num_threads;
reveman 2013/12/28 14:45:48 nit: this line should be indented 2 spaces, not 4
sohanjg 2013/12/30 06:49:36 Done.
203 LOG(WARNING) << "Failed to parse switch " <<
reveman 2013/12/28 14:45:48 nit: maybe add a blank line between this and the a
sohanjg 2013/12/30 06:49:36 Done.
204 switches::kNumRasterThreads << ": " << string_value;
205 }
206 return num_threads;
reveman 2013/12/28 14:45:48 nit: return kDefaultNumRasterThreads here instead
sohanjg 2013/12/30 06:49:36 Done.
207 }
208
189 } // namespace 209 } // namespace
190 210
191 bool IsImplSidePaintingEnabled() { 211 bool IsImplSidePaintingEnabled() {
192 static bool enabled = CheckImplSidePaintingStatus(); 212 static bool enabled = CheckImplSidePaintingStatus();
193 return enabled; 213 return enabled;
194 } 214 }
195 215
196 bool IsGPURasterizationEnabled() { 216 bool IsGPURasterizationEnabled() {
197 static bool enabled = CheckGPURasterizationStatus(); 217 static bool enabled = CheckGPURasterizationStatus();
198 return enabled; 218 return enabled;
199 } 219 }
200 220
201 bool IsMapImageEnabled() { 221 bool IsMapImageEnabled() {
202 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 222 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
203 223
204 if (command_line.HasSwitch(switches::kDisableMapImage)) 224 if (command_line.HasSwitch(switches::kDisableMapImage))
205 return false; 225 return false;
206 else if (command_line.HasSwitch(switches::kEnableMapImage)) 226 else if (command_line.HasSwitch(switches::kEnableMapImage))
207 return true; 227 return true;
208 228
209 return false; 229 return false;
210 } 230 }
211 231
232 size_t GetNumRasterThreads() {
233 static size_t num_raster_threads = CheckNumRasterThreads();
reveman 2013/12/28 14:45:48 FYI, you'll have to update this if https://coderev
sohanjg 2013/12/30 06:49:36 OK.will take care of it, if that happens.
234 return num_raster_threads;
235 }
236
212 } // namespace switches 237 } // namespace switches
213 } // namespace cc 238 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698