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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D)) | 564 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH3D)) |
552 prefs->flash_3d_enabled = false; | 565 prefs->flash_3d_enabled = false; |
553 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) { | 566 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D)) { |
554 prefs->flash_stage3d_enabled = false; | 567 prefs->flash_stage3d_enabled = false; |
555 prefs->flash_stage3d_baseline_enabled = false; | 568 prefs->flash_stage3d_baseline_enabled = false; |
556 } | 569 } |
557 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) | 570 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE)) |
558 prefs->flash_stage3d_baseline_enabled = false; | 571 prefs->flash_stage3d_baseline_enabled = false; |
559 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) | 572 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) |
560 prefs->accelerated_2d_canvas_enabled = false; | 573 prefs->accelerated_2d_canvas_enabled = false; |
561 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING)) | 574 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_MULTISAMPLING) |
| 575 || display_count_ > 1) |
562 prefs->gl_multisampling_enabled = false; | 576 prefs->gl_multisampling_enabled = false; |
563 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) { | 577 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_3D_CSS)) { |
564 prefs->accelerated_compositing_for_3d_transforms_enabled = false; | 578 prefs->accelerated_compositing_for_3d_transforms_enabled = false; |
565 prefs->accelerated_compositing_for_animation_enabled = false; | 579 prefs->accelerated_compositing_for_animation_enabled = false; |
566 } | 580 } |
567 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) | 581 if (IsFeatureBlacklisted(GPU_FEATURE_TYPE_ACCELERATED_VIDEO)) |
568 prefs->accelerated_compositing_for_video_enabled = false; | 582 prefs->accelerated_compositing_for_video_enabled = false; |
569 | 583 |
570 // Accelerated video and animation are slower than regular when using | 584 // Accelerated video and animation are slower than regular when using |
571 // SwiftShader. 3D CSS may also be too slow to be worthwhile. | 585 // SwiftShader. 3D CSS may also be too slow to be worthwhile. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 DisableHardwareAcceleration(); | 719 DisableHardwareAcceleration(); |
706 if (command_line->HasSwitch(switches::kGpuSwitching)) { | 720 if (command_line->HasSwitch(switches::kGpuSwitching)) { |
707 std::string option_string = command_line->GetSwitchValueASCII( | 721 std::string option_string = command_line->GetSwitchValueASCII( |
708 switches::kGpuSwitching); | 722 switches::kGpuSwitching); |
709 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); | 723 GpuSwitchingOption option = StringToGpuSwitchingOption(option_string); |
710 if (option != GPU_SWITCHING_OPTION_UNKNOWN) | 724 if (option != GPU_SWITCHING_OPTION_UNKNOWN) |
711 gpu_switching_ = option; | 725 gpu_switching_ = option; |
712 } | 726 } |
713 | 727 |
714 #if defined(OS_MACOSX) | 728 #if defined(OS_MACOSX) |
| 729 CGGetActiveDisplayList (0, NULL, &display_count_); |
715 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); | 730 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); |
716 #endif // OS_MACOSX | 731 #endif // OS_MACOSX |
717 } | 732 } |
718 | 733 |
719 GpuDataManagerImpl::~GpuDataManagerImpl() { | 734 GpuDataManagerImpl::~GpuDataManagerImpl() { |
720 #if defined(OS_MACOSX) | 735 #if defined(OS_MACOSX) |
721 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); | 736 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); |
722 #endif | 737 #endif |
723 } | 738 } |
724 | 739 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 | 927 |
913 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, | 928 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, |
914 int render_process_id, | 929 int render_process_id, |
915 int render_view_id, | 930 int render_view_id, |
916 ThreeDAPIType requester) { | 931 ThreeDAPIType requester) { |
917 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, | 932 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
918 url, render_process_id, render_view_id, requester); | 933 url, render_process_id, render_view_id, requester); |
919 } | 934 } |
920 | 935 |
921 } // namespace content | 936 } // namespace content |
OLD | NEW |