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 <stdint.h> |
| 9 |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
| 12 #include "base/macros.h" |
10 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
11 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "build/build_config.h" |
12 #include "ui/gl/gl_export.h" | 16 #include "ui/gl/gl_export.h" |
13 #include "ui/gl/gpu_preference.h" | 17 #include "ui/gl/gpu_preference.h" |
14 #include "ui/gl/gpu_switching_observer.h" | 18 #include "ui/gl/gpu_switching_observer.h" |
15 | 19 |
16 namespace ui { | 20 namespace ui { |
17 | 21 |
18 class GL_EXPORT GpuSwitchingManager { | 22 class GL_EXPORT GpuSwitchingManager { |
19 public: | 23 public: |
20 // Getter for the singleton. This will return NULL on failure. | 24 // Getter for the singleton. This will return NULL on failure. |
21 static GpuSwitchingManager* GetInstance(); | 25 static GpuSwitchingManager* GetInstance(); |
22 | 26 |
23 // Set the switching option to PreferIntegratedGpu. | 27 // Set the switching option to PreferIntegratedGpu. |
24 void ForceUseOfIntegratedGpu(); | 28 void ForceUseOfIntegratedGpu(); |
25 // Set the switching option to PreferDiscreteGpu; switch to discrete GPU | 29 // Set the switching option to PreferDiscreteGpu; switch to discrete GPU |
26 // immediately on Mac where dual GPU switching is supported. | 30 // immediately on Mac where dual GPU switching is supported. |
27 void ForceUseOfDiscreteGpu(); | 31 void ForceUseOfDiscreteGpu(); |
28 | 32 |
29 // If no GPU is forced, return the original GpuPreference; otherwise, return | 33 // If no GPU is forced, return the original GpuPreference; otherwise, return |
30 // the forced GPU. | 34 // the forced GPU. |
31 gfx::GpuPreference AdjustGpuPreference(gfx::GpuPreference gpu_preference); | 35 gfx::GpuPreference AdjustGpuPreference(gfx::GpuPreference gpu_preference); |
32 | 36 |
33 // In the browser process, the value for this flag is computed the first time | 37 // In the browser process, the value for this flag is computed the first time |
34 // this function is called. | 38 // this function is called. |
35 // In the GPU process, the value is passed from the browser process using the | 39 // In the GPU process, the value is passed from the browser process using the |
36 // --supports-dual-gpus commandline switch. | 40 // --supports-dual-gpus commandline switch. |
37 bool SupportsDualGpus(); | 41 bool SupportsDualGpus(); |
38 | 42 |
39 // Sets the vendor IDs of the GPUs on the system. The length of this | 43 // Sets the vendor IDs of the GPUs on the system. The length of this |
40 // vector defines the count of GPUs. | 44 // vector defines the count of GPUs. |
41 void SetGpuVendorIds(const std::vector<uint32>& vendor_ids); | 45 void SetGpuVendorIds(const std::vector<uint32_t>& vendor_ids); |
42 | 46 |
43 void AddObserver(GpuSwitchingObserver* observer); | 47 void AddObserver(GpuSwitchingObserver* observer); |
44 void RemoveObserver(GpuSwitchingObserver* observer); | 48 void RemoveObserver(GpuSwitchingObserver* observer); |
45 | 49 |
46 // Called when a GPU switch is noticed by the system. In the browser process | 50 // 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 | 51 // 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 | 52 // 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 | 53 // in the browser process only so that any workarounds or blacklisting can |
50 // be applied there. | 54 // be applied there. |
51 void NotifyGpuSwitched(); | 55 void NotifyGpuSwitched(); |
52 | 56 |
53 private: | 57 private: |
54 friend struct base::DefaultSingletonTraits<GpuSwitchingManager>; | 58 friend struct base::DefaultSingletonTraits<GpuSwitchingManager>; |
55 | 59 |
56 GpuSwitchingManager(); | 60 GpuSwitchingManager(); |
57 virtual ~GpuSwitchingManager(); | 61 virtual ~GpuSwitchingManager(); |
58 | 62 |
59 #if defined(OS_MACOSX) | 63 #if defined(OS_MACOSX) |
60 void SwitchToDiscreteGpuMac(); | 64 void SwitchToDiscreteGpuMac(); |
61 #endif // OS_MACOSX | 65 #endif // OS_MACOSX |
62 | 66 |
63 gfx::GpuPreference gpu_switching_option_; | 67 gfx::GpuPreference gpu_switching_option_; |
64 bool gpu_switching_option_set_; | 68 bool gpu_switching_option_set_; |
65 | 69 |
66 std::vector<uint32> vendor_ids_; | 70 std::vector<uint32_t> vendor_ids_; |
67 | 71 |
68 bool supports_dual_gpus_; | 72 bool supports_dual_gpus_; |
69 bool supports_dual_gpus_set_; | 73 bool supports_dual_gpus_set_; |
70 | 74 |
71 struct PlatformSpecific; | 75 struct PlatformSpecific; |
72 scoped_ptr<PlatformSpecific> platform_specific_; | 76 scoped_ptr<PlatformSpecific> platform_specific_; |
73 | 77 |
74 base::ObserverList<GpuSwitchingObserver> observer_list_; | 78 base::ObserverList<GpuSwitchingObserver> observer_list_; |
75 | 79 |
76 DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager); | 80 DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager); |
77 }; | 81 }; |
78 | 82 |
79 } // namespace ui | 83 } // namespace ui |
80 | 84 |
81 #endif // UI_GL_GPU_SWITCHING_MANAGER_H_ | 85 #endif // UI_GL_GPU_SWITCHING_MANAGER_H_ |
OLD | NEW |