diff options
author | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 23:38:40 +0000 |
---|---|---|
committer | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 23:38:40 +0000 |
commit | 21de1e45440a096f619e04ce035f8dacca2fa892 (patch) | |
tree | 81efdb5df8e1068db74f5637b420b21f4675db59 /ui | |
parent | e90e1f02118866ce6ff066a28a3fec264c53c9b1 (diff) | |
download | chromium_src-21de1e45440a096f619e04ce035f8dacca2fa892.zip chromium_src-21de1e45440a096f619e04ce035f8dacca2fa892.tar.gz chromium_src-21de1e45440a096f619e04ce035f8dacca2fa892.tar.bz2 |
Remove calling into CGLQueryRendererInfo to decide dual gpu supporting.
We use the GPU numbers collected through IOKit to make the decision instead.
Also, clean the gpu_info_ in GPU process before calling into GPU collection, otherwise we will see integrated GPU gets accumulated incorrectly in each collection.
BUG=155938
TEST=bot, mac with dual GPUs
Review URL: https://codereview.chromium.org/11358225
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167767 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gl/gpu_switching_manager.cc | 63 | ||||
-rw-r--r-- | ui/gl/gpu_switching_manager.h | 4 |
2 files changed, 11 insertions, 56 deletions
diff --git a/ui/gl/gpu_switching_manager.cc b/ui/gl/gpu_switching_manager.cc index e936c79..05a7865 100644 --- a/ui/gl/gpu_switching_manager.cc +++ b/ui/gl/gpu_switching_manager.cc @@ -13,60 +13,6 @@ #include "ui/gl/gl_context_cgl.h" #endif // OS_MACOSX -namespace { - -#if defined(OS_MACOSX) -bool SupportsOnlineAndOfflineRenderers() { - // Enumerate all hardware-accelerated renderers. If we find one - // online and one offline, assume we're on a dual-GPU system. - GLuint display_mask = static_cast<GLuint>(-1); - CGLRendererInfoObj renderer_info = NULL; - GLint num_renderers = 0; - - bool found_online = false; - bool found_offline = false; - - if (CGLQueryRendererInfo(display_mask, - &renderer_info, - &num_renderers) != kCGLNoError) { - return false; - } - - gfx::ScopedCGLRendererInfoObj scoper(renderer_info); - - for (GLint i = 0; i < num_renderers; ++i) { - GLint accelerated = 0; - if (CGLDescribeRenderer(renderer_info, - i, - kCGLRPAccelerated, - &accelerated) != kCGLNoError) { - return false; - } - - if (!accelerated) - continue; - - GLint online = 0; - if (CGLDescribeRenderer(renderer_info, - i, - kCGLRPOnline, - &online) != kCGLNoError) { - return false; - } - - if (online) { - found_online = true; - } else { - found_offline = true; - } - } - - return (found_online && found_offline); -} -#endif // OS_MACOSX - -} // namespace anonymous - namespace ui { // static @@ -78,7 +24,8 @@ GpuSwitchingManager::GpuSwitchingManager() : gpu_switching_option_(gfx::PreferIntegratedGpu), gpu_switching_option_set_(false), supports_dual_gpus_(false), - supports_dual_gpus_set_(false) { + supports_dual_gpus_set_(false), + gpu_count_(0) { #if defined(OS_MACOSX) discrete_pixel_format_ = NULL; #endif // OS_MACOSX @@ -135,7 +82,7 @@ bool GpuSwitchingManager::SupportsDualGpus() { // Browser process. // We only compute this flag in the browser process. #if defined(OS_MACOSX) - flag = SupportsOnlineAndOfflineRenderers(); + flag = (gpu_count_ == 2); if (flag && command_line.HasSwitch(switches::kUseGL) && command_line.GetSwitchValueASCII(switches::kUseGL) != gfx::kGLImplementationDesktopName) @@ -151,6 +98,10 @@ bool GpuSwitchingManager::SupportsDualGpus() { return supports_dual_gpus_; } +void GpuSwitchingManager::SetGpuCount(size_t gpu_count) { + gpu_count_ = gpu_count; +} + gfx::GpuPreference GpuSwitchingManager::AdjustGpuPreference( gfx::GpuPreference gpu_preference) { if (!gpu_switching_option_set_) diff --git a/ui/gl/gpu_switching_manager.h b/ui/gl/gpu_switching_manager.h index 073e7b1..a097d9a 100644 --- a/ui/gl/gpu_switching_manager.h +++ b/ui/gl/gpu_switching_manager.h @@ -38,6 +38,8 @@ class GL_EXPORT GpuSwitchingManager { // --supports-dual-gpus commandline switch. bool SupportsDualGpus(); + void SetGpuCount(size_t gpu_count); + private: friend struct DefaultSingletonTraits<GpuSwitchingManager>; @@ -56,6 +58,8 @@ class GL_EXPORT GpuSwitchingManager { bool supports_dual_gpus_; bool supports_dual_gpus_set_; + size_t gpu_count_; + DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager); }; |