Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: content/browser/gpu/gpu_blacklist.h

Issue 7633038: Relax software rendering list parsing. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BLACKLIST_H_ 5 #ifndef CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_
6 #define CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ 6 #define CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h" 16 #include "base/values.h"
15 #include "content/common/gpu/gpu_feature_flags.h" 17 #include "content/common/gpu/gpu_feature_flags.h"
16 18
17 class Version; 19 class Version;
18 struct GPUInfo; 20 struct GPUInfo;
19 21
20 namespace base { 22 namespace base {
21 class DictionaryValue; 23 class DictionaryValue;
22 } 24 }
23 25
24 class GpuBlacklist { 26 class GpuBlacklist {
25 public: 27 public:
26 enum OsType { 28 enum OsType {
27 kOsLinux, 29 kOsLinux,
28 kOsMacosx, 30 kOsMacosx,
29 kOsWin, 31 kOsWin,
30 kOsChromeOS, 32 kOsChromeOS,
31 kOsAny, 33 kOsAny,
32 kOsUnknown 34 kOsUnknown
33 }; 35 };
34 36
37 enum OsFilter {
38 // In loading, Ignore all entries that belong to other OS.
vangelis 2011/08/24 19:00:17 typo: Ignore->ignore
Zhenyao Mo 2011/08/24 22:29:57 Done.
39 kCurrentOsOnly,
40 // In loading, keep all entries. This is for testing only.
41 kAllOs
42 };
43
35 explicit GpuBlacklist(const std::string& browser_version_string); 44 explicit GpuBlacklist(const std::string& browser_version_string);
36 ~GpuBlacklist(); 45 ~GpuBlacklist();
37 46
38 // Loads blacklist information from a json file. 47 // Loads blacklist information from a json file.
39 // current_os_only==true indicates all blacklist entries that don't belong to
40 // the current OS are discarded; current_os_only==false should only be used
41 // for testing purpose.
42 // If failed, the current GpuBlacklist is un-touched. 48 // If failed, the current GpuBlacklist is un-touched.
43 bool LoadGpuBlacklist(const std::string& json_context, 49 bool LoadGpuBlacklist(const std::string& json_context, OsFilter os_filter);
44 bool current_os_only);
45 bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, 50 bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json,
46 bool current_os_only); 51 OsFilter os_filter);
47 52
48 // Collects system information and combines them with gpu_info and blacklist 53 // Collects system information and combines them with gpu_info and blacklist
49 // information to determine gpu feature flags. 54 // information to determine gpu feature flags.
50 // If os is kOsAny, use the current OS; if os_version is null, use the 55 // If os is kOsAny, use the current OS; if os_version is null, use the
51 // current OS version. 56 // current OS version.
52 GpuFeatureFlags DetermineGpuFeatureFlags(OsType os, 57 GpuFeatureFlags DetermineGpuFeatureFlags(OsType os,
53 Version* os_version, 58 Version* os_version,
54 const GPUInfo& gpu_info); 59 const GPUInfo& gpu_info);
55 60
56 // Collects the entries that set the "feature" flag from the last 61 // Collects the entries that set the "feature" flag from the last
57 // DetermineGpuFeatureFlags() call. This tells which entries are responsible 62 // DetermineGpuFeatureFlags() call. This tells which entries are responsible
58 // for raising a certain flag, i.e, for blacklisting a certain feature. 63 // for raising a certain flag, i.e, for blacklisting a certain feature.
59 // Examples of "feature": 64 // Examples of "feature":
60 // kGpuFeatureAll - any of the supported features; 65 // kGpuFeatureAll - any of the supported features;
61 // kGpuFeatureWebgl - a single feature; 66 // kGpuFeatureWebgl - a single feature;
62 // kGpuFeatureWebgl | kGpuFeatureAcceleratedCompositing - two features. 67 // kGpuFeatureWebgl | kGpuFeatureAcceleratedCompositing - two features.
63 void GetGpuFeatureFlagEntries(GpuFeatureFlags::GpuFeatureType feature, 68 void GetGpuFeatureFlagEntries(GpuFeatureFlags::GpuFeatureType feature,
64 std::vector<uint32>& entry_ids) const; 69 std::vector<uint32>& entry_ids) const;
65 70
66
67 // Returns status information on the blacklist. This is two parted: 71 // Returns status information on the blacklist. This is two parted:
68 // { 72 // {
69 // featureStatus: [] 73 // featureStatus: []
70 // problems: [] 74 // problems: []
71 // } 75 // }
72 // 76 //
73 // Each entry in feature_status has: 77 // Each entry in feature_status has:
74 // { 78 // {
75 // name: "name of feature" 79 // name: "name of feature"
76 // status: "enabled" | "unavailable_software" | "unavailable_off" | 80 // status: "enabled" | "unavailable_software" | "unavailable_off" |
(...skipping 25 matching lines...) Expand all
102 // Collects the version of the current blacklist. Returns false and sets 106 // Collects the version of the current blacklist. Returns false and sets
103 // major and minor to 0 on failure. 107 // major and minor to 0 on failure.
104 bool GetVersion(uint16* major, uint16* monir) const; 108 bool GetVersion(uint16* major, uint16* monir) const;
105 109
106 // Collects the version of the current blacklist from a parsed json file. 110 // Collects the version of the current blacklist from a parsed json file.
107 // Returns false and sets major and minor to 0 on failure. 111 // Returns false and sets major and minor to 0 on failure.
108 static bool GetVersion( 112 static bool GetVersion(
109 const base::DictionaryValue& parsed_json, uint16* major, uint16* minor); 113 const base::DictionaryValue& parsed_json, uint16* major, uint16* minor);
110 114
111 private: 115 private:
116 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, CurrentBlacklistValidation);
117 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownField);
118 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownExceptionField);
119 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownFeature);
120
112 class VersionInfo { 121 class VersionInfo {
113 public: 122 public:
114 VersionInfo(const std::string& version_op, 123 VersionInfo(const std::string& version_op,
115 const std::string& version_string, 124 const std::string& version_string,
116 const std::string& version_string2); 125 const std::string& version_string2);
117 ~VersionInfo(); 126 ~VersionInfo();
118 127
119 // Determines if a given version is included in the VersionInfo range. 128 // Determines if a given version is included in the VersionInfo range.
120 bool Contains(const Version& version) const; 129 bool Contains(const Version& version) const;
121 130
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 kUnknown // Indicates StringInfo data is invalid. 194 kUnknown // Indicates StringInfo data is invalid.
186 }; 195 };
187 196
188 // Maps string to Op; returns kUnknown if it's not a valid Op. 197 // Maps string to Op; returns kUnknown if it's not a valid Op.
189 static Op StringToOp(const std::string& string_op); 198 static Op StringToOp(const std::string& string_op);
190 199
191 Op op_; 200 Op op_;
192 std::string value_; 201 std::string value_;
193 }; 202 };
194 203
195 class GpuBlacklistEntry { 204 class GpuBlacklistEntry;
205 typedef scoped_refptr<GpuBlacklistEntry> ScopedGpuBlacklistEntry;
206
207 class GpuBlacklistEntry : public base::RefCounted<GpuBlacklistEntry> {
196 public: 208 public:
197 // Constructs GpuBlacklistEntry from DictionaryValue loaded from json. 209 // Constructs GpuBlacklistEntry from DictionaryValue loaded from json.
198 // Top-level entry must have an id number. Others are exceptions. 210 // Top-level entry must have an id number. Others are exceptions.
199 static GpuBlacklistEntry* GetGpuBlacklistEntryFromValue( 211 static GpuBlacklistEntry* GetGpuBlacklistEntryFromValue(
200 base::DictionaryValue* value, bool top_level); 212 base::DictionaryValue* value, bool top_level);
201 213
202 // Determines if a given os/gc/driver is included in the Entry set. 214 // Determines if a given os/gc/driver is included in the Entry set.
203 bool Contains(OsType os_type, 215 bool Contains(OsType os_type,
204 const Version& os_version, 216 const Version& os_version,
205 const GPUInfo& gpu_info) const; 217 const GPUInfo& gpu_info) const;
206 218
207 // Returns the OsType. 219 // Returns the OsType.
208 OsType GetOsType() const; 220 OsType GetOsType() const;
209 221
210 // Returns the entry's unique id. 0 is reserved. 222 // Returns the entry's unique id. 0 is reserved.
211 uint32 id() const; 223 uint32 id() const;
212 224
213 // Returns the description of the entry 225 // Returns the description of the entry
214 const std::string& description() const { return description_; } 226 const std::string& description() const { return description_; }
215 227
216 // Returs a list of Chromium and Webkit bugs applicable to this entry 228 // Returns a list of Chromium and Webkit bugs applicable to this entry
217 const std::vector<int>& cr_bugs() const { return cr_bugs_; } 229 const std::vector<int>& cr_bugs() const { return cr_bugs_; }
218 const std::vector<int>& webkit_bugs() const { return webkit_bugs_; } 230 const std::vector<int>& webkit_bugs() const { return webkit_bugs_; }
219 231
220 // Returns the GpuFeatureFlags. 232 // Returns the GpuFeatureFlags.
221 GpuFeatureFlags GetGpuFeatureFlags() const; 233 GpuFeatureFlags GetGpuFeatureFlags() const;
222 234
223 ~GpuBlacklistEntry(); 235 // Returns true if an unknown filed of an unknown blacklist feature
vangelis 2011/08/24 19:00:17 typo: filed -> field
Zhenyao Mo 2011/08/24 22:29:57 Done.
236 // is encountered.
237 bool contains_unknown_fields() const {
238 return contains_unknown_fields_;
239 }
240 // Returns true if an exception contains an unknown field.
241 bool contains_exceptions_with_unknown_fields() const {
242 return contains_exceptions_with_unknown_fields_;
243 }
224 244
225 private: 245 private:
246 friend class base::RefCounted<GpuBlacklistEntry>;
247
226 GpuBlacklistEntry(); 248 GpuBlacklistEntry();
249 ~GpuBlacklistEntry() { }
227 250
228 bool SetId(uint32 id); 251 bool SetId(uint32 id);
229 252
230 bool SetOsInfo(const std::string& os, 253 bool SetOsInfo(const std::string& os,
231 const std::string& version_op, 254 const std::string& version_op,
232 const std::string& version_string, 255 const std::string& version_string,
233 const std::string& version_string2); 256 const std::string& version_string2);
234 257
235 bool SetVendorId(const std::string& vendor_id_string); 258 bool SetVendorId(const std::string& vendor_id_string);
236 259
(...skipping 23 matching lines...) Expand all
260 std::vector<int> cr_bugs_; 283 std::vector<int> cr_bugs_;
261 std::vector<int> webkit_bugs_; 284 std::vector<int> webkit_bugs_;
262 scoped_ptr<OsInfo> os_info_; 285 scoped_ptr<OsInfo> os_info_;
263 uint32 vendor_id_; 286 uint32 vendor_id_;
264 std::vector<uint32> device_id_list_; 287 std::vector<uint32> device_id_list_;
265 scoped_ptr<StringInfo> driver_vendor_info_; 288 scoped_ptr<StringInfo> driver_vendor_info_;
266 scoped_ptr<VersionInfo> driver_version_info_; 289 scoped_ptr<VersionInfo> driver_version_info_;
267 scoped_ptr<VersionInfo> driver_date_info_; 290 scoped_ptr<VersionInfo> driver_date_info_;
268 scoped_ptr<StringInfo> gl_renderer_info_; 291 scoped_ptr<StringInfo> gl_renderer_info_;
269 scoped_ptr<GpuFeatureFlags> feature_flags_; 292 scoped_ptr<GpuFeatureFlags> feature_flags_;
270 std::vector<GpuBlacklistEntry*> exceptions_; 293 std::vector<ScopedGpuBlacklistEntry> exceptions_;
294 bool contains_unknown_fields_;
295 bool contains_exceptions_with_unknown_fields_;
271 }; 296 };
272 297
273 enum BrowserVersionSupport { 298 enum BrowserVersionSupport {
274 kSupported, 299 kSupported,
275 kUnsupported, 300 kUnsupported,
276 kMalformed 301 kMalformed
277 }; 302 };
278 303
279 // Gets the current OS type. 304 // Gets the current OS type.
280 static OsType GetOsType(); 305 static OsType GetOsType();
281 306
282 void Clear(); 307 void Clear();
283 308
284 bool IsFeatureBlacklisted(GpuFeatureFlags::GpuFeatureType feature) const; 309 bool IsFeatureBlacklisted(GpuFeatureFlags::GpuFeatureType feature) const;
285 310
286 // Check if the entry is supported by the current version of browser. 311 // Check if the entry is supported by the current version of browser.
287 // By default, if there is no browser version information in the entry, 312 // By default, if there is no browser version information in the entry,
288 // return kSupported; 313 // return kSupported;
289 BrowserVersionSupport IsEntrySupportedByCurrentBrowserVersion( 314 BrowserVersionSupport IsEntrySupportedByCurrentBrowserVersion(
290 base::DictionaryValue* value); 315 base::DictionaryValue* value);
291 316
317 // Returns the number of entries. This is only for tests.
318 size_t num_entries() const;
319
320 // Check if any entries contain unknown field. This is only for tests.
321 bool contains_unknown_fields() const { return contains_unknown_fields_; }
322
292 scoped_ptr<Version> version_; 323 scoped_ptr<Version> version_;
293 std::vector<GpuBlacklistEntry*> blacklist_; 324 std::vector<ScopedGpuBlacklistEntry> blacklist_;
294 325
295 scoped_ptr<Version> browser_version_; 326 scoped_ptr<Version> browser_version_;
296 327
297 // This records all the blacklist entries that are appliable to the current 328 // This records all the blacklist entries that are appliable to the current
298 // user machine. It is updated everytime DetermineGpuFeatureFlags() is 329 // user machine. It is updated everytime DetermineGpuFeatureFlags() is
299 // called and is used later by GetGpuFeatureFlagEntries(). 330 // called and is used later by GetGpuFeatureFlagEntries().
300 std::vector<GpuBlacklistEntry*> active_entries_; 331 std::vector<ScopedGpuBlacklistEntry> active_entries_;
301 332
302 uint32 max_entry_id_; 333 uint32 max_entry_id_;
303 334
335 bool contains_unknown_fields_;
336
304 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); 337 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist);
305 }; 338 };
306 339
307 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ 340 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698