Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/gpu_data_manager_impl_private.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 #include "gpu/config/gpu_control_list_jsons.h" | 36 #include "gpu/config/gpu_control_list_jsons.h" |
| 37 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 37 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 38 #include "gpu/config/gpu_feature_type.h" | 38 #include "gpu/config/gpu_feature_type.h" |
| 39 #include "gpu/config/gpu_info_collector.h" | 39 #include "gpu/config/gpu_info_collector.h" |
| 40 #include "gpu/config/gpu_switches.h" | 40 #include "gpu/config/gpu_switches.h" |
| 41 #include "gpu/config/gpu_util.h" | 41 #include "gpu/config/gpu_util.h" |
| 42 #include "gpu/ipc/common/memory_stats.h" | 42 #include "gpu/ipc/common/memory_stats.h" |
| 43 #include "gpu/ipc/service/switches.h" | 43 #include "gpu/ipc/service/switches.h" |
| 44 #include "media/media_features.h" | 44 #include "media/media_features.h" |
| 45 #include "ui/base/ui_base_switches.h" | 45 #include "ui/base/ui_base_switches.h" |
| 46 #include "ui/gl/gl_features.h" | |
| 46 #include "ui/gl/gl_implementation.h" | 47 #include "ui/gl/gl_implementation.h" |
| 47 #include "ui/gl/gl_switches.h" | 48 #include "ui/gl/gl_switches.h" |
| 48 #include "ui/gl/gpu_switching_manager.h" | 49 #include "ui/gl/gpu_switching_manager.h" |
| 49 | 50 |
| 50 #if defined(USE_OZONE) | 51 #if defined(USE_OZONE) |
| 51 #include "ui/ozone/public/ozone_switches.h" | 52 #include "ui/ozone/public/ozone_switches.h" |
| 52 #endif | 53 #endif |
| 53 #if defined(OS_MACOSX) | 54 #if defined(OS_MACOSX) |
| 54 #include <ApplicationServices/ApplicationServices.h> | 55 #include <ApplicationServices/ApplicationServices.h> |
| 55 #endif // OS_MACOSX | 56 #endif // OS_MACOSX |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 #if defined(OS_CHROMEOS) | 289 #if defined(OS_CHROMEOS) |
| 289 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && | 290 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && |
| 290 base::CommandLine::ForCurrentProcess()->HasSwitch( | 291 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 291 switches::kDisablePanelFitting)) { | 292 switches::kDisablePanelFitting)) { |
| 292 return true; | 293 return true; |
| 293 } | 294 } |
| 294 #endif // OS_CHROMEOS | 295 #endif // OS_CHROMEOS |
| 295 if (use_swiftshader_) { | 296 if (use_swiftshader_) { |
| 296 // Skia's software rendering is probably more efficient than going through | 297 // Skia's software rendering is probably more efficient than going through |
| 297 // software emulation of the GPU, so use that. | 298 // software emulation of the GPU, so use that. |
| 298 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) | 299 return (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS || |
| 299 return true; | 300 feature == gpu::GPU_FEATURE_TYPE_WEBGL2); |
| 300 return false; | |
| 301 } | 301 } |
| 302 | 302 |
| 303 return (blacklisted_features_.count(feature) == 1); | 303 return (blacklisted_features_.count(feature) == 1); |
| 304 } | 304 } |
| 305 | 305 |
| 306 bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const { | 306 bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const { |
| 307 DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); | 307 DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); |
| 308 return gpu_feature_info_ | 308 return gpu_feature_info_ |
| 309 .status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] == | 309 .status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] == |
| 310 gpu::kGpuFeatureStatusEnabled; | 310 gpu::kGpuFeatureStatusEnabled; |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { | 313 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { |
| 314 return (gpu_driver_bugs_.count(feature) == 1); | 314 return (gpu_driver_bugs_.count(feature) == 1); |
| 315 } | 315 } |
| 316 | 316 |
| 317 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { | 317 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { |
| 318 if (use_swiftshader_) | 318 if (use_swiftshader_) |
| 319 return 1; | 319 return 2; // GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS and |
| 320 // GPU_FEATURE_TYPE_WEBGL2 | |
| 320 return blacklisted_features_.size(); | 321 return blacklisted_features_.size(); |
| 321 } | 322 } |
| 322 | 323 |
| 323 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { | 324 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { |
| 324 return gpu_info_; | 325 return gpu_info_; |
| 325 } | 326 } |
| 326 | 327 |
| 327 void GpuDataManagerImplPrivate::GetGpuProcessHandles( | 328 void GpuDataManagerImplPrivate::GetGpuProcessHandles( |
| 328 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { | 329 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { |
| 329 GpuProcessHost::GetProcessHandles(callback); | 330 GpuProcessHost::GetProcessHandles(callback); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { | 434 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { |
| 434 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 435 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 435 false /* force_create */, | 436 false /* force_create */, |
| 436 new GpuMsg_GetVideoMemoryUsageStats()); | 437 new GpuMsg_GetVideoMemoryUsageStats()); |
| 437 } | 438 } |
| 438 | 439 |
| 439 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { | 440 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { |
| 440 return use_swiftshader_; | 441 return use_swiftshader_; |
| 441 } | 442 } |
| 442 | 443 |
| 443 void GpuDataManagerImplPrivate::RegisterSwiftShaderPath( | |
| 444 const base::FilePath& path) { | |
| 445 swiftshader_path_ = path; | |
| 446 EnableSwiftShaderIfNecessary(); | |
| 447 } | |
| 448 | |
| 449 void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) { | 444 void GpuDataManagerImplPrivate::AddObserver(GpuDataManagerObserver* observer) { |
| 450 GpuDataManagerImpl::UnlockedSession session(owner_); | 445 GpuDataManagerImpl::UnlockedSession session(owner_); |
| 451 observer_list_->AddObserver(observer); | 446 observer_list_->AddObserver(observer); |
| 452 } | 447 } |
| 453 | 448 |
| 454 void GpuDataManagerImplPrivate::RemoveObserver( | 449 void GpuDataManagerImplPrivate::RemoveObserver( |
| 455 GpuDataManagerObserver* observer) { | 450 GpuDataManagerObserver* observer) { |
| 456 GpuDataManagerImpl::UnlockedSession session(owner_); | 451 GpuDataManagerImpl::UnlockedSession session(owner_); |
| 457 observer_list_->RemoveObserver(observer); | 452 observer_list_->RemoveObserver(observer); |
| 458 } | 453 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 switches::kUseGL, | 742 switches::kUseGL, |
| 748 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation())); | 743 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation())); |
| 749 } else if (!use_gl.empty()) { | 744 } else if (!use_gl.empty()) { |
| 750 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); | 745 command_line->AppendSwitchASCII(switches::kUseGL, use_gl); |
| 751 } | 746 } |
| 752 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) | 747 if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) |
| 753 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true"); | 748 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "true"); |
| 754 else | 749 else |
| 755 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); | 750 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); |
| 756 | 751 |
| 757 if (!swiftshader_path_.empty()) { | |
| 758 command_line->AppendSwitchPath(switches::kSwiftShaderPath, | |
| 759 swiftshader_path_); | |
| 760 } | |
| 761 | |
| 762 if (!gpu_driver_bugs_.empty()) { | 752 if (!gpu_driver_bugs_.empty()) { |
| 763 command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, | 753 command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, |
| 764 IntSetToString(gpu_driver_bugs_)); | 754 IntSetToString(gpu_driver_bugs_)); |
| 765 } | 755 } |
| 766 | 756 |
| 767 if (!disabled_extensions_.empty()) { | 757 if (!disabled_extensions_.empty()) { |
| 768 command_line->AppendSwitchASCII(switches::kDisableGLExtensions, | 758 command_line->AppendSwitchASCII(switches::kDisableGLExtensions, |
| 769 disabled_extensions_); | 759 disabled_extensions_); |
| 770 } | 760 } |
| 771 | 761 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1132 update_histograms_(true), | 1122 update_histograms_(true), |
| 1133 domain_blocking_enabled_(true), | 1123 domain_blocking_enabled_(true), |
| 1134 owner_(owner), | 1124 owner_(owner), |
| 1135 gpu_process_accessible_(true), | 1125 gpu_process_accessible_(true), |
| 1136 is_initialized_(false), | 1126 is_initialized_(false), |
| 1137 finalized_(false), | 1127 finalized_(false), |
| 1138 in_process_gpu_(false) { | 1128 in_process_gpu_(false) { |
| 1139 DCHECK(owner_); | 1129 DCHECK(owner_); |
| 1140 const base::CommandLine* command_line = | 1130 const base::CommandLine* command_line = |
| 1141 base::CommandLine::ForCurrentProcess(); | 1131 base::CommandLine::ForCurrentProcess(); |
| 1142 swiftshader_path_ = command_line->GetSwitchValuePath( | |
| 1143 switches::kSwiftShaderPath); | |
| 1144 if (ShouldDisableHardwareAcceleration()) | 1132 if (ShouldDisableHardwareAcceleration()) |
| 1145 DisableHardwareAcceleration(); | 1133 DisableHardwareAcceleration(); |
| 1146 | 1134 |
| 1147 if (command_line->HasSwitch(switches::kSingleProcess) || | 1135 if (command_line->HasSwitch(switches::kSingleProcess) || |
| 1148 command_line->HasSwitch(switches::kInProcessGPU)) { | 1136 command_line->HasSwitch(switches::kInProcessGPU)) { |
| 1149 in_process_gpu_ = true; | 1137 in_process_gpu_ = true; |
| 1150 } | 1138 } |
| 1151 | 1139 |
| 1152 #if defined(OS_MACOSX) | 1140 #if defined(OS_MACOSX) |
| 1153 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); | 1141 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1236 } | 1224 } |
| 1237 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids); | 1225 ui::GpuSwitchingManager::GetInstance()->SetGpuVendorIds(vendor_ids); |
| 1238 gpu::InitializeDualGpusIfSupported(gpu_driver_bugs_); | 1226 gpu::InitializeDualGpusIfSupported(gpu_driver_bugs_); |
| 1239 } | 1227 } |
| 1240 | 1228 |
| 1241 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { | 1229 void GpuDataManagerImplPrivate::NotifyGpuInfoUpdate() { |
| 1242 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::OnGpuInfoUpdate); | 1230 observer_list_->Notify(FROM_HERE, &GpuDataManagerObserver::OnGpuInfoUpdate); |
| 1243 } | 1231 } |
| 1244 | 1232 |
| 1245 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { | 1233 void GpuDataManagerImplPrivate::EnableSwiftShaderIfNecessary() { |
| 1246 if (!GpuAccessAllowed(NULL) || | 1234 #if BUILDFLAG(ENABLE_SWIFTSHADER) |
| 1235 if (!GpuAccessAllowed(nullptr) || | |
|
sugoi1
2017/03/01 16:50:22
This call to GpuAccessAllowed() causes SwiftShader
| |
| 1247 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) { | 1236 blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_WEBGL)) { |
| 1248 if (!swiftshader_path_.empty() && | 1237 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1249 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1238 switches::kDisableSoftwareRasterizer)) |
| 1250 switches::kDisableSoftwareRasterizer)) | |
| 1251 use_swiftshader_ = true; | 1239 use_swiftshader_ = true; |
| 1252 } | 1240 } |
| 1241 #endif | |
| 1253 } | 1242 } |
| 1254 | 1243 |
| 1255 std::string GpuDataManagerImplPrivate::GetDomainFromURL( | 1244 std::string GpuDataManagerImplPrivate::GetDomainFromURL( |
| 1256 const GURL& url) const { | 1245 const GURL& url) const { |
| 1257 // For the moment, we just use the host, or its IP address, as the | 1246 // For the moment, we just use the host, or its IP address, as the |
| 1258 // entry in the set, rather than trying to figure out the top-level | 1247 // entry in the set, rather than trying to figure out the top-level |
| 1259 // domain. This does mean that a.foo.com and b.foo.com will be | 1248 // domain. This does mean that a.foo.com and b.foo.com will be |
| 1260 // treated independently in the blocking of a given domain, but it | 1249 // treated independently in the blocking of a given domain, but it |
| 1261 // would require a third-party library to reliably figure out the | 1250 // would require a third-party library to reliably figure out the |
| 1262 // top-level domain from a URL. | 1251 // top-level domain from a URL. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1358 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1347 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
| 1359 #if defined(OS_WIN) | 1348 #if defined(OS_WIN) |
| 1360 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1349 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
| 1361 #endif | 1350 #endif |
| 1362 complete_gpu_info_already_requested_ = true; | 1351 complete_gpu_info_already_requested_ = true; |
| 1363 // Some observers might be waiting. | 1352 // Some observers might be waiting. |
| 1364 NotifyGpuInfoUpdate(); | 1353 NotifyGpuInfoUpdate(); |
| 1365 } | 1354 } |
| 1366 | 1355 |
| 1367 } // namespace content | 1356 } // namespace content |
| OLD | NEW |