| 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 #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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 rt += ","; | 68 rt += ","; |
| 69 rt += base::IntToString(*it); | 69 rt += base::IntToString(*it); |
| 70 } | 70 } |
| 71 return rt; | 71 return rt; |
| 72 } | 72 } |
| 73 | 73 |
| 74 #if defined(OS_MACOSX) | 74 #if defined(OS_MACOSX) |
| 75 void DisplayReconfigCallback(CGDirectDisplayID display, | 75 void DisplayReconfigCallback(CGDirectDisplayID display, |
| 76 CGDisplayChangeSummaryFlags flags, | 76 CGDisplayChangeSummaryFlags flags, |
| 77 void* gpu_data_manager) { | 77 void* gpu_data_manager) { |
| 78 if (flags & kCGDisplayAddFlag) { | 78 if(flags == kCGDisplayBeginConfigurationFlag) |
| 79 GpuDataManagerImpl* manager = | 79 return; // This call contains no information about the display change |
| 80 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); | 80 |
| 81 DCHECK(manager); | 81 GpuDataManagerImpl* manager = |
| 82 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); |
| 83 DCHECK(manager); |
| 84 |
| 85 uint32_t displayCount; |
| 86 CGGetActiveDisplayList(0, NULL, &displayCount); |
| 87 |
| 88 bool fireGpuSwitch = flags & kCGDisplayAddFlag; |
| 89 |
| 90 if (displayCount != manager->GetDisplayCount()) { |
| 91 manager->SetDisplayCount(displayCount); |
| 92 fireGpuSwitch = true; |
| 93 } |
| 94 |
| 95 if (fireGpuSwitch) |
| 82 manager->HandleGpuSwitch(); | 96 manager->HandleGpuSwitch(); |
| 83 } | |
| 84 } | 97 } |
| 85 #endif // OS_MACOSX | 98 #endif // OS_MACOSX |
| 86 | 99 |
| 87 // Block all domains' use of 3D APIs for this many milliseconds if | 100 // Block all domains' use of 3D APIs for this many milliseconds if |
| 88 // approaching a threshold where system stability might be compromised. | 101 // approaching a threshold where system stability might be compromised. |
| 89 const int64 kBlockAllDomainsMs = 10000; | 102 const int64 kBlockAllDomainsMs = 10000; |
| 90 const int kNumResetsWithinDuration = 1; | 103 const int kNumResetsWithinDuration = 1; |
| 91 | 104 |
| 92 // Enums for UMA histograms. | 105 // Enums for UMA histograms. |
| 93 enum BlockStatusHistogram { | 106 enum BlockStatusHistogram { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 119 | 132 |
| 120 return (blacklisted_features_.count(feature) == 1); | 133 return (blacklisted_features_.count(feature) == 1); |
| 121 } | 134 } |
| 122 | 135 |
| 123 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { | 136 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { |
| 124 if (use_swiftshader_) | 137 if (use_swiftshader_) |
| 125 return 1; | 138 return 1; |
| 126 return blacklisted_features_.size(); | 139 return blacklisted_features_.size(); |
| 127 } | 140 } |
| 128 | 141 |
| 142 void GpuDataManagerImplPrivate::SetDisplayCount(unsigned int display_count) { |
| 143 display_count_ = display_count; |
| 144 } |
| 145 |
| 146 unsigned int GpuDataManagerImplPrivate::GetDisplayCount() const { |
| 147 return display_count_; |
| 148 } |
| 149 |
| 129 GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { | 150 GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { |
| 130 return gpu_info_; | 151 return gpu_info_; |
| 131 } | 152 } |
| 132 | 153 |
| 133 void GpuDataManagerImplPrivate::GetGpuProcessHandles( | 154 void GpuDataManagerImplPrivate::GetGpuProcessHandles( |
| 134 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { | 155 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { |
| 135 GpuProcessHost::GetProcessHandles(callback); | 156 GpuProcessHost::GetProcessHandles(callback); |
| 136 } | 157 } |
| 137 | 158 |
| 138 bool GpuDataManagerImplPrivate::GpuAccessAllowed( | 159 bool GpuDataManagerImplPrivate::GpuAccessAllowed( |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D)) | 553 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D)) |
| 533 prefs->flash_3d_enabled = false; | 554 prefs->flash_3d_enabled = false; |
| 534 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) { | 555 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) { |
| 535 prefs->flash_stage3d_enabled = false; | 556 prefs->flash_stage3d_enabled = false; |
| 536 prefs->flash_stage3d_baseline_enabled = false; | 557 prefs->flash_stage3d_baseline_enabled = false; |
| 537 } | 558 } |
| 538 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) | 559 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) |
| 539 prefs->flash_stage3d_baseline_enabled = false; | 560 prefs->flash_stage3d_baseline_enabled = false; |
| 540 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) | 561 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) |
| 541 prefs->accelerated_2d_canvas_enabled = false; | 562 prefs->accelerated_2d_canvas_enabled = false; |
| 542 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING)) | 563 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) |
| 564 || display_count_ > 1) |
| 543 prefs->gl_multisampling_enabled = false; | 565 prefs->gl_multisampling_enabled = false; |
| 544 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) { | 566 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) { |
| 545 prefs->accelerated_compositing_for_3d_transforms_enabled = false; | 567 prefs->accelerated_compositing_for_3d_transforms_enabled = false; |
| 546 prefs->accelerated_compositing_for_animation_enabled = false; | 568 prefs->accelerated_compositing_for_animation_enabled = false; |
| 547 } | 569 } |
| 548 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) | 570 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) |
| 549 prefs->accelerated_compositing_for_video_enabled = false; | 571 prefs->accelerated_compositing_for_video_enabled = false; |
| 550 | 572 |
| 551 // Accelerated video and animation are slower than regular when using | 573 // Accelerated video and animation are slower than regular when using |
| 552 // SwiftShader. 3D CSS may also be too slow to be worthwhile. | 574 // SwiftShader. 3D CSS may also be too slow to be worthwhile. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( | 702 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( |
| 681 GpuDataManagerImpl* owner) | 703 GpuDataManagerImpl* owner) |
| 682 : complete_gpu_info_already_requested_(false), | 704 : complete_gpu_info_already_requested_(false), |
| 683 gpu_switching_(GPU_SWITCHING_OPTION_AUTOMATIC), | 705 gpu_switching_(GPU_SWITCHING_OPTION_AUTOMATIC), |
| 684 observer_list_(new GpuDataManagerObserverList), | 706 observer_list_(new GpuDataManagerObserverList), |
| 685 use_swiftshader_(false), | 707 use_swiftshader_(false), |
| 686 card_blacklisted_(false), | 708 card_blacklisted_(false), |
| 687 update_histograms_(true), | 709 update_histograms_(true), |
| 688 window_count_(0), | 710 window_count_(0), |
| 689 domain_blocking_enabled_(true), | 711 domain_blocking_enabled_(true), |
| 690 owner_(owner) { | 712 owner_(owner), |
| 713 display_count_(0) { |
| 691 DCHECK(owner_); | 714 DCHECK(owner_); |
| 692 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 715 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 693 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 716 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
| 694 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 717 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
| 695 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 718 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
| 696 } | 719 } |
| 697 if (command_line->HasSwitch(switches::kDisableGpu)) | 720 if (command_line->HasSwitch(switches::kDisableGpu)) |
| 698 DisableHardwareAcceleration(); | 721 DisableHardwareAcceleration(); |
| 699 if (command_line->HasSwitch(switches::kGpuSwitching)) { | 722 if (command_line->HasSwitch(switches::kGpuSwitching)) { |
| 700 std::string option_string = command_line->GetSwitchValueASCII( | 723 std::string option_string = command_line->GetSwitchValueASCII( |
| 701 switches::kGpuSwitching); | 724 switches::kGpuSwitching); |
| 702 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); | 725 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); |
| 703 if (option != GPU_SWITCHING_OPTION_UNKNOWN) | 726 if (option != GPU_SWITCHING_OPTION_UNKNOWN) |
| 704 gpu_switching_ = option; | 727 gpu_switching_ = option; |
| 705 } | 728 } |
| 706 | 729 |
| 707 #if defined(OS_MACOSX) | 730 #if defined(OS_MACOSX) |
| 731 CGGetActiveDisplayList (0, NULL, &display_count_); |
| 708 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); | 732 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); |
| 709 #endif // OS_MACOSX | 733 #endif // OS_MACOSX |
| 710 } | 734 } |
| 711 | 735 |
| 712 GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { | 736 GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { |
| 713 #if defined(OS_MACOSX) | 737 #if defined(OS_MACOSX) |
| 714 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, owner_); | 738 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, owner_); |
| 715 #endif | 739 #endif |
| 716 } | 740 } |
| 717 | 741 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 int render_process_id, | 930 int render_process_id, |
| 907 int render_view_id, | 931 int render_view_id, |
| 908 ThreeDAPIType requester) { | 932 ThreeDAPIType requester) { |
| 909 GpuDataManagerImpl::UnlockedSession session(owner_); | 933 GpuDataManagerImpl::UnlockedSession session(owner_); |
| 910 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, | 934 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
| 911 url, render_process_id, render_view_id, requester); | 935 url, render_process_id, render_view_id, requester); |
| 912 } | 936 } |
| 913 | 937 |
| 914 } // namespace content | 938 } // namespace content |
| 915 | 939 |
| OLD | NEW |