| 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 #ifndef UI_GL_GPU_SWITCHING_MANAGER_H_ | 5 #ifndef UI_GL_GPU_SWITCHING_MANAGER_H_ |
| 6 #define UI_GL_GPU_SWITCHING_MANAGER_H_ | 6 #define UI_GL_GPU_SWITCHING_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #if defined(OS_MACOSX) |
| 12 #include "ui/gl/gl_context_cgl.h" |
| 13 #endif // OS_MACOSX |
| 11 #include "ui/gl/gl_export.h" | 14 #include "ui/gl/gl_export.h" |
| 12 #include "ui/gl/gpu_preference.h" | 15 #include "ui/gl/gpu_preference.h" |
| 13 | 16 |
| 14 namespace gfx { | 17 namespace gfx { |
| 15 | 18 |
| 16 class GL_EXPORT GpuSwitchingManager { | 19 class GL_EXPORT GpuSwitchingManager { |
| 17 public: | 20 public: |
| 18 // Getter for the singleton. This will return NULL on failure. | 21 // Getter for the singleton. This will return NULL on failure. |
| 19 static GpuSwitchingManager* GetInstance(); | 22 static GpuSwitchingManager* GetInstance(); |
| 20 | 23 |
| 21 // Set the switching option, but don't take any actions until later | 24 // Set the switching option, but don't take any actions until later |
| 22 // we access GPU. | 25 // we access GPU. |
| 23 void ForceUseOfIntegratedGpu(); | 26 void ForceUseOfIntegratedGpu(); |
| 24 void ForceUseOfDiscreteGpu(); | 27 void ForceUseOfDiscreteGpu(); |
| 25 | 28 |
| 26 // Adjust GpuPreference based on the current switching option. | 29 // If no GPU is forced, return the original GpuPreference; otherwise, return |
| 27 // If none is set, return the original GpuPreference. | 30 // the forced GPU. |
| 31 // If forcing discrete GPU on Mac, we set up a pixel format, which keeps |
| 32 // Chrome on the discrete GPU throughout the rest of Chrome's lifetime. |
| 28 GpuPreference AdjustGpuPreference(GpuPreference gpu_preference); | 33 GpuPreference AdjustGpuPreference(GpuPreference gpu_preference); |
| 29 | 34 |
| 30 private: | 35 private: |
| 31 friend struct DefaultSingletonTraits<GpuSwitchingManager>; | 36 friend struct DefaultSingletonTraits<GpuSwitchingManager>; |
| 32 | 37 |
| 33 GpuSwitchingManager(); | 38 GpuSwitchingManager(); |
| 34 virtual ~GpuSwitchingManager(); | 39 virtual ~GpuSwitchingManager(); |
| 35 | 40 |
| 36 std::vector<GpuPreference> gpu_switching_option_; | 41 std::vector<GpuPreference> gpu_switching_option_; |
| 37 | 42 |
| 38 DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager); | 43 DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager); |
| 39 }; | 44 }; |
| 40 | 45 |
| 41 } // namespace gfx | 46 } // namespace gfx |
| 42 | 47 |
| 43 #endif // UI_GL_GPU_SWITCHING_MANAGER_H_ | 48 #endif // UI_GL_GPU_SWITCHING_MANAGER_H_ |
| 44 | 49 |
| OLD | NEW |