Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: ui/gl/gpu_switching_manager.cc

Issue 1142423005: [M44 Merge] Refine dual-GPU detection on Mac OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2403
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gpu_switching_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/gl/gpu_switching_manager.h" 5 #include "ui/gl/gpu_switching_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/gl/gl_switches.h" 9 #include "ui/gl/gl_switches.h"
10 10
(...skipping 14 matching lines...) Expand all
25 // static 25 // static
26 GpuSwitchingManager* GpuSwitchingManager::GetInstance() { 26 GpuSwitchingManager* GpuSwitchingManager::GetInstance() {
27 return Singleton<GpuSwitchingManager>::get(); 27 return Singleton<GpuSwitchingManager>::get();
28 } 28 }
29 29
30 GpuSwitchingManager::GpuSwitchingManager() 30 GpuSwitchingManager::GpuSwitchingManager()
31 : gpu_switching_option_(gfx::PreferIntegratedGpu), 31 : gpu_switching_option_(gfx::PreferIntegratedGpu),
32 gpu_switching_option_set_(false), 32 gpu_switching_option_set_(false),
33 supports_dual_gpus_(false), 33 supports_dual_gpus_(false),
34 supports_dual_gpus_set_(false), 34 supports_dual_gpus_set_(false),
35 gpu_count_(0),
36 platform_specific_(new PlatformSpecific) { 35 platform_specific_(new PlatformSpecific) {
37 #if defined(OS_MACOSX) 36 #if defined(OS_MACOSX)
38 platform_specific_->discrete_pixel_format = nullptr; 37 platform_specific_->discrete_pixel_format = nullptr;
39 #endif // OS_MACOSX 38 #endif // OS_MACOSX
40 } 39 }
41 40
42 GpuSwitchingManager::~GpuSwitchingManager() { 41 GpuSwitchingManager::~GpuSwitchingManager() {
43 #if defined(OS_MACOSX) 42 #if defined(OS_MACOSX)
44 if (platform_specific_->discrete_pixel_format) 43 if (platform_specific_->discrete_pixel_format)
45 CGLReleasePixelFormat(platform_specific_->discrete_pixel_format); 44 CGLReleasePixelFormat(platform_specific_->discrete_pixel_format);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 flag = true; 83 flag = true;
85 } else if (flag_string == "false") { 84 } else if (flag_string == "false") {
86 flag = false; 85 flag = false;
87 } else { 86 } else {
88 NOTIMPLEMENTED(); 87 NOTIMPLEMENTED();
89 } 88 }
90 } else { 89 } else {
91 // Browser process. 90 // Browser process.
92 // We only compute this flag in the browser process. 91 // We only compute this flag in the browser process.
93 #if defined(OS_MACOSX) 92 #if defined(OS_MACOSX)
94 flag = (gpu_count_ == 2); 93 flag = (vendor_ids_.size() == 2);
95 if (flag && command_line.HasSwitch(switches::kUseGL) && 94 if (flag && command_line.HasSwitch(switches::kUseGL) &&
96 command_line.GetSwitchValueASCII(switches::kUseGL) != 95 command_line.GetSwitchValueASCII(switches::kUseGL) !=
97 gfx::kGLImplementationDesktopName) 96 gfx::kGLImplementationDesktopName)
98 flag = false; 97 flag = false;
99 98
100 if (flag && !base::mac::IsOSLionOrLater()) 99 if (flag && !base::mac::IsOSLionOrLater())
101 flag = false; 100 flag = false;
101
102 if (flag) {
103 // Only advertise that we have two GPUs to the rest of
104 // Chrome's code if we find an Intel GPU and some other
105 // vendor's GPU. Otherwise we don't understand the
106 // configuration and don't deal well with it (an example being
107 // the dual AMD GPUs in recent Mac Pros).
108 const uint32 intel = 0x8086;
109 flag = ((vendor_ids_[0] == intel && vendor_ids_[1] != intel) ||
110 (vendor_ids_[0] != intel && vendor_ids_[1] == intel));
111 }
102 #endif // OS_MACOSX 112 #endif // OS_MACOSX
103 } 113 }
104 supports_dual_gpus_ = flag; 114 supports_dual_gpus_ = flag;
105 supports_dual_gpus_set_ = true; 115 supports_dual_gpus_set_ = true;
106 } 116 }
107 return supports_dual_gpus_; 117 return supports_dual_gpus_;
108 } 118 }
109 119
110 void GpuSwitchingManager::SetGpuCount(size_t gpu_count) { 120 void GpuSwitchingManager::SetGpuVendorIds(
111 gpu_count_ = gpu_count; 121 const std::vector<uint32>& vendor_ids) {
122 vendor_ids_ = vendor_ids;
112 } 123 }
113 124
114 void GpuSwitchingManager::AddObserver(GpuSwitchingObserver* observer) { 125 void GpuSwitchingManager::AddObserver(GpuSwitchingObserver* observer) {
115 observer_list_.AddObserver(observer); 126 observer_list_.AddObserver(observer);
116 } 127 }
117 128
118 void GpuSwitchingManager::RemoveObserver(GpuSwitchingObserver* observer) { 129 void GpuSwitchingManager::RemoveObserver(GpuSwitchingObserver* observer) {
119 observer_list_.RemoveObserver(observer); 130 observer_list_.RemoveObserver(observer);
120 } 131 }
121 132
(...skipping 14 matching lines...) Expand all
136 return; 147 return;
137 CGLPixelFormatAttribute attribs[1]; 148 CGLPixelFormatAttribute attribs[1];
138 attribs[0] = static_cast<CGLPixelFormatAttribute>(0); 149 attribs[0] = static_cast<CGLPixelFormatAttribute>(0);
139 GLint num_pixel_formats = 0; 150 GLint num_pixel_formats = 0;
140 CGLChoosePixelFormat(attribs, &platform_specific_->discrete_pixel_format, 151 CGLChoosePixelFormat(attribs, &platform_specific_->discrete_pixel_format,
141 &num_pixel_formats); 152 &num_pixel_formats);
142 } 153 }
143 #endif // OS_MACOSX 154 #endif // OS_MACOSX
144 155
145 } // namespace ui 156 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gl/gpu_switching_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698