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 "content/browser/gpu/compositor_util.h" | 5 #include "content/browser/gpu/compositor_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 static bool IsGpuRasterizationBlacklisted() { | 23 static bool IsGpuRasterizationBlacklisted() { |
24 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); | 24 GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance(); |
25 return manager->IsFeatureBlacklisted( | 25 return manager->IsFeatureBlacklisted( |
26 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); | 26 gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); |
27 } | 27 } |
28 | 28 |
29 const char* kGpuCompositingFeatureName = "gpu_compositing"; | 29 const char* kGpuCompositingFeatureName = "gpu_compositing"; |
30 const char* kWebGLFeatureName = "webgl"; | 30 const char* kWebGLFeatureName = "webgl"; |
31 const char* kRasterizationFeatureName = "rasterization"; | 31 const char* kRasterizationFeatureName = "rasterization"; |
32 const char* kThreadedRasterizationFeatureName = "threaded_rasterization"; | |
33 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; | 32 const char* kMultipleRasterThreadsFeatureName = "multiple_raster_threads"; |
34 | 33 |
35 const int kMinRasterThreads = 1; | 34 const int kMinRasterThreads = 1; |
36 const int kMaxRasterThreads = 16; | 35 const int kMaxRasterThreads = 16; |
37 | 36 |
38 const int kMinMSAASampleCount = 0; | 37 const int kMinMSAASampleCount = 0; |
39 | 38 |
40 struct GpuFeatureInfo { | 39 struct GpuFeatureInfo { |
41 std::string name; | 40 std::string name; |
42 bool blocked; | 41 bool blocked; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 kRasterizationFeatureName, | 137 kRasterizationFeatureName, |
139 IsGpuRasterizationBlacklisted() && | 138 IsGpuRasterizationBlacklisted() && |
140 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled(), | 139 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled(), |
141 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled() && | 140 !IsGpuRasterizationEnabled() && !IsForceGpuRasterizationEnabled() && |
142 !IsGpuRasterizationBlacklisted(), | 141 !IsGpuRasterizationBlacklisted(), |
143 "Accelerated rasterization has been disabled, either via about:flags" | 142 "Accelerated rasterization has been disabled, either via about:flags" |
144 " or command line.", | 143 " or command line.", |
145 true | 144 true |
146 }, | 145 }, |
147 { | 146 { |
148 kThreadedRasterizationFeatureName, | |
149 false, | |
150 !IsImplSidePaintingEnabled(), | |
151 "Threaded rasterization has not been enabled or" | |
152 " is not supported by the current system.", | |
153 false | |
154 }, | |
155 { | |
156 kMultipleRasterThreadsFeatureName, | 147 kMultipleRasterThreadsFeatureName, |
157 false, | 148 false, |
158 NumberOfRendererRasterThreads() == 1, | 149 NumberOfRendererRasterThreads() == 1, |
159 "Raster is using a single thread.", | 150 "Raster is using a single thread.", |
160 false | 151 false |
161 }, | 152 }, |
162 }; | 153 }; |
163 DCHECK(index < arraysize(kGpuFeatureInfo)); | 154 DCHECK(index < arraysize(kGpuFeatureInfo)); |
164 *eof = (index == arraysize(kGpuFeatureInfo) - 1); | 155 *eof = (index == arraysize(kGpuFeatureInfo) - 1); |
165 return kGpuFeatureInfo[index]; | 156 return kGpuFeatureInfo[index]; |
(...skipping 16 matching lines...) Expand all Loading... |
182 // Enable on Aura and Mac. | 173 // Enable on Aura and Mac. |
183 enabled = true; | 174 enabled = true; |
184 #endif | 175 #endif |
185 | 176 |
186 // Flags override. | 177 // Flags override. |
187 enabled |= command_line.HasSwitch(switches::kEnableDelegatedRenderer); | 178 enabled |= command_line.HasSwitch(switches::kEnableDelegatedRenderer); |
188 enabled &= !command_line.HasSwitch(switches::kDisableDelegatedRenderer); | 179 enabled &= !command_line.HasSwitch(switches::kDisableDelegatedRenderer); |
189 return enabled; | 180 return enabled; |
190 } | 181 } |
191 | 182 |
192 bool IsImplSidePaintingEnabled() { | |
193 const base::CommandLine& command_line = | |
194 *base::CommandLine::ForCurrentProcess(); | |
195 if (command_line.HasSwitch(switches::kDisableImplSidePainting)) | |
196 return false; | |
197 return true; | |
198 } | |
199 | |
200 int NumberOfRendererRasterThreads() { | 183 int NumberOfRendererRasterThreads() { |
201 int num_processors = base::SysInfo::NumberOfProcessors(); | 184 int num_processors = base::SysInfo::NumberOfProcessors(); |
202 | 185 |
203 #if defined(OS_ANDROID) | 186 #if defined(OS_ANDROID) |
204 // Android may report 6 to 8 CPUs for big.LITTLE configurations. | 187 // Android may report 6 to 8 CPUs for big.LITTLE configurations. |
205 // Limit the number of raster threads based on maximum of 4 big cores. | 188 // Limit the number of raster threads based on maximum of 4 big cores. |
206 num_processors = std::min(num_processors, 4); | 189 num_processors = std::min(num_processors, 4); |
207 #endif | 190 #endif |
208 | 191 |
209 int num_raster_threads = num_processors / 2; | 192 int num_raster_threads = num_processors / 2; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // TODO(reveman): One-copy can work with sync compositing: crbug.com/490295. | 243 // TODO(reveman): One-copy can work with sync compositing: crbug.com/490295. |
261 if (command_line.HasSwitch(switches::kDisableThreadedCompositing)) | 244 if (command_line.HasSwitch(switches::kDisableThreadedCompositing)) |
262 return true; | 245 return true; |
263 return command_line.HasSwitch(switches::kEnableZeroCopy); | 246 return command_line.HasSwitch(switches::kEnableZeroCopy); |
264 } | 247 } |
265 | 248 |
266 bool IsGpuRasterizationEnabled() { | 249 bool IsGpuRasterizationEnabled() { |
267 const base::CommandLine& command_line = | 250 const base::CommandLine& command_line = |
268 *base::CommandLine::ForCurrentProcess(); | 251 *base::CommandLine::ForCurrentProcess(); |
269 | 252 |
270 if (!IsImplSidePaintingEnabled()) | |
271 return false; | |
272 | |
273 if (command_line.HasSwitch(switches::kDisableGpuRasterization)) | 253 if (command_line.HasSwitch(switches::kDisableGpuRasterization)) |
274 return false; | 254 return false; |
275 else if (command_line.HasSwitch(switches::kEnableGpuRasterization)) | 255 else if (command_line.HasSwitch(switches::kEnableGpuRasterization)) |
276 return true; | 256 return true; |
277 | 257 |
278 if (IsGpuRasterizationBlacklisted()) { | 258 if (IsGpuRasterizationBlacklisted()) { |
279 return false; | 259 return false; |
280 } | 260 } |
281 | 261 |
282 #if defined(OS_ANDROID) | 262 #if defined(OS_ANDROID) |
283 return true; | 263 return true; |
284 #endif | 264 #endif |
285 | 265 |
286 // explicitly disable GPU rasterization on all non-android devices until we | 266 // explicitly disable GPU rasterization on all non-android devices until we |
287 // have full test coverage. | 267 // have full test coverage. |
288 return false; | 268 return false; |
289 } | 269 } |
290 | 270 |
291 bool IsForceGpuRasterizationEnabled() { | 271 bool IsForceGpuRasterizationEnabled() { |
292 const base::CommandLine& command_line = | 272 const base::CommandLine& command_line = |
293 *base::CommandLine::ForCurrentProcess(); | 273 *base::CommandLine::ForCurrentProcess(); |
294 | |
295 if (!IsImplSidePaintingEnabled()) | |
296 return false; | |
297 | |
298 return command_line.HasSwitch(switches::kForceGpuRasterization); | 274 return command_line.HasSwitch(switches::kForceGpuRasterization); |
299 } | 275 } |
300 | 276 |
301 bool UseSurfacesEnabled() { | 277 bool UseSurfacesEnabled() { |
302 #if defined(OS_ANDROID) | 278 #if defined(OS_ANDROID) |
303 return false; | 279 return false; |
304 #endif | 280 #endif |
305 bool enabled = false; | 281 bool enabled = false; |
306 #if defined(USE_AURA) || defined(OS_MACOSX) | 282 #if defined(USE_AURA) || defined(OS_MACOSX) |
307 enabled = true; | 283 enabled = true; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 bool eof = false; | 327 bool eof = false; |
352 for (size_t i = 0; !eof; ++i) { | 328 for (size_t i = 0; !eof; ++i) { |
353 const GpuFeatureInfo gpu_feature_info = GetGpuFeatureInfo(i, &eof); | 329 const GpuFeatureInfo gpu_feature_info = GetGpuFeatureInfo(i, &eof); |
354 std::string status; | 330 std::string status; |
355 if (gpu_feature_info.disabled) { | 331 if (gpu_feature_info.disabled) { |
356 status = "disabled"; | 332 status = "disabled"; |
357 if (gpu_feature_info.fallback_to_software) | 333 if (gpu_feature_info.fallback_to_software) |
358 status += "_software"; | 334 status += "_software"; |
359 else | 335 else |
360 status += "_off"; | 336 status += "_off"; |
361 if (gpu_feature_info.name == kThreadedRasterizationFeatureName) | |
362 status += "_ok"; | |
363 } else if (gpu_feature_info.blocked || | 337 } else if (gpu_feature_info.blocked || |
364 gpu_access_blocked) { | 338 gpu_access_blocked) { |
365 status = "unavailable"; | 339 status = "unavailable"; |
366 if (gpu_feature_info.fallback_to_software) | 340 if (gpu_feature_info.fallback_to_software) |
367 status += "_software"; | 341 status += "_software"; |
368 else | 342 else |
369 status += "_off"; | 343 status += "_off"; |
370 } else { | 344 } else { |
371 status = "enabled"; | 345 status = "enabled"; |
372 if (gpu_feature_info.name == kWebGLFeatureName && | 346 if (gpu_feature_info.name == kWebGLFeatureName && |
373 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) | 347 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) |
374 status += "_readback"; | 348 status += "_readback"; |
375 if (gpu_feature_info.name == kRasterizationFeatureName) { | 349 if (gpu_feature_info.name == kRasterizationFeatureName) { |
376 if (IsForceGpuRasterizationEnabled()) | 350 if (IsForceGpuRasterizationEnabled()) |
377 status += "_force"; | 351 status += "_force"; |
378 } | 352 } |
379 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { | 353 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) { |
380 const base::CommandLine& command_line = | 354 const base::CommandLine& command_line = |
381 *base::CommandLine::ForCurrentProcess(); | 355 *base::CommandLine::ForCurrentProcess(); |
382 if (command_line.HasSwitch(switches::kNumRasterThreads)) | 356 if (command_line.HasSwitch(switches::kNumRasterThreads)) |
383 status += "_force"; | 357 status += "_force"; |
384 } | 358 } |
385 if (gpu_feature_info.name == kThreadedRasterizationFeatureName || | 359 if (gpu_feature_info.name == kMultipleRasterThreadsFeatureName) |
386 gpu_feature_info.name == kMultipleRasterThreadsFeatureName) | |
387 status += "_on"; | 360 status += "_on"; |
388 } | 361 } |
389 if (gpu_feature_info.name == kWebGLFeatureName && | 362 if (gpu_feature_info.name == kWebGLFeatureName && |
390 (gpu_feature_info.blocked || gpu_access_blocked) && | 363 (gpu_feature_info.blocked || gpu_access_blocked) && |
391 manager->ShouldUseSwiftShader()) { | 364 manager->ShouldUseSwiftShader()) { |
392 status = "unavailable_software"; | 365 status = "unavailable_software"; |
393 } | 366 } |
394 | 367 |
395 feature_status_dict->SetString( | 368 feature_status_dict->SetString( |
396 gpu_feature_info.name.c_str(), status.c_str()); | 369 gpu_feature_info.name.c_str(), status.c_str()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } | 410 } |
438 } | 411 } |
439 return problem_list; | 412 return problem_list; |
440 } | 413 } |
441 | 414 |
442 std::vector<std::string> GetDriverBugWorkarounds() { | 415 std::vector<std::string> GetDriverBugWorkarounds() { |
443 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); | 416 return GpuDataManagerImpl::GetInstance()->GetDriverBugWorkarounds(); |
444 } | 417 } |
445 | 418 |
446 } // namespace content | 419 } // namespace content |
OLD | NEW |