| 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 "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 |
| 11 #if defined(OS_MACOSX) | 11 #if defined(OS_MACOSX) |
| 12 #include <OpenGL/OpenGL.h> | 12 #include <OpenGL/OpenGL.h> |
| 13 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
| 14 #include "ui/gl/gl_context_cgl.h" | 14 #include "ui/gl/gl_context_cgl.h" |
| 15 #endif // OS_MACOSX | 15 #endif // OS_MACOSX |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 struct GpuSwitchingManager::PlatformSpecific { | 19 struct GpuSwitchingManager::PlatformSpecific { |
| 20 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
| 21 CGLPixelFormatObj discrete_pixel_format; | 21 CGLPixelFormatObj discrete_pixel_format; |
| 22 #endif // OS_MACOSX | 22 #endif // OS_MACOSX |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 // static | 25 // static |
| 26 GpuSwitchingManager* GpuSwitchingManager::GetInstance() { | 26 GpuSwitchingManager* GpuSwitchingManager::GetInstance() { |
| 27 return Singleton<GpuSwitchingManager>::get(); | 27 return base::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 platform_specific_(new PlatformSpecific) { | 35 platform_specific_(new PlatformSpecific) { |
| 36 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
| 37 platform_specific_->discrete_pixel_format = nullptr; | 37 platform_specific_->discrete_pixel_format = nullptr; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return; | 147 return; |
| 148 CGLPixelFormatAttribute attribs[1]; | 148 CGLPixelFormatAttribute attribs[1]; |
| 149 attribs[0] = static_cast<CGLPixelFormatAttribute>(0); | 149 attribs[0] = static_cast<CGLPixelFormatAttribute>(0); |
| 150 GLint num_pixel_formats = 0; | 150 GLint num_pixel_formats = 0; |
| 151 CGLChoosePixelFormat(attribs, &platform_specific_->discrete_pixel_format, | 151 CGLChoosePixelFormat(attribs, &platform_specific_->discrete_pixel_format, |
| 152 &num_pixel_formats); | 152 &num_pixel_formats); |
| 153 } | 153 } |
| 154 #endif // OS_MACOSX | 154 #endif // OS_MACOSX |
| 155 | 155 |
| 156 } // namespace ui | 156 } // namespace ui |
| OLD | NEW |