Chromium Code Reviews| 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_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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 kOsUnknown | 34 kOsUnknown |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 enum OsFilter { | 37 enum OsFilter { |
| 38 // In loading, ignore all entries that belong to other OS. | 38 // In loading, ignore all entries that belong to other OS. |
| 39 kCurrentOsOnly, | 39 kCurrentOsOnly, |
| 40 // In loading, keep all entries. This is for testing only. | 40 // In loading, keep all entries. This is for testing only. |
| 41 kAllOs | 41 kAllOs |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 struct Decision { | |
| 45 content::GpuFeatureType blacklisted_features; | |
| 46 content::GpuSwitchingOption gpu_switching; | |
| 47 | |
| 48 Decision() | |
| 49 : blacklisted_features(content::GPU_FEATURE_TYPE_UNKNOWN), | |
| 50 gpu_switching(content::GPU_SWITCHING_AUTOMATIC) { | |
| 51 } | |
| 52 }; | |
| 53 | |
| 44 GpuBlacklist(); | 54 GpuBlacklist(); |
| 45 virtual ~GpuBlacklist(); | 55 virtual ~GpuBlacklist(); |
| 46 | 56 |
| 47 // Loads blacklist information from a json file. | 57 // Loads blacklist information from a json file. |
| 48 // If failed, the current GpuBlacklist is un-touched. | 58 // If failed, the current GpuBlacklist is un-touched. |
| 49 bool LoadGpuBlacklist(const std::string& json_context, OsFilter os_filter); | 59 bool LoadGpuBlacklist(const std::string& json_context, OsFilter os_filter); |
| 50 bool LoadGpuBlacklist(const std::string& browser_version_string, | 60 bool LoadGpuBlacklist(const std::string& browser_version_string, |
| 51 const std::string& json_context, | 61 const std::string& json_context, |
| 52 OsFilter os_filter); | 62 OsFilter os_filter); |
| 53 | 63 |
| 54 // Collects system information and combines them with gpu_info and blacklist | 64 // Collects system information and combines them with gpu_info and blacklist |
| 55 // information to determine gpu feature flags. | 65 // information to make the blacklist decision. |
| 56 // If os is kOsAny, use the current OS; if os_version is null, use the | 66 // If os is kOsAny, use the current OS; if os_version is null, use the |
| 57 // current OS version. | 67 // current OS version. |
| 58 content::GpuFeatureType DetermineGpuFeatureType( | 68 Decision MakeBlacklistDecision( |
|
Ken Russell (switch to Gerrit)
2012/09/12 01:59:04
Thank you for renaming this. The old name was very
| |
| 59 OsType os, Version* os_version, const content::GPUInfo& gpu_info); | 69 OsType os, Version* os_version, const content::GPUInfo& gpu_info); |
| 60 | 70 |
| 61 // Collects the active entries that set the "feature" flag from the last | 71 // Collects the active entries from the last MakeBlacklistDecision() call. |
| 62 // DetermineGpuFeatureType() call. This tells which entries are responsible | |
| 63 // for raising a certain flag, i.e, for blacklisting a certain feature. | |
| 64 // Examples of "feature": | |
| 65 // GPU_FEATURE_TYPE_ALL - any of the supported features; | |
| 66 // GPU_FEATURE_TYPE_WEBGL - a single feature; | |
| 67 // GPU_FEATURE_TYPE_WEBGL | GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | |
| 68 // - two features. | |
| 69 // If disabled set to true, return entries that are disabled; otherwise, | 72 // If disabled set to true, return entries that are disabled; otherwise, |
| 70 // return enabled entries. | 73 // return enabled entries. |
| 71 void GetGpuFeatureTypeEntries(content::GpuFeatureType feature, | 74 void GetDecisionEntries(std::vector<uint32>& entry_ids, |
| 72 std::vector<uint32>& entry_ids, | 75 bool disabled) const; |
| 73 bool disabled) const; | |
| 74 | 76 |
| 75 // Returns the description and bugs from active entries from the last | 77 // Returns the description and bugs from active entries from the last |
| 76 // DetermineGpuFeatureType() call. | 78 // MakeBlacklistDecision() call. |
| 77 // | 79 // |
| 78 // Each problems has: | 80 // Each problems has: |
| 79 // { | 81 // { |
| 80 // "description": "Your GPU is too old", | 82 // "description": "Your GPU is too old", |
| 81 // "crBugs": [1234], | 83 // "crBugs": [1234], |
| 82 // "webkitBugs": [] | 84 // "webkitBugs": [] |
| 83 // } | 85 // } |
| 84 void GetBlacklistReasons(ListValue* problem_list) const; | 86 void GetBlacklistReasons(ListValue* problem_list) const; |
| 85 | 87 |
| 86 // Return the largest entry id. This is used for histogramming. | 88 // Return the largest entry id. This is used for histogramming. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 // Returns the description of the entry | 244 // Returns the description of the entry |
| 243 const std::string& description() const { return description_; } | 245 const std::string& description() const { return description_; } |
| 244 | 246 |
| 245 // Returns a list of Chromium and Webkit bugs applicable to this entry | 247 // Returns a list of Chromium and Webkit bugs applicable to this entry |
| 246 const std::vector<int>& cr_bugs() const { return cr_bugs_; } | 248 const std::vector<int>& cr_bugs() const { return cr_bugs_; } |
| 247 const std::vector<int>& webkit_bugs() const { return webkit_bugs_; } | 249 const std::vector<int>& webkit_bugs() const { return webkit_bugs_; } |
| 248 | 250 |
| 249 // Returns the GpuFeatureType. | 251 // Returns the GpuFeatureType. |
| 250 content::GpuFeatureType GetGpuFeatureType() const; | 252 content::GpuFeatureType GetGpuFeatureType() const; |
| 251 | 253 |
| 254 // Returns the GpuSwitchingOption. | |
| 255 content::GpuSwitchingOption GetGpuSwitchingOption() const; | |
| 256 | |
| 252 // Returns true if an unknown field is encountered. | 257 // Returns true if an unknown field is encountered. |
| 253 bool contains_unknown_fields() const { | 258 bool contains_unknown_fields() const { |
| 254 return contains_unknown_fields_; | 259 return contains_unknown_fields_; |
| 255 } | 260 } |
| 256 // Returns true if an unknown blacklist feature is encountered. | 261 // Returns true if an unknown blacklist feature is encountered. |
| 257 bool contains_unknown_features() const { | 262 bool contains_unknown_features() const { |
| 258 return contains_unknown_features_; | 263 return contains_unknown_features_; |
| 259 } | 264 } |
| 260 | 265 |
| 261 private: | 266 private: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 const std::string& float_string, | 325 const std::string& float_string, |
| 321 const std::string& float_string2); | 326 const std::string& float_string2); |
| 322 | 327 |
| 323 bool SetPerfOverallInfo(const std::string& op, | 328 bool SetPerfOverallInfo(const std::string& op, |
| 324 const std::string& float_string, | 329 const std::string& float_string, |
| 325 const std::string& float_string2); | 330 const std::string& float_string2); |
| 326 | 331 |
| 327 bool SetBlacklistedFeatures( | 332 bool SetBlacklistedFeatures( |
| 328 const std::vector<std::string>& blacklisted_features); | 333 const std::vector<std::string>& blacklisted_features); |
| 329 | 334 |
| 335 bool SetGpuSwitchingOption(const std::string& switching_string); | |
| 336 | |
| 330 void AddException(ScopedGpuBlacklistEntry exception); | 337 void AddException(ScopedGpuBlacklistEntry exception); |
| 331 | 338 |
| 332 static MultiGpuStyle StringToMultiGpuStyle(const std::string& style); | 339 static MultiGpuStyle StringToMultiGpuStyle(const std::string& style); |
| 333 | 340 |
| 334 static MultiGpuCategory StringToMultiGpuCategory( | 341 static MultiGpuCategory StringToMultiGpuCategory( |
| 335 const std::string& category); | 342 const std::string& category); |
| 336 | 343 |
| 337 uint32 id_; | 344 uint32 id_; |
| 338 bool disabled_; | 345 bool disabled_; |
| 339 std::string description_; | 346 std::string description_; |
| 340 std::vector<int> cr_bugs_; | 347 std::vector<int> cr_bugs_; |
| 341 std::vector<int> webkit_bugs_; | 348 std::vector<int> webkit_bugs_; |
| 342 scoped_ptr<OsInfo> os_info_; | 349 scoped_ptr<OsInfo> os_info_; |
| 343 uint32 vendor_id_; | 350 uint32 vendor_id_; |
| 344 std::vector<uint32> device_id_list_; | 351 std::vector<uint32> device_id_list_; |
| 345 MultiGpuStyle multi_gpu_style_; | 352 MultiGpuStyle multi_gpu_style_; |
| 346 MultiGpuCategory multi_gpu_category_; | 353 MultiGpuCategory multi_gpu_category_; |
| 347 scoped_ptr<StringInfo> driver_vendor_info_; | 354 scoped_ptr<StringInfo> driver_vendor_info_; |
| 348 scoped_ptr<VersionInfo> driver_version_info_; | 355 scoped_ptr<VersionInfo> driver_version_info_; |
| 349 scoped_ptr<VersionInfo> driver_date_info_; | 356 scoped_ptr<VersionInfo> driver_date_info_; |
| 350 scoped_ptr<StringInfo> gl_vendor_info_; | 357 scoped_ptr<StringInfo> gl_vendor_info_; |
| 351 scoped_ptr<StringInfo> gl_renderer_info_; | 358 scoped_ptr<StringInfo> gl_renderer_info_; |
| 352 scoped_ptr<FloatInfo> perf_graphics_info_; | 359 scoped_ptr<FloatInfo> perf_graphics_info_; |
| 353 scoped_ptr<FloatInfo> perf_gaming_info_; | 360 scoped_ptr<FloatInfo> perf_gaming_info_; |
| 354 scoped_ptr<FloatInfo> perf_overall_info_; | 361 scoped_ptr<FloatInfo> perf_overall_info_; |
| 355 content::GpuFeatureType feature_type_; | 362 Decision decision_; |
| 356 std::vector<ScopedGpuBlacklistEntry> exceptions_; | 363 std::vector<ScopedGpuBlacklistEntry> exceptions_; |
| 357 bool contains_unknown_fields_; | 364 bool contains_unknown_fields_; |
| 358 bool contains_unknown_features_; | 365 bool contains_unknown_features_; |
| 359 }; | 366 }; |
| 360 | 367 |
| 361 // Gets the current OS type. | 368 // Gets the current OS type. |
| 362 static OsType GetOsType(); | 369 static OsType GetOsType(); |
| 363 | 370 |
| 364 bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, | 371 bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, |
| 365 OsFilter os_filter); | 372 OsFilter os_filter); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 379 bool contains_unknown_fields() const { return contains_unknown_fields_; } | 386 bool contains_unknown_fields() const { return contains_unknown_fields_; } |
| 380 | 387 |
| 381 static NumericOp StringToNumericOp(const std::string& op); | 388 static NumericOp StringToNumericOp(const std::string& op); |
| 382 | 389 |
| 383 scoped_ptr<Version> version_; | 390 scoped_ptr<Version> version_; |
| 384 std::vector<ScopedGpuBlacklistEntry> blacklist_; | 391 std::vector<ScopedGpuBlacklistEntry> blacklist_; |
| 385 | 392 |
| 386 scoped_ptr<Version> browser_version_; | 393 scoped_ptr<Version> browser_version_; |
| 387 | 394 |
| 388 // This records all the blacklist entries that are appliable to the current | 395 // This records all the blacklist entries that are appliable to the current |
| 389 // user machine. It is updated everytime DetermineGpuFeatureType() is | 396 // user machine. It is updated everytime MakeBlacklistDecision() is |
| 390 // called and is used later by GetGpuFeatureTypeEntries(). | 397 // called and is used later by GetDecisionEntries() and |
|
Ken Russell (switch to Gerrit)
2012/09/12 01:59:04
Incomplete sentence.
Zhenyao Mo
2012/09/12 17:41:34
Done.
| |
| 391 std::vector<ScopedGpuBlacklistEntry> active_entries_; | 398 std::vector<ScopedGpuBlacklistEntry> active_entries_; |
| 392 | 399 |
| 393 uint32 max_entry_id_; | 400 uint32 max_entry_id_; |
| 394 | 401 |
| 395 bool contains_unknown_fields_; | 402 bool contains_unknown_fields_; |
| 396 | 403 |
| 397 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); | 404 DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); |
| 398 }; | 405 }; |
| 399 | 406 |
| 400 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ | 407 #endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ |
| 401 | 408 |
| OLD | NEW |