| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 switches::kGpuSwitching); | 312 switches::kGpuSwitching); |
| 313 if (option == switches::kGpuSwitchingOptionNameForceDiscrete) { | 313 if (option == switches::kGpuSwitchingOptionNameForceDiscrete) { |
| 314 workarounds->erase(gpu::FORCE_INTEGRATED_GPU); | 314 workarounds->erase(gpu::FORCE_INTEGRATED_GPU); |
| 315 workarounds->insert(gpu::FORCE_DISCRETE_GPU); | 315 workarounds->insert(gpu::FORCE_DISCRETE_GPU); |
| 316 } else if (option == switches::kGpuSwitchingOptionNameForceIntegrated) { | 316 } else if (option == switches::kGpuSwitchingOptionNameForceIntegrated) { |
| 317 workarounds->erase(gpu::FORCE_DISCRETE_GPU); | 317 workarounds->erase(gpu::FORCE_DISCRETE_GPU); |
| 318 workarounds->insert(gpu::FORCE_INTEGRATED_GPU); | 318 workarounds->insert(gpu::FORCE_INTEGRATED_GPU); |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 | 321 |
| 322 bool IsAcceleratedVideoDecodeEnabled( |
| 323 const GpuDataManagerImplPrivate* gpu_manager) { |
| 324 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 325 if (gpu_manager->IsFeatureBlacklisted( |
| 326 gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && |
| 327 !command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode)) |
| 328 return false; |
| 329 |
| 330 #if defined(OS_CHROMEOS) || defined(OS_WIN) || defined(OS_ANDROID) |
| 331 return true; |
| 332 #endif |
| 333 #if defined(OS_LINUX) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
| 334 return true; |
| 335 #endif |
| 336 |
| 337 return false; |
| 338 } |
| 339 |
| 322 // Block all domains' use of 3D APIs for this many milliseconds if | 340 // Block all domains' use of 3D APIs for this many milliseconds if |
| 323 // approaching a threshold where system stability might be compromised. | 341 // approaching a threshold where system stability might be compromised. |
| 324 const int64 kBlockAllDomainsMs = 10000; | 342 const int64 kBlockAllDomainsMs = 10000; |
| 325 const int kNumResetsWithinDuration = 1; | 343 const int kNumResetsWithinDuration = 1; |
| 326 | 344 |
| 327 // Enums for UMA histograms. | 345 // Enums for UMA histograms. |
| 328 enum BlockStatusHistogram { | 346 enum BlockStatusHistogram { |
| 329 BLOCK_STATUS_NOT_BLOCKED, | 347 BLOCK_STATUS_NOT_BLOCKED, |
| 330 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, | 348 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, |
| 331 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, | 349 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 video_memory_usage_stats); | 657 video_memory_usage_stats); |
| 640 } | 658 } |
| 641 | 659 |
| 642 void GpuDataManagerImplPrivate::AppendRendererCommandLine( | 660 void GpuDataManagerImplPrivate::AppendRendererCommandLine( |
| 643 CommandLine* command_line) const { | 661 CommandLine* command_line) const { |
| 644 DCHECK(command_line); | 662 DCHECK(command_line); |
| 645 | 663 |
| 646 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) && | 664 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) && |
| 647 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) | 665 !command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) |
| 648 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); | 666 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); |
| 649 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && | 667 if (!IsAcceleratedVideoDecodeEnabled(this)) |
| 650 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) | |
| 651 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); | 668 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); |
| 652 #if defined(ENABLE_WEBRTC) | 669 #if defined(ENABLE_WEBRTC) |
| 653 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) && | 670 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) && |
| 654 !command_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) | 671 !command_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) |
| 655 command_line->AppendSwitch(switches::kDisableWebRtcHWEncoding); | 672 command_line->AppendSwitch(switches::kDisableWebRtcHWEncoding); |
| 656 #endif | 673 #endif |
| 657 | 674 |
| 658 if (use_software_compositor_ && | 675 if (use_software_compositor_ && |
| 659 !command_line->HasSwitch(switches::kEnableSoftwareCompositing)) | 676 !command_line->HasSwitch(switches::kEnableSoftwareCompositing)) |
| 660 command_line->AppendSwitch(switches::kEnableSoftwareCompositing); | 677 command_line->AppendSwitch(switches::kEnableSoftwareCompositing); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 if (!swiftshader_path.empty()) { | 716 if (!swiftshader_path.empty()) { |
| 700 command_line->AppendSwitchPath(switches::kSwiftShaderPath, | 717 command_line->AppendSwitchPath(switches::kSwiftShaderPath, |
| 701 swiftshader_path); | 718 swiftshader_path); |
| 702 } | 719 } |
| 703 | 720 |
| 704 if (!gpu_driver_bugs_.empty()) { | 721 if (!gpu_driver_bugs_.empty()) { |
| 705 command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, | 722 command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds, |
| 706 IntSetToString(gpu_driver_bugs_)); | 723 IntSetToString(gpu_driver_bugs_)); |
| 707 } | 724 } |
| 708 | 725 |
| 709 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) && | 726 if (!IsAcceleratedVideoDecodeEnabled(this)) |
| 710 !command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { | |
| 711 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); | 727 command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); |
| 712 } | |
| 713 #if defined(ENABLE_WEBRTC) | 728 #if defined(ENABLE_WEBRTC) |
| 714 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) && | 729 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) && |
| 715 !command_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) { | 730 !command_line->HasSwitch(switches::kDisableWebRtcHWEncoding)) { |
| 716 command_line->AppendSwitch(switches::kDisableWebRtcHWEncoding); | 731 command_line->AppendSwitch(switches::kDisableWebRtcHWEncoding); |
| 717 } | 732 } |
| 718 #endif | 733 #endif |
| 719 | 734 |
| 720 // Pass GPU and driver information to GPU process. We try to avoid full GPU | 735 // Pass GPU and driver information to GPU process. We try to avoid full GPU |
| 721 // info collection at GPU process startup, but we need gpu vendor_id, | 736 // info collection at GPU process startup, but we need gpu vendor_id, |
| 722 // device_id, driver_vendor, driver_version for deciding whether we need to | 737 // device_id, driver_vendor, driver_version for deciding whether we need to |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 | 1189 |
| 1175 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { | 1190 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { |
| 1176 gpu_process_accessible_ = false; | 1191 gpu_process_accessible_ = false; |
| 1177 gpu_info_.finalized = true; | 1192 gpu_info_.finalized = true; |
| 1178 complete_gpu_info_already_requested_ = true; | 1193 complete_gpu_info_already_requested_ = true; |
| 1179 // Some observers might be waiting. | 1194 // Some observers might be waiting. |
| 1180 NotifyGpuInfoUpdate(); | 1195 NotifyGpuInfoUpdate(); |
| 1181 } | 1196 } |
| 1182 | 1197 |
| 1183 } // namespace content | 1198 } // namespace content |
| OLD | NEW |