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