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
3 // found in the LICENSE file.
5 #ifndef UI_GL_GPU_SWITCHING_MANAGER_H_
6 #define UI_GL_GPU_SWITCHING_MANAGER_H_
10 #include "base/memory/singleton.h"
11 #include "ui/gl/gl_export.h"
12 #include "ui/gl/gpu_preference.h"
14 #if defined(OS_MACOSX)
15 #include <OpenGL/OpenGL.h>
20 class GL_EXPORT GpuSwitchingManager
{
22 // Getter for the singleton. This will return NULL on failure.
23 static GpuSwitchingManager
* GetInstance();
25 // Set the switching option to PreferIntegratedGpu.
26 void ForceUseOfIntegratedGpu();
27 // Set the switching option to PreferDiscreteGpu; switch to discrete GPU
28 // immediately on Mac where dual GPU switching is supported.
29 void ForceUseOfDiscreteGpu();
31 // If no GPU is forced, return the original GpuPreference; otherwise, return
33 gfx::GpuPreference
AdjustGpuPreference(gfx::GpuPreference gpu_preference
);
35 // In the browser process, the value for this flag is computed the first time
36 // this function is called.
37 // In the GPU process, the value is passed from the browser process using the
38 // --supports-dual-gpus commandline switch.
39 bool SupportsDualGpus();
41 void SetGpuCount(size_t gpu_count
);
44 friend struct DefaultSingletonTraits
<GpuSwitchingManager
>;
46 GpuSwitchingManager();
47 virtual ~GpuSwitchingManager();
49 #if defined(OS_MACOSX)
50 void SwitchToDiscreteGpuMac();
52 CGLPixelFormatObj discrete_pixel_format_
;
55 gfx::GpuPreference gpu_switching_option_
;
56 bool gpu_switching_option_set_
;
58 bool supports_dual_gpus_
;
59 bool supports_dual_gpus_set_
;
63 DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager
);
68 #endif // UI_GL_GPU_SWITCHING_MANAGER_H_