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 CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
6 #define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ | 6 #define CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
16 #include "base/observer_list_threadsafe.h" | 16 #include "base/observer_list_threadsafe.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "content/browser/gpu/gpu_blacklist.h" | |
20 #include "content/public/browser/gpu_data_manager.h" | 19 #include "content/public/browser/gpu_data_manager.h" |
21 #include "content/public/common/gpu_info.h" | 20 #include "content/public/common/gpu_info.h" |
22 #include "content/public/common/gpu_memory_stats.h" | 21 #include "content/public/common/gpu_memory_stats.h" |
23 | 22 |
24 class CommandLine; | 23 class CommandLine; |
25 | 24 |
26 class CONTENT_EXPORT GpuDataManagerImpl | 25 class CONTENT_EXPORT GpuDataManagerImpl |
27 : public NON_EXPORTED_BASE(content::GpuDataManager) { | 26 : public NON_EXPORTED_BASE(content::GpuDataManager) { |
28 public: | 27 public: |
29 // Getter for the singleton. This will return NULL on failure. | 28 // Getter for the singleton. This will return NULL on failure. |
30 static GpuDataManagerImpl* GetInstance(); | 29 static GpuDataManagerImpl* GetInstance(); |
31 | 30 |
32 // GpuDataManager implementation. | 31 // GpuDataManager implementation. |
33 virtual void Initialize( | 32 virtual void InitializeGpuInfo() OVERRIDE; |
34 const std::string& browser_version_string, | |
35 const std::string& gpu_blacklist_json) OVERRIDE; | |
36 virtual content::GpuFeatureType GetBlacklistedFeatures() const OVERRIDE; | 33 virtual content::GpuFeatureType GetBlacklistedFeatures() const OVERRIDE; |
37 virtual base::ListValue* GetBlacklistReasons() const OVERRIDE; | 34 virtual void SetPreliminaryBlacklistedFeatures( |
38 virtual std::string GetBlacklistVersion() const OVERRIDE; | 35 content::GpuFeatureType features) OVERRIDE; |
39 virtual content::GPUInfo GetGPUInfo() const OVERRIDE; | 36 virtual content::GPUInfo GetGPUInfo() const OVERRIDE; |
40 virtual bool GpuAccessAllowed() const OVERRIDE; | 37 virtual bool GpuAccessAllowed() const OVERRIDE; |
41 virtual void RequestCompleteGpuInfoIfNeeded() OVERRIDE; | 38 virtual void RequestCompleteGpuInfoIfNeeded() OVERRIDE; |
42 virtual bool IsCompleteGpuInfoAvailable() const OVERRIDE; | 39 virtual bool IsCompleteGpuInfoAvailable() const OVERRIDE; |
43 virtual void RequestVideoMemoryUsageStatsUpdate() const OVERRIDE; | 40 virtual void RequestVideoMemoryUsageStatsUpdate() const OVERRIDE; |
44 virtual bool ShouldUseSoftwareRendering() const OVERRIDE; | 41 virtual bool ShouldUseSoftwareRendering() const OVERRIDE; |
45 virtual void RegisterSwiftShaderPath(const FilePath& path) OVERRIDE; | 42 virtual void RegisterSwiftShaderPath(const FilePath& path) OVERRIDE; |
46 virtual void AddLogMessage(int level, const std::string& header, | 43 virtual void AddLogMessage(int level, const std::string& header, |
47 const std::string& message) OVERRIDE; | 44 const std::string& message) OVERRIDE; |
48 virtual base::ListValue* GetLogMessages() const OVERRIDE; | 45 virtual base::ListValue* GetLogMessages() const OVERRIDE; |
49 virtual void AddObserver(content::GpuDataManagerObserver* observer) OVERRIDE; | 46 virtual void AddObserver(content::GpuDataManagerObserver* observer) OVERRIDE; |
50 virtual void RemoveObserver( | 47 virtual void RemoveObserver( |
51 content::GpuDataManagerObserver* observer) OVERRIDE; | 48 content::GpuDataManagerObserver* observer) OVERRIDE; |
52 | 49 |
53 // Only update if the current GPUInfo is not finalized. If blacklist is | 50 // Only update if the current GPUInfo is not finalized. |
54 // loaded, run through blacklist and update blacklisted features. | |
55 void UpdateGpuInfo(const content::GPUInfo& gpu_info); | 51 void UpdateGpuInfo(const content::GPUInfo& gpu_info); |
56 | 52 |
57 void UpdateVideoMemoryUsageStats( | 53 void UpdateVideoMemoryUsageStats( |
58 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats); | 54 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats); |
59 | 55 |
60 // Insert disable-feature switches corresponding to preliminary gpu feature | 56 // Insert disable-feature switches corresponding to preliminary gpu feature |
61 // flags into the renderer process command line. | 57 // flags into the renderer process command line. |
62 void AppendRendererCommandLine(CommandLine* command_line) const; | 58 void AppendRendererCommandLine(CommandLine* command_line) const; |
63 | 59 |
64 // Insert switches into gpu process command line: kUseGL, | 60 // Insert switches into gpu process command line: kUseGL, |
(...skipping 23 matching lines...) Expand all Loading... |
88 | 84 |
89 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuSideBlacklisting); | 85 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuSideBlacklisting); |
90 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, BlacklistCard); | 86 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, BlacklistCard); |
91 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuInfoUpdate); | 87 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, GpuInfoUpdate); |
92 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, | 88 FRIEND_TEST_ALL_PREFIXES(GpuDataManagerImplTest, |
93 GPUVideoMemoryUsageStatsUpdate); | 89 GPUVideoMemoryUsageStatsUpdate); |
94 | 90 |
95 GpuDataManagerImpl(); | 91 GpuDataManagerImpl(); |
96 virtual ~GpuDataManagerImpl(); | 92 virtual ~GpuDataManagerImpl(); |
97 | 93 |
| 94 // If flags hasn't been set and GPUInfo is available, run through blacklist |
| 95 // and compute the flags. |
98 void UpdateBlacklistedFeatures(content::GpuFeatureType features); | 96 void UpdateBlacklistedFeatures(content::GpuFeatureType features); |
99 | 97 |
100 // This should only be called once at initialization time, when preliminary | |
101 // gpu info is collected. | |
102 void UpdatePreliminaryBlacklistedFeatures(); | |
103 | |
104 // Notify all observers whenever there is a GPU info update. | 98 // Notify all observers whenever there is a GPU info update. |
105 void NotifyGpuInfoUpdate(); | 99 void NotifyGpuInfoUpdate(); |
106 | 100 |
107 // Try to switch to software rendering, if possible and necessary. | 101 // Try to switch to software rendering, if possible and necessary. |
108 void EnableSoftwareRenderingIfNecessary(); | 102 void EnableSoftwareRenderingIfNecessary(); |
109 | 103 |
110 // Send UMA histograms about the disabled/enabled features. | |
111 void UpdateStats(); | |
112 | |
113 bool complete_gpu_info_already_requested_; | 104 bool complete_gpu_info_already_requested_; |
114 | 105 |
115 content::GpuFeatureType gpu_feature_type_; | 106 content::GpuFeatureType gpu_feature_type_; |
116 content::GpuFeatureType preliminary_gpu_feature_type_; | 107 content::GpuFeatureType preliminary_gpu_feature_type_; |
117 | 108 |
118 content::GPUInfo gpu_info_; | 109 content::GPUInfo gpu_info_; |
119 mutable base::Lock gpu_info_lock_; | 110 mutable base::Lock gpu_info_lock_; |
120 | 111 |
121 scoped_ptr<GpuBlacklist> gpu_blacklist_; | |
122 | |
123 const scoped_refptr<GpuDataManagerObserverList> observer_list_; | 112 const scoped_refptr<GpuDataManagerObserverList> observer_list_; |
124 | 113 |
125 ListValue log_messages_; | 114 ListValue log_messages_; |
126 mutable base::Lock log_messages_lock_; | 115 mutable base::Lock log_messages_lock_; |
127 | 116 |
128 bool software_rendering_; | 117 bool software_rendering_; |
129 | 118 |
130 FilePath swiftshader_path_; | 119 FilePath swiftshader_path_; |
131 | 120 |
132 // Current card force-blacklisted due to GPU crashes, or disabled through | 121 // Current card force-blacklisted due to GPU crashes, or disabled through |
133 // the --disable-gpu commandline switch. | 122 // the --disable-gpu commandline switch. |
134 bool card_blacklisted_; | 123 bool card_blacklisted_; |
135 | 124 |
136 DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl); | 125 DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl); |
137 }; | 126 }; |
138 | 127 |
139 #endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ | 128 #endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_IMPL_H_ |
OLD | NEW |