Add ICU message format support
[chromium-blink-merge.git] / ui / gl / gpu_switching_manager.h
blobba60945ea28ff8fa2e42cbcd2a90a2c2e94b8773
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 "base/observer_list.h"
12 #include "ui/gl/gl_export.h"
13 #include "ui/gl/gpu_preference.h"
14 #include "ui/gl/gpu_switching_observer.h"
16 namespace ui {
18 class GL_EXPORT GpuSwitchingManager {
19 public:
20 // Getter for the singleton. This will return NULL on failure.
21 static GpuSwitchingManager* GetInstance();
23 // Set the switching option to PreferIntegratedGpu.
24 void ForceUseOfIntegratedGpu();
25 // Set the switching option to PreferDiscreteGpu; switch to discrete GPU
26 // immediately on Mac where dual GPU switching is supported.
27 void ForceUseOfDiscreteGpu();
29 // If no GPU is forced, return the original GpuPreference; otherwise, return
30 // the forced GPU.
31 gfx::GpuPreference AdjustGpuPreference(gfx::GpuPreference gpu_preference);
33 // In the browser process, the value for this flag is computed the first time
34 // this function is called.
35 // In the GPU process, the value is passed from the browser process using the
36 // --supports-dual-gpus commandline switch.
37 bool SupportsDualGpus();
39 // Sets the vendor IDs of the GPUs on the system. The length of this
40 // vector defines the count of GPUs.
41 void SetGpuVendorIds(const std::vector<uint32>& vendor_ids);
43 void AddObserver(GpuSwitchingObserver* observer);
44 void RemoveObserver(GpuSwitchingObserver* observer);
46 // Called when a GPU switch is noticed by the system. In the browser process
47 // this is occurs as a result of a system observer. In the GPU process, this
48 // occurs as a result of an IPC from the browser. The system observer is kept
49 // in the browser process only so that any workarounds or blacklisting can
50 // be applied there.
51 void NotifyGpuSwitched();
53 private:
54 friend struct DefaultSingletonTraits<GpuSwitchingManager>;
56 GpuSwitchingManager();
57 virtual ~GpuSwitchingManager();
59 #if defined(OS_MACOSX)
60 void SwitchToDiscreteGpuMac();
61 #endif // OS_MACOSX
63 gfx::GpuPreference gpu_switching_option_;
64 bool gpu_switching_option_set_;
66 std::vector<uint32> vendor_ids_;
68 bool supports_dual_gpus_;
69 bool supports_dual_gpus_set_;
71 struct PlatformSpecific;
72 scoped_ptr<PlatformSpecific> platform_specific_;
74 base::ObserverList<GpuSwitchingObserver> observer_list_;
76 DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager);
79 } // namespace ui
81 #endif // UI_GL_GPU_SWITCHING_MANAGER_H_