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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 rt += ","; | 209 rt += ","; |
210 rt += base::IntToString(*it); | 210 rt += base::IntToString(*it); |
211 } | 211 } |
212 return rt; | 212 return rt; |
213 } | 213 } |
214 | 214 |
215 #if defined(OS_MACOSX) | 215 #if defined(OS_MACOSX) |
216 void DisplayReconfigCallback(CGDirectDisplayID display, | 216 void DisplayReconfigCallback(CGDirectDisplayID display, |
217 CGDisplayChangeSummaryFlags flags, | 217 CGDisplayChangeSummaryFlags flags, |
218 void* gpu_data_manager) { | 218 void* gpu_data_manager) { |
219 if (flags & kCGDisplayAddFlag) { | 219 if(flags == kCGDisplayBeginConfigurationFlag) |
220 GpuDataManagerImpl* manager = | 220 return; // This call contains no information about the display change |
221 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); | 221 |
222 DCHECK(manager); | 222 GpuDataManagerImpl* manager = |
| 223 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); |
| 224 DCHECK(manager); |
| 225 |
| 226 uint32_t displayCount; |
| 227 CGGetActiveDisplayList(0, NULL, &displayCount); |
| 228 |
| 229 bool fireGpuSwitch = flags & kCGDisplayAddFlag; |
| 230 |
| 231 if (displayCount != manager->GetDisplayCount()) { |
| 232 manager->SetDisplayCount(displayCount); |
| 233 fireGpuSwitch = true; |
| 234 } |
| 235 |
| 236 if (fireGpuSwitch) |
223 manager->HandleGpuSwitch(); | 237 manager->HandleGpuSwitch(); |
224 } | |
225 } | 238 } |
226 #endif // OS_MACOSX | 239 #endif // OS_MACOSX |
227 | 240 |
228 #if defined(OS_ANDROID) | 241 #if defined(OS_ANDROID) |
229 void ApplyAndroidWorkarounds(const gpu::GPUInfo& gpu_info, | 242 void ApplyAndroidWorkarounds(const gpu::GPUInfo& gpu_info, |
230 CommandLine* command_line) { | 243 CommandLine* command_line) { |
231 std::string vendor(StringToLowerASCII(gpu_info.gl_vendor)); | 244 std::string vendor(StringToLowerASCII(gpu_info.gl_vendor)); |
232 std::string renderer(StringToLowerASCII(gpu_info.gl_renderer)); | 245 std::string renderer(StringToLowerASCII(gpu_info.gl_renderer)); |
233 bool is_img = | 246 bool is_img = |
234 gpu_info.gl_vendor.find("Imagination") != std::string::npos; | 247 gpu_info.gl_vendor.find("Imagination") != std::string::npos; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 348 |
336 return (blacklisted_features_.count(feature) == 1); | 349 return (blacklisted_features_.count(feature) == 1); |
337 } | 350 } |
338 | 351 |
339 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { | 352 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { |
340 if (use_swiftshader_) | 353 if (use_swiftshader_) |
341 return 1; | 354 return 1; |
342 return blacklisted_features_.size(); | 355 return blacklisted_features_.size(); |
343 } | 356 } |
344 | 357 |
| 358 void GpuDataManagerImplPrivate::SetDisplayCount(unsigned int display_count) { |
| 359 display_count_ = display_count; |
| 360 } |
| 361 |
| 362 unsigned int GpuDataManagerImplPrivate::GetDisplayCount() const { |
| 363 return display_count_; |
| 364 } |
| 365 |
345 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { | 366 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { |
346 return gpu_info_; | 367 return gpu_info_; |
347 } | 368 } |
348 | 369 |
349 void GpuDataManagerImplPrivate::GetGpuProcessHandles( | 370 void GpuDataManagerImplPrivate::GetGpuProcessHandles( |
350 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { | 371 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { |
351 GpuProcessHost::GetProcessHandles(callback); | 372 GpuProcessHost::GetProcessHandles(callback); |
352 } | 373 } |
353 | 374 |
354 bool GpuDataManagerImplPrivate::GpuAccessAllowed( | 375 bool GpuDataManagerImplPrivate::GpuAccessAllowed( |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D)) | 764 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH3D)) |
744 prefs->flash_3d_enabled = false; | 765 prefs->flash_3d_enabled = false; |
745 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D)) { | 766 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D)) { |
746 prefs->flash_stage3d_enabled = false; | 767 prefs->flash_stage3d_enabled = false; |
747 prefs->flash_stage3d_baseline_enabled = false; | 768 prefs->flash_stage3d_baseline_enabled = false; |
748 } | 769 } |
749 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) | 770 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) |
750 prefs->flash_stage3d_baseline_enabled = false; | 771 prefs->flash_stage3d_baseline_enabled = false; |
751 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) | 772 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) |
752 prefs->accelerated_2d_canvas_enabled = false; | 773 prefs->accelerated_2d_canvas_enabled = false; |
753 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING)) | 774 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING) |
| 775 || display_count_ > 1) |
754 prefs->gl_multisampling_enabled = false; | 776 prefs->gl_multisampling_enabled = false; |
755 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_3D_CSS)) { | 777 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_3D_CSS)) { |
756 prefs->accelerated_compositing_for_3d_transforms_enabled = false; | 778 prefs->accelerated_compositing_for_3d_transforms_enabled = false; |
757 prefs->accelerated_compositing_for_animation_enabled = false; | 779 prefs->accelerated_compositing_for_animation_enabled = false; |
758 } | 780 } |
759 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) | 781 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) |
760 prefs->accelerated_compositing_for_video_enabled = false; | 782 prefs->accelerated_compositing_for_video_enabled = false; |
761 | 783 |
762 // Accelerated video and animation are slower than regular when using | 784 // Accelerated video and animation are slower than regular when using |
763 // SwiftShader. 3D CSS may also be too slow to be worthwhile. | 785 // SwiftShader. 3D CSS may also be too slow to be worthwhile. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( | 914 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate( |
893 GpuDataManagerImpl* owner) | 915 GpuDataManagerImpl* owner) |
894 : complete_gpu_info_already_requested_(false), | 916 : complete_gpu_info_already_requested_(false), |
895 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), | 917 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), |
896 observer_list_(new GpuDataManagerObserverList), | 918 observer_list_(new GpuDataManagerObserverList), |
897 use_swiftshader_(false), | 919 use_swiftshader_(false), |
898 card_blacklisted_(false), | 920 card_blacklisted_(false), |
899 update_histograms_(true), | 921 update_histograms_(true), |
900 window_count_(0), | 922 window_count_(0), |
901 domain_blocking_enabled_(true), | 923 domain_blocking_enabled_(true), |
902 owner_(owner) { | 924 owner_(owner), |
| 925 display_count_(0) { |
903 DCHECK(owner_); | 926 DCHECK(owner_); |
904 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 927 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
905 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 928 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
906 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 929 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
907 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 930 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
908 } | 931 } |
909 if (command_line->HasSwitch(switches::kDisableGpu)) | 932 if (command_line->HasSwitch(switches::kDisableGpu)) |
910 DisableHardwareAcceleration(); | 933 DisableHardwareAcceleration(); |
911 if (command_line->HasSwitch(switches::kGpuSwitching)) { | 934 if (command_line->HasSwitch(switches::kGpuSwitching)) { |
912 std::string option_string = command_line->GetSwitchValueASCII( | 935 std::string option_string = command_line->GetSwitchValueASCII( |
913 switches::kGpuSwitching); | 936 switches::kGpuSwitching); |
914 gpu::GpuSwitchingOption option = | 937 gpu::GpuSwitchingOption option = |
915 gpu::StringToGpuSwitchingOption(option_string); | 938 gpu::StringToGpuSwitchingOption(option_string); |
916 if (option != gpu::GPU_SWITCHING_OPTION_UNKNOWN) | 939 if (option != gpu::GPU_SWITCHING_OPTION_UNKNOWN) |
917 gpu_switching_ = option; | 940 gpu_switching_ = option; |
918 } | 941 } |
919 | 942 |
920 #if defined(OS_MACOSX) | 943 #if defined(OS_MACOSX) |
| 944 CGGetActiveDisplayList (0, NULL, &display_count_); |
921 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); | 945 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); |
922 #endif // OS_MACOSX | 946 #endif // OS_MACOSX |
923 } | 947 } |
924 | 948 |
925 GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { | 949 GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { |
926 #if defined(OS_MACOSX) | 950 #if defined(OS_MACOSX) |
927 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, owner_); | 951 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, owner_); |
928 #endif | 952 #endif |
929 } | 953 } |
930 | 954 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 int render_process_id, | 1159 int render_process_id, |
1136 int render_view_id, | 1160 int render_view_id, |
1137 ThreeDAPIType requester) { | 1161 ThreeDAPIType requester) { |
1138 GpuDataManagerImpl::UnlockedSession session(owner_); | 1162 GpuDataManagerImpl::UnlockedSession session(owner_); |
1139 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, | 1163 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
1140 url, render_process_id, render_view_id, requester); | 1164 url, render_process_id, render_view_id, requester); |
1141 } | 1165 } |
1142 | 1166 |
1143 } // namespace content | 1167 } // namespace content |
1144 | 1168 |
OLD | NEW |