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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 } | 264 } |
| 265 | 265 |
| 266 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { | 266 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { |
| 267 #if defined(OS_CHROMEOS) | 267 #if defined(OS_CHROMEOS) |
| 268 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && | 268 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && |
| 269 base::CommandLine::ForCurrentProcess()->HasSwitch( | 269 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 270 switches::kDisablePanelFitting)) { | 270 switches::kDisablePanelFitting)) { |
| 271 return true; | 271 return true; |
| 272 } | 272 } |
| 273 #endif // OS_CHROMEOS | 273 #endif // OS_CHROMEOS |
| 274 if (use_swiftshader_) { | 274 if (use_swiftshader_ || gpu_info_.use_warp) { |
| 275 // Skia's software rendering is probably more efficient than going through | 275 // Skia's software rendering is probably more efficient than going through |
| 276 // software emulation of the GPU, so use that. | 276 // software emulation of the GPU, so use that. |
| 277 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) | 277 if (feature == gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) |
| 278 return true; | 278 return true; |
| 279 return false; | 279 return false; |
| 280 } | 280 } |
| 281 | 281 |
| 282 return (blacklisted_features_.count(feature) == 1); | 282 return (blacklisted_features_.count(feature) == 1); |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { | 285 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { |
| 286 return (gpu_driver_bugs_.count(feature) == 1); | 286 return (gpu_driver_bugs_.count(feature) == 1); |
| 287 } | 287 } |
| 288 | 288 |
| 289 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { | 289 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { |
| 290 if (use_swiftshader_) | 290 if (use_swiftshader_ || gpu_info_.use_warp) |
| 291 return 1; | 291 return 1; |
| 292 return blacklisted_features_.size(); | 292 return blacklisted_features_.size(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void GpuDataManagerImplPrivate::SetDisplayCount(unsigned int display_count) { | 295 void GpuDataManagerImplPrivate::SetDisplayCount(unsigned int display_count) { |
| 296 display_count_ = display_count; | 296 display_count_ = display_count; |
| 297 } | 297 } |
| 298 | 298 |
| 299 unsigned int GpuDataManagerImplPrivate::GetDisplayCount() const { | 299 unsigned int GpuDataManagerImplPrivate::GetDisplayCount() const { |
| 300 return display_count_; | 300 return display_count_; |
| 301 } | 301 } |
| 302 | 302 |
| 303 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { | 303 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { |
| 304 return gpu_info_; | 304 return gpu_info_; |
| 305 } | 305 } |
| 306 | 306 |
| 307 void GpuDataManagerImplPrivate::GetGpuProcessHandles( | 307 void GpuDataManagerImplPrivate::GetGpuProcessHandles( |
| 308 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { | 308 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { |
| 309 GpuProcessHost::GetProcessHandles(callback); | 309 GpuProcessHost::GetProcessHandles(callback); |
| 310 } | 310 } |
| 311 | 311 |
| 312 bool GpuDataManagerImplPrivate::GpuAccessAllowed( | 312 bool GpuDataManagerImplPrivate::GpuAccessAllowed( |
| 313 std::string* reason) const { | 313 std::string* reason) const { |
| 314 if (use_swiftshader_) | 314 if (use_swiftshader_ || gpu_info_.use_warp) |
| 315 return true; | 315 return true; |
| 316 | 316 |
| 317 if (!gpu_process_accessible_) { | 317 if (!gpu_process_accessible_) { |
| 318 if (reason) { | 318 if (reason) { |
| 319 *reason = "GPU process launch failed."; | 319 *reason = "GPU process launch failed."; |
| 320 } | 320 } |
| 321 return false; | 321 return false; |
| 322 } | 322 } |
| 323 | 323 |
| 324 if (card_blacklisted_) { | 324 if (card_blacklisted_) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 void GpuDataManagerImplPrivate::GetGLStrings(std::string* gl_vendor, | 464 void GpuDataManagerImplPrivate::GetGLStrings(std::string* gl_vendor, |
| 465 std::string* gl_renderer, | 465 std::string* gl_renderer, |
| 466 std::string* gl_version) { | 466 std::string* gl_version) { |
| 467 DCHECK(gl_vendor && gl_renderer && gl_version); | 467 DCHECK(gl_vendor && gl_renderer && gl_version); |
| 468 | 468 |
| 469 *gl_vendor = gpu_info_.gl_vendor; | 469 *gl_vendor = gpu_info_.gl_vendor; |
| 470 *gl_renderer = gpu_info_.gl_renderer; | 470 *gl_renderer = gpu_info_.gl_renderer; |
| 471 *gl_version = gpu_info_.gl_version; | 471 *gl_version = gpu_info_.gl_version; |
| 472 } | 472 } |
| 473 | 473 |
| 474 void GpuDataManagerImplPrivate::SetShouldUseWarp(bool use_warp) { | |
| 475 gpu_info_.use_warp = use_warp; | |
|
Zhenyao Mo
2014/08/20 21:02:09
This is incorrect. gpu_info_ could be updated mul
luken
2014/08/27 20:43:46
Deprecated code.
| |
| 476 // Let the observers know, particularly the GpuPrefManager, so it can update | |
| 477 // its persistent state about using warp or not. | |
| 478 NotifyGpuInfoUpdate(); | |
| 479 } | |
| 480 | |
| 481 bool GpuDataManagerImplPrivate::ShouldUseWarp() const { | |
| 482 return gpu_info_.use_warp || | |
| 483 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseWarp); | |
| 484 } | |
| 485 | |
| 474 void GpuDataManagerImplPrivate::Initialize() { | 486 void GpuDataManagerImplPrivate::Initialize() { |
| 475 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); | 487 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); |
| 476 if (finalized_) { | 488 if (finalized_) { |
| 477 DVLOG(0) << "GpuDataManagerImpl marked as finalized; skipping Initialize"; | 489 DVLOG(0) << "GpuDataManagerImpl marked as finalized; skipping Initialize"; |
| 478 return; | 490 return; |
| 479 } | 491 } |
| 480 | 492 |
| 481 const base::CommandLine* command_line = | 493 const base::CommandLine* command_line = |
| 482 base::CommandLine::ForCurrentProcess(); | 494 base::CommandLine::ForCurrentProcess(); |
| 483 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) | 495 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 } | 550 } |
| 539 gpu::GpuDriverBugList::AppendWorkaroundsFromCommandLine( | 551 gpu::GpuDriverBugList::AppendWorkaroundsFromCommandLine( |
| 540 &gpu_driver_bugs_, *base::CommandLine::ForCurrentProcess()); | 552 &gpu_driver_bugs_, *base::CommandLine::ForCurrentProcess()); |
| 541 | 553 |
| 542 // We have to update GpuFeatureType before notify all the observers. | 554 // We have to update GpuFeatureType before notify all the observers. |
| 543 NotifyGpuInfoUpdate(); | 555 NotifyGpuInfoUpdate(); |
| 544 } | 556 } |
| 545 | 557 |
| 546 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { | 558 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { |
| 547 // No further update of gpu_info if falling back to SwiftShader. | 559 // No further update of gpu_info if falling back to SwiftShader. |
| 548 if (use_swiftshader_) | 560 if (use_swiftshader_ || gpu_info_.use_warp) |
| 549 return; | 561 return; |
| 550 | 562 |
| 551 gpu::MergeGPUInfo(&gpu_info_, gpu_info); | 563 gpu::MergeGPUInfo(&gpu_info_, gpu_info); |
| 552 complete_gpu_info_already_requested_ = | 564 complete_gpu_info_already_requested_ = |
| 553 complete_gpu_info_already_requested_ || gpu_info_.finalized; | 565 complete_gpu_info_already_requested_ || gpu_info_.finalized; |
| 554 | 566 |
| 555 UpdateGpuInfoHelper(); | 567 UpdateGpuInfoHelper(); |
| 556 } | 568 } |
| 557 | 569 |
| 558 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( | 570 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 // device_id, driver_vendor, driver_version for deciding whether we need to | 650 // device_id, driver_vendor, driver_version for deciding whether we need to |
| 639 // collect full info (on Linux) and for crash reporting purpose. | 651 // collect full info (on Linux) and for crash reporting purpose. |
| 640 command_line->AppendSwitchASCII(switches::kGpuVendorID, | 652 command_line->AppendSwitchASCII(switches::kGpuVendorID, |
| 641 base::StringPrintf("0x%04x", gpu_info_.gpu.vendor_id)); | 653 base::StringPrintf("0x%04x", gpu_info_.gpu.vendor_id)); |
| 642 command_line->AppendSwitchASCII(switches::kGpuDeviceID, | 654 command_line->AppendSwitchASCII(switches::kGpuDeviceID, |
| 643 base::StringPrintf("0x%04x", gpu_info_.gpu.device_id)); | 655 base::StringPrintf("0x%04x", gpu_info_.gpu.device_id)); |
| 644 command_line->AppendSwitchASCII(switches::kGpuDriverVendor, | 656 command_line->AppendSwitchASCII(switches::kGpuDriverVendor, |
| 645 gpu_info_.driver_vendor); | 657 gpu_info_.driver_vendor); |
| 646 command_line->AppendSwitchASCII(switches::kGpuDriverVersion, | 658 command_line->AppendSwitchASCII(switches::kGpuDriverVersion, |
| 647 gpu_info_.driver_version); | 659 gpu_info_.driver_version); |
| 660 | |
| 661 if (ShouldUseWarp()) | |
| 662 command_line->AppendSwitch(switches::kUseWarp); | |
| 648 } | 663 } |
| 649 | 664 |
| 650 void GpuDataManagerImplPrivate::AppendPluginCommandLine( | 665 void GpuDataManagerImplPrivate::AppendPluginCommandLine( |
| 651 base::CommandLine* command_line) const { | 666 base::CommandLine* command_line) const { |
| 652 DCHECK(command_line); | 667 DCHECK(command_line); |
| 653 | 668 |
| 654 #if defined(OS_MACOSX) | 669 #if defined(OS_MACOSX) |
| 655 // TODO(jbauman): Add proper blacklist support for core animation plugins so | 670 // TODO(jbauman): Add proper blacklist support for core animation plugins so |
| 656 // special-casing this video card won't be necessary. See | 671 // special-casing this video card won't be necessary. See |
| 657 // http://crbug.com/134015 | 672 // http://crbug.com/134015 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 812 gpu_info_.secondary_gpus[ii].active = false; | 827 gpu_info_.secondary_gpus[ii].active = false; |
| 813 } | 828 } |
| 814 } | 829 } |
| 815 gpu_info_.gpu.active = false; | 830 gpu_info_.gpu.active = false; |
| 816 } | 831 } |
| 817 UpdateGpuInfoHelper(); | 832 UpdateGpuInfoHelper(); |
| 818 return true; | 833 return true; |
| 819 } | 834 } |
| 820 | 835 |
| 821 bool GpuDataManagerImplPrivate::CanUseGpuBrowserCompositor() const { | 836 bool GpuDataManagerImplPrivate::CanUseGpuBrowserCompositor() const { |
| 837 if (gpu_info_.use_warp) | |
|
Zhenyao Mo
2014/08/20 21:02:09
You should use ShouldUseWarp() here to be consiste
luken
2014/08/27 20:43:46
Done.
| |
| 838 return true; | |
| 822 if (ShouldUseSwiftShader()) | 839 if (ShouldUseSwiftShader()) |
| 823 return false; | 840 return false; |
| 824 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) | 841 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)) |
| 825 return false; | 842 return false; |
| 826 return true; | 843 return true; |
| 827 } | 844 } |
| 828 | 845 |
| 829 void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs( | 846 void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs( |
| 830 const GURL& url, GpuDataManagerImpl::DomainGuilt guilt) { | 847 const GURL& url, GpuDataManagerImpl::DomainGuilt guilt) { |
| 831 BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now()); | 848 BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now()); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1079 | 1096 |
| 1080 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { | 1097 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { |
| 1081 gpu_process_accessible_ = false; | 1098 gpu_process_accessible_ = false; |
| 1082 gpu_info_.finalized = true; | 1099 gpu_info_.finalized = true; |
| 1083 complete_gpu_info_already_requested_ = true; | 1100 complete_gpu_info_already_requested_ = true; |
| 1084 // Some observers might be waiting. | 1101 // Some observers might be waiting. |
| 1085 NotifyGpuInfoUpdate(); | 1102 NotifyGpuInfoUpdate(); |
| 1086 } | 1103 } |
| 1087 | 1104 |
| 1088 } // namespace content | 1105 } // namespace content |
| OLD | NEW |