| 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 "build/build_config.h" |
| 9 #include "ui/gl/gl_switches.h" | 10 #include "ui/gl/gl_switches.h" |
| 10 | 11 |
| 11 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
| 12 #include <OpenGL/OpenGL.h> | 13 #include <OpenGL/OpenGL.h> |
| 13 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 14 #include "ui/gl/gl_context_cgl.h" | 15 #include "ui/gl/gl_context_cgl.h" |
| 15 #endif // OS_MACOSX | 16 #endif // OS_MACOSX |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 | 19 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 99 |
| 99 if (flag && !base::mac::IsOSLionOrLater()) | 100 if (flag && !base::mac::IsOSLionOrLater()) |
| 100 flag = false; | 101 flag = false; |
| 101 | 102 |
| 102 if (flag) { | 103 if (flag) { |
| 103 // Only advertise that we have two GPUs to the rest of | 104 // 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 // Chrome's code if we find an Intel GPU and some other |
| 105 // vendor's GPU. Otherwise we don't understand the | 106 // vendor's GPU. Otherwise we don't understand the |
| 106 // configuration and don't deal well with it (an example being | 107 // configuration and don't deal well with it (an example being |
| 107 // the dual AMD GPUs in recent Mac Pros). | 108 // the dual AMD GPUs in recent Mac Pros). |
| 108 const uint32 intel = 0x8086; | 109 const uint32_t intel = 0x8086; |
| 109 flag = ((vendor_ids_[0] == intel && vendor_ids_[1] != intel) || | 110 flag = ((vendor_ids_[0] == intel && vendor_ids_[1] != intel) || |
| 110 (vendor_ids_[0] != intel && vendor_ids_[1] == intel)); | 111 (vendor_ids_[0] != intel && vendor_ids_[1] == intel)); |
| 111 } | 112 } |
| 112 #endif // OS_MACOSX | 113 #endif // OS_MACOSX |
| 113 } | 114 } |
| 114 supports_dual_gpus_ = flag; | 115 supports_dual_gpus_ = flag; |
| 115 supports_dual_gpus_set_ = true; | 116 supports_dual_gpus_set_ = true; |
| 116 } | 117 } |
| 117 return supports_dual_gpus_; | 118 return supports_dual_gpus_; |
| 118 } | 119 } |
| 119 | 120 |
| 120 void GpuSwitchingManager::SetGpuVendorIds( | 121 void GpuSwitchingManager::SetGpuVendorIds( |
| 121 const std::vector<uint32>& vendor_ids) { | 122 const std::vector<uint32_t>& vendor_ids) { |
| 122 vendor_ids_ = vendor_ids; | 123 vendor_ids_ = vendor_ids; |
| 123 } | 124 } |
| 124 | 125 |
| 125 void GpuSwitchingManager::AddObserver(GpuSwitchingObserver* observer) { | 126 void GpuSwitchingManager::AddObserver(GpuSwitchingObserver* observer) { |
| 126 observer_list_.AddObserver(observer); | 127 observer_list_.AddObserver(observer); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void GpuSwitchingManager::RemoveObserver(GpuSwitchingObserver* observer) { | 130 void GpuSwitchingManager::RemoveObserver(GpuSwitchingObserver* observer) { |
| 130 observer_list_.RemoveObserver(observer); | 131 observer_list_.RemoveObserver(observer); |
| 131 } | 132 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 147 return; | 148 return; |
| 148 CGLPixelFormatAttribute attribs[1]; | 149 CGLPixelFormatAttribute attribs[1]; |
| 149 attribs[0] = static_cast<CGLPixelFormatAttribute>(0); | 150 attribs[0] = static_cast<CGLPixelFormatAttribute>(0); |
| 150 GLint num_pixel_formats = 0; | 151 GLint num_pixel_formats = 0; |
| 151 CGLChoosePixelFormat(attribs, &platform_specific_->discrete_pixel_format, | 152 CGLChoosePixelFormat(attribs, &platform_specific_->discrete_pixel_format, |
| 152 &num_pixel_formats); | 153 &num_pixel_formats); |
| 153 } | 154 } |
| 154 #endif // OS_MACOSX | 155 #endif // OS_MACOSX |
| 155 | 156 |
| 156 } // namespace ui | 157 } // namespace ui |
| OLD | NEW |