Move content_settings_pattern and content_settings_pattern_parser to the content_sett...
[chromium-blink-merge.git] / ui / gl / gpu_switching_manager.h
bloba097d9af681e1b9476bc059b6009d460fdcda72d
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_
8 #include <vector>
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>
16 #endif // OS_MACOSX
18 namespace ui {
20 class GL_EXPORT GpuSwitchingManager {
21 public:
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
32 // the forced GPU.
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);
43 private:
44 friend struct DefaultSingletonTraits<GpuSwitchingManager>;
46 GpuSwitchingManager();
47 virtual ~GpuSwitchingManager();
49 #if defined(OS_MACOSX)
50 void SwitchToDiscreteGpuMac();
52 CGLPixelFormatObj discrete_pixel_format_;
53 #endif // OS_MACOSX
55 gfx::GpuPreference gpu_switching_option_;
56 bool gpu_switching_option_set_;
58 bool supports_dual_gpus_;
59 bool supports_dual_gpus_set_;
61 size_t gpu_count_;
63 DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager);
66 } // namespace ui
68 #endif // UI_GL_GPU_SWITCHING_MANAGER_H_