Chromium Code Reviews| 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/gpu_data_manager_impl.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 6 | 6 |
| 7 #if defined(OS_MACOSX) | 7 #if defined(OS_MACOSX) |
| 8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
| 9 #endif // OS_MACOSX | 9 #endif // OS_MACOSX |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 rt += ","; | 71 rt += ","; |
| 72 rt += base::IntToString(*it); | 72 rt += base::IntToString(*it); |
| 73 } | 73 } |
| 74 return rt; | 74 return rt; |
| 75 } | 75 } |
| 76 | 76 |
| 77 #if defined(OS_MACOSX) | 77 #if defined(OS_MACOSX) |
| 78 void DisplayReconfigCallback(CGDirectDisplayID display, | 78 void DisplayReconfigCallback(CGDirectDisplayID display, |
| 79 CGDisplayChangeSummaryFlags flags, | 79 CGDisplayChangeSummaryFlags flags, |
| 80 void* gpu_data_manager) { | 80 void* gpu_data_manager) { |
| 81 if (flags & kCGDisplayAddFlag) { | 81 if(flags == kCGDisplayBeginConfigurationFlag) |
| 82 GpuDataManagerImpl* manager = | 82 return; // This call contains no information about the display change |
|
Ken Russell (switch to Gerrit)
2013/05/08 23:53:24
End with ".".
| |
| 83 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); | 83 |
| 84 DCHECK(manager); | 84 GpuDataManagerImpl* manager = |
| 85 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); | |
| 86 DCHECK(manager); | |
| 87 | |
| 88 uint32_t displayCount; | |
| 89 CGGetActiveDisplayList(0, NULL, &displayCount); | |
| 90 | |
| 91 bool fireGpuSwitch = flags & kCGDisplayAddFlag; | |
| 92 | |
| 93 if (displayCount != manager->GetDisplayCount()) { | |
| 94 manager->SetDisplayCount(displayCount); | |
| 95 fireGpuSwitch = true; | |
| 96 } | |
| 97 | |
| 98 if (fireGpuSwitch) | |
| 85 manager->HandleGpuSwitch(); | 99 manager->HandleGpuSwitch(); |
| 86 } | |
| 87 } | 100 } |
| 88 #endif // OS_MACOSX | 101 #endif // OS_MACOSX |
| 89 | 102 |
| 90 // Block all domains' use of 3D APIs for this many milliseconds if | 103 // Block all domains' use of 3D APIs for this many milliseconds if |
| 91 // approaching a threshold where system stability might be compromised. | 104 // approaching a threshold where system stability might be compromised. |
| 92 const int64 kBlockAllDomainsMs = 10000; | 105 const int64 kBlockAllDomainsMs = 10000; |
| 93 const int kNumResetsWithinDuration = 1; | 106 const int kNumResetsWithinDuration = 1; |
| 94 | 107 |
| 95 // Enums for UMA histograms. | 108 // Enums for UMA histograms. |
| 96 enum BlockStatusHistogram { | 109 enum BlockStatusHistogram { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 void GpuDataManagerImpl::RemoveGpuSwitchCallback( | 160 void GpuDataManagerImpl::RemoveGpuSwitchCallback( |
| 148 const GpuSwitchCallback& callback) { | 161 const GpuSwitchCallback& callback) { |
| 149 for (size_t i = 0; i < gpu_switch_callbacks_.size(); i++) { | 162 for (size_t i = 0; i < gpu_switch_callbacks_.size(); i++) { |
| 150 if (gpu_switch_callbacks_[i].Equals(callback)) { | 163 if (gpu_switch_callbacks_[i].Equals(callback)) { |
| 151 gpu_switch_callbacks_.erase(gpu_switch_callbacks_.begin() + i); | 164 gpu_switch_callbacks_.erase(gpu_switch_callbacks_.begin() + i); |
| 152 return; | 165 return; |
| 153 } | 166 } |
| 154 } | 167 } |
| 155 } | 168 } |
| 156 | 169 |
| 170 void GpuDataManagerImpl::SetDisplayCount(unsigned int display_count) { | |
| 171 display_count_ = display_count; | |
| 172 } | |
| 173 | |
| 174 unsigned int GpuDataManagerImpl::GetDisplayCount() const { | |
| 175 return display_count_; | |
| 176 } | |
| 177 | |
| 157 GPUInfo GpuDataManagerImpl::GetGPUInfo() const { | 178 GPUInfo GpuDataManagerImpl::GetGPUInfo() const { |
| 158 GPUInfo gpu_info; | 179 GPUInfo gpu_info; |
| 159 { | 180 { |
| 160 base::AutoLock auto_lock(gpu_info_lock_); | 181 base::AutoLock auto_lock(gpu_info_lock_); |
| 161 gpu_info = gpu_info_; | 182 gpu_info = gpu_info_; |
| 162 } | 183 } |
| 163 return gpu_info; | 184 return gpu_info; |
| 164 } | 185 } |
| 165 | 186 |
| 166 void GpuDataManagerImpl::GetGpuProcessHandles( | 187 void GpuDataManagerImpl::GetGpuProcessHandles( |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D)) | 592 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D)) |
| 572 prefs->flash_3d_enabled = false; | 593 prefs->flash_3d_enabled = false; |
| 573 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) { | 594 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) { |
| 574 prefs->flash_stage3d_enabled = false; | 595 prefs->flash_stage3d_enabled = false; |
| 575 prefs->flash_stage3d_baseline_enabled = false; | 596 prefs->flash_stage3d_baseline_enabled = false; |
| 576 } | 597 } |
| 577 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) | 598 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) |
| 578 prefs->flash_stage3d_baseline_enabled = false; | 599 prefs->flash_stage3d_baseline_enabled = false; |
| 579 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) | 600 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) |
| 580 prefs->accelerated_2d_canvas_enabled = false; | 601 prefs->accelerated_2d_canvas_enabled = false; |
| 581 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING)) | 602 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) |
| 603 || display_count_ > 1) | |
| 582 prefs->gl_multisampling_enabled = false; | 604 prefs->gl_multisampling_enabled = false; |
| 583 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) { | 605 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) { |
| 584 prefs->accelerated_compositing_for_3d_transforms_enabled = false; | 606 prefs->accelerated_compositing_for_3d_transforms_enabled = false; |
| 585 prefs->accelerated_compositing_for_animation_enabled = false; | 607 prefs->accelerated_compositing_for_animation_enabled = false; |
| 586 } | 608 } |
| 587 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) | 609 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) |
| 588 prefs->accelerated_compositing_for_video_enabled = false; | 610 prefs->accelerated_compositing_for_video_enabled = false; |
| 589 | 611 |
| 590 // Accelerated video and animation are slower than regular when using | 612 // Accelerated video and animation are slower than regular when using |
| 591 // SwiftShader. 3D CSS may also be too slow to be worthwhile. | 613 // SwiftShader. 3D CSS may also be too slow to be worthwhile. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 } | 730 } |
| 709 | 731 |
| 710 GpuDataManagerImpl::GpuDataManagerImpl() | 732 GpuDataManagerImpl::GpuDataManagerImpl() |
| 711 : complete_gpu_info_already_requested_(false), | 733 : complete_gpu_info_already_requested_(false), |
| 712 gpu_switching_(GPU_SWITCHING_OPTION_AUTOMATIC), | 734 gpu_switching_(GPU_SWITCHING_OPTION_AUTOMATIC), |
| 713 observer_list_(new GpuDataManagerObserverList), | 735 observer_list_(new GpuDataManagerObserverList), |
| 714 use_swiftshader_(false), | 736 use_swiftshader_(false), |
| 715 card_blacklisted_(false), | 737 card_blacklisted_(false), |
| 716 update_histograms_(true), | 738 update_histograms_(true), |
| 717 window_count_(0), | 739 window_count_(0), |
| 718 domain_blocking_enabled_(true) { | 740 domain_blocking_enabled_(true), |
| 741 display_count_(0) { | |
| 719 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 742 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 720 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 743 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
| 721 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 744 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
| 722 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 745 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
| 723 } | 746 } |
| 724 if (command_line->HasSwitch(switches::kDisableGpu)) | 747 if (command_line->HasSwitch(switches::kDisableGpu)) |
| 725 DisableHardwareAcceleration(); | 748 DisableHardwareAcceleration(); |
| 726 if (command_line->HasSwitch(switches::kGpuSwitching)) { | 749 if (command_line->HasSwitch(switches::kGpuSwitching)) { |
| 727 std::string option_string = command_line->GetSwitchValueASCII( | 750 std::string option_string = command_line->GetSwitchValueASCII( |
| 728 switches::kGpuSwitching); | 751 switches::kGpuSwitching); |
| 729 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); | 752 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); |
| 730 if (option != GPU_SWITCHING_OPTION_UNKNOWN) | 753 if (option != GPU_SWITCHING_OPTION_UNKNOWN) |
| 731 gpu_switching_ = option; | 754 gpu_switching_ = option; |
| 732 } | 755 } |
| 733 | 756 |
| 734 #if defined(OS_MACOSX) | 757 #if defined(OS_MACOSX) |
| 758 CGGetActiveDisplayList (0, NULL, &display_count_); | |
| 735 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); | 759 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); |
| 736 #endif // OS_MACOSX | 760 #endif // OS_MACOSX |
| 737 } | 761 } |
| 738 | 762 |
| 739 GpuDataManagerImpl::~GpuDataManagerImpl() { | 763 GpuDataManagerImpl::~GpuDataManagerImpl() { |
| 740 #if defined(OS_MACOSX) | 764 #if defined(OS_MACOSX) |
| 741 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); | 765 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); |
| 742 #endif | 766 #endif |
| 743 } | 767 } |
| 744 | 768 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 932 | 956 |
| 933 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, | 957 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, |
| 934 int render_process_id, | 958 int render_process_id, |
| 935 int render_view_id, | 959 int render_view_id, |
| 936 ThreeDAPIType requester) { | 960 ThreeDAPIType requester) { |
| 937 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, | 961 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
| 938 url, render_process_id, render_view_id, requester); | 962 url, render_process_id, render_view_id, requester); |
| 939 } | 963 } |
| 940 | 964 |
| 941 } // namespace content | 965 } // namespace content |
| OLD | NEW |