| OLD | NEW |
| 1 // Copyright (c) 2012 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 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownField); | 103 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownField); |
| 104 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownExceptionField); | 104 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownExceptionField); |
| 105 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownFeature); | 105 FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownFeature); |
| 106 | 106 |
| 107 enum BrowserVersionSupport { | 107 enum BrowserVersionSupport { |
| 108 kSupported, | 108 kSupported, |
| 109 kUnsupported, | 109 kUnsupported, |
| 110 kMalformed | 110 kMalformed |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 enum NumericOp { | |
| 114 kBetween, // <= * <= | |
| 115 kEQ, // = | |
| 116 kLT, // < | |
| 117 kLE, // <= | |
| 118 kGT, // > | |
| 119 kGE, // >= | |
| 120 kAny, | |
| 121 kUnknown // Indicates the data is invalid. | |
| 122 }; | |
| 123 | |
| 124 class VersionInfo { | 113 class VersionInfo { |
| 125 public: | 114 public: |
| 126 VersionInfo(const std::string& version_op, | 115 VersionInfo(const std::string& version_op, |
| 127 const std::string& version_string, | 116 const std::string& version_string, |
| 128 const std::string& version_string2); | 117 const std::string& version_string2); |
| 129 ~VersionInfo(); | 118 ~VersionInfo(); |
| 130 | 119 |
| 131 // Determines if a given version is included in the VersionInfo range. | 120 // Determines if a given version is included in the VersionInfo range. |
| 132 bool Contains(const Version& version) const; | 121 bool Contains(const Version& version) const; |
| 133 | 122 |
| 134 // Determines if the VersionInfo contains valid information. | 123 // Determines if the VersionInfo contains valid information. |
| 135 bool IsValid() const; | 124 bool IsValid() const; |
| 136 | 125 |
| 137 private: | 126 private: |
| 138 NumericOp op_; | 127 enum Op { |
| 128 kBetween, // <= * <= |
| 129 kEQ, // = |
| 130 kLT, // < |
| 131 kLE, // <= |
| 132 kGT, // > |
| 133 kGE, // >= |
| 134 kAny, |
| 135 kUnknown // Indicates VersionInfo data is invalid. |
| 136 }; |
| 137 |
| 138 // Maps string to Op; returns kUnknown if it's not a valid Op. |
| 139 static Op StringToOp(const std::string& version_op); |
| 140 |
| 141 Op op_; |
| 139 scoped_ptr<Version> version_; | 142 scoped_ptr<Version> version_; |
| 140 scoped_ptr<Version> version2_; | 143 scoped_ptr<Version> version2_; |
| 141 }; | 144 }; |
| 142 | 145 |
| 143 class OsInfo { | 146 class OsInfo { |
| 144 public: | 147 public: |
| 145 OsInfo(const std::string& os, | 148 OsInfo(const std::string& os, |
| 146 const std::string& version_op, | 149 const std::string& version_op, |
| 147 const std::string& version_string, | 150 const std::string& version_string, |
| 148 const std::string& version_string2); | 151 const std::string& version_string2); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 kUnknown // Indicates StringInfo data is invalid. | 186 kUnknown // Indicates StringInfo data is invalid. |
| 184 }; | 187 }; |
| 185 | 188 |
| 186 // Maps string to Op; returns kUnknown if it's not a valid Op. | 189 // Maps string to Op; returns kUnknown if it's not a valid Op. |
| 187 static Op StringToOp(const std::string& string_op); | 190 static Op StringToOp(const std::string& string_op); |
| 188 | 191 |
| 189 Op op_; | 192 Op op_; |
| 190 std::string value_; | 193 std::string value_; |
| 191 }; | 194 }; |
| 192 | 195 |
| 193 class FloatInfo { | |
| 194 public: | |
| 195 FloatInfo(const std::string& float_op, | |
| 196 const std::string& float_value, | |
| 197 const std::string& float_value2); | |
| 198 | |
| 199 // Determines if a given float is included in the FloatInfo. | |
| 200 bool Contains(float value) const; | |
| 201 | |
| 202 // Determines if the FloatInfo contains valid information. | |
| 203 bool IsValid() const; | |
| 204 | |
| 205 private: | |
| 206 NumericOp op_; | |
| 207 float value_; | |
| 208 float value2_; | |
| 209 }; | |
| 210 | |
| 211 class GpuBlacklistEntry; | 196 class GpuBlacklistEntry; |
| 212 typedef scoped_refptr<GpuBlacklistEntry> ScopedGpuBlacklistEntry; | 197 typedef scoped_refptr<GpuBlacklistEntry> ScopedGpuBlacklistEntry; |
| 213 | 198 |
| 214 class GpuBlacklistEntry : public base::RefCounted<GpuBlacklistEntry> { | 199 class GpuBlacklistEntry : public base::RefCounted<GpuBlacklistEntry> { |
| 215 public: | 200 public: |
| 216 // Constructs GpuBlacklistEntry from DictionaryValue loaded from json. | 201 // Constructs GpuBlacklistEntry from DictionaryValue loaded from json. |
| 217 // Top-level entry must have an id number. Others are exceptions. | 202 // Top-level entry must have an id number. Others are exceptions. |
| 218 static ScopedGpuBlacklistEntry GetGpuBlacklistEntryFromValue( | 203 static ScopedGpuBlacklistEntry GetGpuBlacklistEntryFromValue( |
| 219 base::DictionaryValue* value, bool top_level); | 204 base::DictionaryValue* value, bool top_level); |
| 220 | 205 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 bool SetDriverDateInfo(const std::string& date_op, | 265 bool SetDriverDateInfo(const std::string& date_op, |
| 281 const std::string& date_string, | 266 const std::string& date_string, |
| 282 const std::string& date_string2); | 267 const std::string& date_string2); |
| 283 | 268 |
| 284 bool SetGLVendorInfo(const std::string& vendor_op, | 269 bool SetGLVendorInfo(const std::string& vendor_op, |
| 285 const std::string& vendor_value); | 270 const std::string& vendor_value); |
| 286 | 271 |
| 287 bool SetGLRendererInfo(const std::string& renderer_op, | 272 bool SetGLRendererInfo(const std::string& renderer_op, |
| 288 const std::string& renderer_value); | 273 const std::string& renderer_value); |
| 289 | 274 |
| 290 bool SetPerfGraphicsInfo(const std::string& op, | |
| 291 const std::string& float_string, | |
| 292 const std::string& float_string2); | |
| 293 | |
| 294 bool SetPerfGamingInfo(const std::string& op, | |
| 295 const std::string& float_string, | |
| 296 const std::string& float_string2); | |
| 297 | |
| 298 bool SetPerfOverallInfo(const std::string& op, | |
| 299 const std::string& float_string, | |
| 300 const std::string& float_string2); | |
| 301 | |
| 302 bool SetBlacklistedFeatures( | 275 bool SetBlacklistedFeatures( |
| 303 const std::vector<std::string>& blacklisted_features); | 276 const std::vector<std::string>& blacklisted_features); |
| 304 | 277 |
| 305 void AddException(ScopedGpuBlacklistEntry exception); | 278 void AddException(ScopedGpuBlacklistEntry exception); |
| 306 | 279 |
| 307 uint32 id_; | 280 uint32 id_; |
| 308 bool disabled_; | 281 bool disabled_; |
| 309 std::string description_; | 282 std::string description_; |
| 310 std::vector<int> cr_bugs_; | 283 std::vector<int> cr_bugs_; |
| 311 std::vector<int> webkit_bugs_; | 284 std::vector<int> webkit_bugs_; |
| 312 scoped_ptr<OsInfo> os_info_; | 285 scoped_ptr<OsInfo> os_info_; |
| 313 uint32 vendor_id_; | 286 uint32 vendor_id_; |
| 314 std::vector<uint32> device_id_list_; | 287 std::vector<uint32> device_id_list_; |
| 315 scoped_ptr<StringInfo> driver_vendor_info_; | 288 scoped_ptr<StringInfo> driver_vendor_info_; |
| 316 scoped_ptr<VersionInfo> driver_version_info_; | 289 scoped_ptr<VersionInfo> driver_version_info_; |
| 317 scoped_ptr<VersionInfo> driver_date_info_; | 290 scoped_ptr<VersionInfo> driver_date_info_; |
| 318 scoped_ptr<StringInfo> gl_vendor_info_; | 291 scoped_ptr<StringInfo> gl_vendor_info_; |
| 319 scoped_ptr<StringInfo> gl_renderer_info_; | 292 scoped_ptr<StringInfo> gl_renderer_info_; |
| 320 scoped_ptr<FloatInfo> perf_graphics_info_; | |
| 321 scoped_ptr<FloatInfo> perf_gaming_info_; | |
| 322 scoped_ptr<FloatInfo> perf_overall_info_; | |
| 323 scoped_ptr<GpuFeatureFlags> feature_flags_; | 293 scoped_ptr<GpuFeatureFlags> feature_flags_; |
| 324 std::vector<ScopedGpuBlacklistEntry> exceptions_; | 294 std::vector<ScopedGpuBlacklistEntry> exceptions_; |
| 325 bool contains_unknown_fields_; | 295 bool contains_unknown_fields_; |
| 326 bool contains_unknown_features_; | 296 bool contains_unknown_features_; |
| 327 }; | 297 }; |
| 328 | 298 |
| 329 // Gets the current OS type. | 299 // Gets the current OS type. |
| 330 static OsType GetOsType(); | 300 static OsType GetOsType(); |
| 331 | 301 |
| 332 void Clear(); | 302 void Clear(); |
| 333 | 303 |
| 334 // Check if the entry is supported by the current version of browser. | 304 // Check if the entry is supported by the current version of browser. |
| 335 // By default, if there is no browser version information in the entry, | 305 // By default, if there is no browser version information in the entry, |
| 336 // return kSupported; | 306 // return kSupported; |
| 337 BrowserVersionSupport IsEntrySupportedByCurrentBrowserVersion( | 307 BrowserVersionSupport IsEntrySupportedByCurrentBrowserVersion( |
| 338 base::DictionaryValue* value); | 308 base::DictionaryValue* value); |
| 339 | 309 |
| 340 // Returns the number of entries. This is only for tests. | 310 // Returns the number of entries. This is only for tests. |
| 341 size_t num_entries() const; | 311 size_t num_entries() const; |
| 342 | 312 |
| 343 // Check if any entries contain unknown fields. This is only for tests. | 313 // Check if any entries contain unknown fields. This is only for tests. |
| 344 bool contains_unknown_fields() const { return contains_unknown_fields_; } | 314 bool contains_unknown_fields() const { return contains_unknown_fields_; } |
| 345 | 315 |
| 346 void SetBrowserVersion(const std::string& version_string); | 316 void SetBrowserVersion(const std::string& version_string); |
| 347 | 317 |
| 348 static NumericOp StringToNumericOp(const std::string& op); | |
| 349 | |
| 350 scoped_ptr<Version> version_; | 318 scoped_ptr<Version> version_; |
| 351 std::vector<ScopedGpuBlacklistEntry> blacklist_; | 319 std::vector<ScopedGpuBlacklistEntry> blacklist_; |
| 352 | 320 |
| 353 scoped_ptr<Version> browser_version_; | 321 scoped_ptr<Version> browser_version_; |
| 354 | 322 |
| 355 // This records all the blacklist entries that are appliable to the current | 323 // This records all the blacklist entries that are appliable to the current |
| 356 // user machine. It is updated everytime DetermineGpuFeatureFlags() is | 324 // user machine. It is updated everytime DetermineGpuFeatureFlags() is |
| 357 // called and is used later by GetGpuFeatureFlagEntries(). | 325 // called and is used later by GetGpuFeatureFlagEntries(). |
| 358 std::vector<ScopedGpuBlacklistEntry> active_entries_; | 326 std::vector<ScopedGpuBlacklistEntry> active_entries_; |
| 359 | 327 |
| 360 uint32 max_entry_id_; | 328 uint32 max_entry_id_; |
| 361 | 329 |
| 362 bool contains_unknown_fields_; | 330 bool contains_unknown_fields_; |
| 363 | 331 |
| 364 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); | 332 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); |
| 365 }; | 333 }; |
| 366 | 334 |
| 367 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ | 335 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ |
| OLD | NEW |