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 |
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->display_count_) { | |
94 manager->display_count_ = 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 26 matching lines...) Expand all Loading... | |
123 | 136 |
124 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const { | 137 bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const { |
125 if (use_swiftshader_) { | 138 if (use_swiftshader_) { |
126 // Skia's software rendering is probably more efficient than going through | 139 // Skia's software rendering is probably more efficient than going through |
127 // software emulation of the GPU, so use that. | 140 // software emulation of the GPU, so use that. |
128 if (feature == GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) | 141 if (feature == GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) |
129 return true; | 142 return true; |
130 return false; | 143 return false; |
131 } | 144 } |
132 | 145 |
146 #if defined(OS_MACOSX) | |
147 // Many Mac laptops have buggy behavior when rendering to fullscreen | |
148 // multisampled buffers on an external monitor. | |
149 if(display_count_ > 1 && feature == GPU_FEATURE_TYPE_MULTISAMPLING) { | |
150 return true; | |
Ken Russell (switch to Gerrit)
2013/05/06 21:59:04
I thought per our earlier discussion that this was
| |
151 } | |
152 #endif | |
153 | |
133 return (blacklisted_features_.count(feature) == 1); | 154 return (blacklisted_features_.count(feature) == 1); |
134 } | 155 } |
135 | 156 |
136 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { | 157 size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const { |
137 if (use_swiftshader_) | 158 if (use_swiftshader_) |
138 return 1; | 159 return 1; |
139 return blacklisted_features_.size(); | 160 return blacklisted_features_.size(); |
140 } | 161 } |
141 | 162 |
142 void GpuDataManagerImpl::AddGpuSwitchCallback( | 163 void GpuDataManagerImpl::AddGpuSwitchCallback( |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 DisableHardwareAcceleration(); | 726 DisableHardwareAcceleration(); |
706 if (command_line->HasSwitch(switches::kGpuSwitching)) { | 727 if (command_line->HasSwitch(switches::kGpuSwitching)) { |
707 std::string option_string = command_line->GetSwitchValueASCII( | 728 std::string option_string = command_line->GetSwitchValueASCII( |
708 switches::kGpuSwitching); | 729 switches::kGpuSwitching); |
709 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); | 730 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); |
710 if (option != GPU_SWITCHING_OPTION_UNKNOWN) | 731 if (option != GPU_SWITCHING_OPTION_UNKNOWN) |
711 gpu_switching_ = option; | 732 gpu_switching_ = option; |
712 } | 733 } |
713 | 734 |
714 #if defined(OS_MACOSX) | 735 #if defined(OS_MACOSX) |
736 CGGetActiveDisplayList (0, NULL, &display_count_); | |
715 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); | 737 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); |
716 #endif // OS_MACOSX | 738 #endif // OS_MACOSX |
717 } | 739 } |
718 | 740 |
719 GpuDataManagerImpl::~GpuDataManagerImpl() { | 741 GpuDataManagerImpl::~GpuDataManagerImpl() { |
720 #if defined(OS_MACOSX) | 742 #if defined(OS_MACOSX) |
721 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); | 743 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); |
722 #endif | 744 #endif |
723 } | 745 } |
724 | 746 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 | 934 |
913 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, | 935 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, |
914 int render_process_id, | 936 int render_process_id, |
915 int render_view_id, | 937 int render_view_id, |
916 ThreeDAPIType requester) { | 938 ThreeDAPIType requester) { |
917 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, | 939 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
918 url, render_process_id, render_view_id, requester); | 940 url, render_process_id, render_view_id, requester); |
919 } | 941 } |
920 | 942 |
921 } // namespace content | 943 } // namespace content |
OLD | NEW |