| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 GPU_CONFIG_GPU_CONTROL_LIST_H_ | 5 #ifndef GPU_CONFIG_GPU_CONTROL_LIST_H_ |
| 6 #define GPU_CONFIG_GPU_CONTROL_LIST_H_ | 6 #define GPU_CONFIG_GPU_CONTROL_LIST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | |
| 10 | 9 |
| 11 #include <memory> | |
| 12 #include <set> | 10 #include <set> |
| 13 #include <string> | 11 #include <string> |
| 14 #include <vector> | 12 #include <vector> |
| 15 | 13 |
| 16 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 17 #include "base/memory/ref_counted.h" | |
| 18 #include "base/values.h" | 15 #include "base/values.h" |
| 19 #include "build/build_config.h" | |
| 20 #include "gpu/gpu_export.h" | 16 #include "gpu/gpu_export.h" |
| 21 | 17 |
| 22 namespace gpu { | 18 namespace gpu { |
| 19 struct GpuControlListData; |
| 23 struct GPUInfo; | 20 struct GPUInfo; |
| 24 | 21 |
| 25 class GPU_EXPORT GpuControlList { | 22 class GPU_EXPORT GpuControlList { |
| 26 public: | 23 public: |
| 27 enum OsType { | 24 typedef base::hash_map<int, std::string> FeatureMap; |
| 28 kOsLinux, | 25 |
| 29 kOsMacosx, | 26 enum OsType { kOsLinux, kOsMacosx, kOsWin, kOsChromeOS, kOsAndroid, kOsAny }; |
| 30 kOsWin, | |
| 31 kOsChromeOS, | |
| 32 kOsAndroid, | |
| 33 kOsAny, | |
| 34 kOsUnknown | |
| 35 }; | |
| 36 | 27 |
| 37 enum OsFilter { | 28 enum OsFilter { |
| 38 // In loading, ignore all entries that belong to other OS. | 29 // In loading, ignore all entries that belong to other OS. |
| 39 kCurrentOsOnly, | 30 kCurrentOsOnly, |
| 40 // In loading, keep all entries. This is for testing only. | 31 // In loading, keep all entries. This is for testing only. |
| 41 kAllOs | 32 kAllOs |
| 42 }; | 33 }; |
| 43 | 34 |
| 44 GpuControlList(); | |
| 45 virtual ~GpuControlList(); | |
| 46 | |
| 47 // Loads control list information from a json file. | |
| 48 // If failed, the current GpuControlList is un-touched. | |
| 49 bool LoadList(const std::string& json_context, OsFilter os_filter); | |
| 50 | |
| 51 // Collects system information and combines them with gpu_info and control | |
| 52 // list information to decide which entries are applied to the current | |
| 53 // system and returns the union of features specified in each entry. | |
| 54 // If os is kOsAny, use the current OS; if os_version is empty, use the | |
| 55 // current OS version. | |
| 56 std::set<int> MakeDecision( | |
| 57 OsType os, std::string os_version, const GPUInfo& gpu_info); | |
| 58 | |
| 59 // Collects the active entries from the last MakeDecision() call. | |
| 60 // If disabled set to true, return entries that are disabled; otherwise, | |
| 61 // return enabled entries. | |
| 62 void GetDecisionEntries(std::vector<uint32_t>* entry_ids, | |
| 63 bool disabled) const; | |
| 64 | |
| 65 // Collects all disabled extensions. | |
| 66 std::vector<std::string> GetDisabledExtensions(); | |
| 67 | |
| 68 // Returns the description and bugs from active entries from the last | |
| 69 // MakeDecision() call. | |
| 70 // | |
| 71 // Each problems has: | |
| 72 // { | |
| 73 // "description": "Your GPU is too old", | |
| 74 // "crBugs": [1234], | |
| 75 // "webkitBugs": [] | |
| 76 // } | |
| 77 void GetReasons( | |
| 78 base::ListValue* problem_list, const std::string& tag) const; | |
| 79 | |
| 80 // Return the largest entry id. This is used for histogramming. | |
| 81 uint32_t max_entry_id() const; | |
| 82 | |
| 83 // Returns the version of the control list. | |
| 84 std::string version() const; | |
| 85 | |
| 86 // Check if we need more gpu info to make the decisions. | |
| 87 // This is computed from the last MakeDecision() call. | |
| 88 // If yes, we should create a gl context and do a full gpu info collection. | |
| 89 bool needs_more_info() const { return needs_more_info_; } | |
| 90 | |
| 91 // Returns the number of entries. This is only for tests. | |
| 92 size_t num_entries() const; | |
| 93 | |
| 94 // This is only for tests. | |
| 95 bool has_duplicated_entry_id() const; | |
| 96 | |
| 97 // Register a feature to FeatureMap - used to construct a GpuControlList. | |
| 98 void AddSupportedFeature(const std::string& feature_name, int feature_id); | |
| 99 // Register whether "all" is recognized as all features. | |
| 100 void set_supports_feature_type_all(bool supported); | |
| 101 | |
| 102 // Enables logging of control list decisions. | |
| 103 void enable_control_list_logging( | |
| 104 const std::string& control_list_logging_name) { | |
| 105 control_list_logging_enabled_ = true; | |
| 106 control_list_logging_name_ = control_list_logging_name; | |
| 107 } | |
| 108 | |
| 109 private: | |
| 110 friend class GpuControlListEntryTest; | |
| 111 friend class MachineModelInfoTest; | |
| 112 friend class NumberInfoTest; | |
| 113 friend class OsInfoTest; | |
| 114 friend class StringInfoTest; | |
| 115 friend class VersionInfoTest; | |
| 116 | |
| 117 enum NumericOp { | 35 enum NumericOp { |
| 118 kBetween, // <= * <= | 36 kBetween, // <= * <= |
| 119 kEQ, // = | 37 kEQ, // = |
| 120 kLT, // < | 38 kLT, // < |
| 121 kLE, // <= | 39 kLE, // <= |
| 122 kGT, // > | 40 kGT, // > |
| 123 kGE, // >= | 41 kGE, // >= |
| 124 kAny, | 42 kAny, |
| 125 kUnknown // Indicates the data is invalid. | 43 kUnknown // Indicates the data is invalid. |
| 126 }; | 44 }; |
| 127 | 45 |
| 128 class GPU_EXPORT VersionInfo { | 46 enum MultiGpuStyle { |
| 129 public: | 47 kMultiGpuStyleOptimus, |
| 130 // If version_style is empty, it defaults to kNumerical. | 48 kMultiGpuStyleAMDSwitchable, |
| 131 VersionInfo(const std::string& version_op, | 49 kMultiGpuStyleAMDSwitchableIntegrated, |
| 132 const std::string& version_style, | 50 kMultiGpuStyleAMDSwitchableDiscrete, |
| 133 const std::string& version_string, | 51 kMultiGpuStyleNone |
| 134 const std::string& version_string2); | 52 }; |
| 135 ~VersionInfo(); | |
| 136 | 53 |
| 137 // Determines if a given version is included in the VersionInfo range. | 54 enum MultiGpuCategory { |
| 138 // "splitter" divides version string into segments. | 55 // This entry applies if this is the primary GPU on the system. |
| 139 bool Contains(const std::string& version, char splitter) const; | 56 kMultiGpuCategoryPrimary, |
| 140 // Same as above, using '.' as splitter. | 57 // This entry applies if this is a secondary GPU on the system. |
| 141 bool Contains(const std::string& version) const; | 58 kMultiGpuCategorySecondary, |
| 59 // This entry applies if this is the active GPU on the system. |
| 60 kMultiGpuCategoryActive, |
| 61 // This entry applies if this is any of the GPUs on the system. |
| 62 kMultiGpuCategoryAny, |
| 63 kMultiGpuCategoryNone |
| 64 }; |
| 142 | 65 |
| 143 // Determine if the version_style is lexical. | 66 enum GLType { |
| 144 bool IsLexical() const; | 67 kGLTypeGL, // This is default on MacOSX, Linux, ChromeOS |
| 68 kGLTypeGLES, // This is default on Android |
| 69 kGLTypeANGLE, // This is default on Windows |
| 70 kGLTypeNone |
| 71 }; |
| 145 | 72 |
| 146 // Determines if the VersionInfo contains valid information. | 73 enum VersionStyle { |
| 147 bool IsValid() const; | 74 kVersionStyleNumerical, |
| 75 kVersionStyleLexical, |
| 76 kVersionStyleUnknown |
| 77 }; |
| 148 | 78 |
| 149 private: | 79 struct GPU_EXPORT Version { |
| 150 enum VersionStyle { | 80 NumericOp op; |
| 151 kVersionStyleNumerical, | 81 VersionStyle style; |
| 152 kVersionStyleLexical, | 82 const char* value1; |
| 153 kVersionStyleUnknown | 83 const char* value2; |
| 154 }; | |
| 155 | 84 |
| 156 static VersionStyle StringToVersionStyle(const std::string& version_style); | 85 bool IsSpecified() const { return op != kUnknown; } |
| 86 |
| 87 bool Contains(const std::string& version_string, char splitter) const; |
| 88 |
| 89 bool Contains(const std::string& version_string) const { |
| 90 return Contains(version_string, '.'); |
| 91 } |
| 157 | 92 |
| 158 // Compare two version strings. | 93 // Compare two version strings. |
| 159 // Return 1 if version > version_ref, | 94 // Return 1 if version > version_ref, |
| 160 // 0 if version = version_ref, | 95 // 0 if version = version_ref, |
| 161 // -1 if version < version_ref. | 96 // -1 if version < version_ref. |
| 162 // Note that we only compare as many segments as both versions contain. | 97 // Note that we only compare as many segments as both versions contain. |
| 163 // For example: Compare("10.3.1", "10.3") returns 0, | 98 // For example: Compare("10.3.1", "10.3") returns 0, |
| 164 // Compare("10.3", "10.3.1") returns 0. | 99 // Compare("10.3", "10.3.1") returns 0. |
| 165 // If "version_style" is Lexical, the first segment is compared | 100 // If "version_style" is Lexical, the first segment is compared |
| 166 // numerically, all other segments are compared lexically. | 101 // numerically, all other segments are compared lexically. |
| 167 // Lexical is used for AMD Linux driver versions only. | 102 // Lexical is used for AMD Linux driver versions only. |
| 168 static int Compare(const std::vector<std::string>& version, | 103 static int Compare(const std::vector<std::string>& version, |
| 169 const std::vector<std::string>& version_ref, | 104 const std::vector<std::string>& version_ref, |
| 170 VersionStyle version_style); | 105 VersionStyle version_style); |
| 171 | |
| 172 NumericOp op_; | |
| 173 VersionStyle version_style_; | |
| 174 std::vector<std::string> version_; | |
| 175 std::vector<std::string> version2_; | |
| 176 }; | 106 }; |
| 177 | 107 |
| 178 class GPU_EXPORT OsInfo { | 108 struct GPU_EXPORT DriverInfo { |
| 179 public: | 109 const char* driver_vendor; |
| 180 OsInfo(const std::string& os, | 110 Version driver_version; |
| 181 const std::string& version_op, | 111 Version driver_date; |
| 182 const std::string& version_string, | |
| 183 const std::string& version_string2); | |
| 184 ~OsInfo(); | |
| 185 | 112 |
| 186 // Determines if a given os/version is included in the OsInfo set. | 113 bool Contains(const GPUInfo& gpu_info) const; |
| 187 bool Contains(OsType type, const std::string& version) const; | |
| 188 | |
| 189 // Determines if the VersionInfo contains valid information. | |
| 190 bool IsValid() const; | |
| 191 | |
| 192 OsType type() const; | |
| 193 | |
| 194 // Maps string to OsType; returns kOsUnknown if it's not a valid os. | |
| 195 static OsType StringToOsType(const std::string& os); | |
| 196 | |
| 197 private: | |
| 198 OsType type_; | |
| 199 std::unique_ptr<VersionInfo> version_info_; | |
| 200 }; | 114 }; |
| 201 | 115 |
| 202 class GPU_EXPORT FloatInfo { | 116 struct GPU_EXPORT GLStrings { |
| 203 public: | 117 const char* gl_vendor; |
| 204 FloatInfo(const std::string& float_op, | 118 const char* gl_renderer; |
| 205 const std::string& float_value, | 119 const char* gl_extensions; |
| 206 const std::string& float_value2); | 120 const char* gl_version; |
| 207 | 121 |
| 208 // Determines if a given float is included in the FloatInfo. | 122 bool Contains(const GPUInfo& gpu_info) const; |
| 209 bool Contains(float value) const; | |
| 210 | |
| 211 // Determines if the FloatInfo contains valid information. | |
| 212 bool IsValid() const; | |
| 213 | |
| 214 private: | |
| 215 NumericOp op_; | |
| 216 float value_; | |
| 217 float value2_; | |
| 218 }; | 123 }; |
| 219 | 124 |
| 220 class GPU_EXPORT IntInfo { | 125 struct GPU_EXPORT MachineModelInfo { |
| 221 public: | 126 size_t machine_model_name_size; |
| 222 IntInfo(const std::string& int_op, | 127 const char** machine_model_names; |
| 223 const std::string& int_value, | 128 Version machine_model_version; |
| 224 const std::string& int_value2); | |
| 225 | 129 |
| 226 // Determines if a given int is included in the IntInfo. | 130 bool Contains(const GPUInfo& gpu_info) const; |
| 227 bool Contains(int value) const; | |
| 228 | |
| 229 // Determines if the IntInfo contains valid information. | |
| 230 bool IsValid() const; | |
| 231 | |
| 232 private: | |
| 233 NumericOp op_; | |
| 234 int value_; | |
| 235 int value2_; | |
| 236 }; | 131 }; |
| 237 | 132 |
| 238 class GPU_EXPORT BoolInfo { | 133 struct GPU_EXPORT More { |
| 239 public: | 134 // These are just part of Entry fields that are less common. |
| 240 explicit BoolInfo(bool value); | 135 // Putting them to a separate struct to save Entry data size. |
| 136 GLType gl_type; |
| 137 Version gl_version; |
| 138 Version pixel_shader_version; |
| 139 bool in_process_gpu; |
| 140 uint32_t gl_reset_notification_strategy; |
| 141 bool direct_rendering; |
| 142 Version gpu_count; |
| 241 | 143 |
| 242 // Determines if a given bool is included in the BoolInfo. | 144 // Return true if GL_VERSION string does not fit the entry info |
| 243 bool Contains(bool value) const; | 145 // on GL type and GL version. |
| 146 bool GLVersionInfoMismatch(const std::string& gl_version_string) const; |
| 244 | 147 |
| 245 private: | 148 bool Contains(const GPUInfo& gpu_info) const; |
| 246 bool value_; | 149 |
| 150 // Return the default GL type, depending on the OS. |
| 151 // See GLType declaration. |
| 152 static GLType GetDefaultGLType(); |
| 247 }; | 153 }; |
| 248 | 154 |
| 249 class GpuControlListEntry; | 155 struct GPU_EXPORT Conditions { |
| 250 typedef scoped_refptr<GpuControlListEntry> ScopedGpuControlListEntry; | 156 OsType os_type; |
| 157 Version os_version; |
| 158 uint32_t vendor_id; |
| 159 size_t device_id_size; |
| 160 const uint32_t* device_ids; |
| 161 MultiGpuCategory multi_gpu_category; |
| 162 MultiGpuStyle multi_gpu_style; |
| 163 const DriverInfo* driver_info; |
| 164 const GLStrings* gl_strings; |
| 165 const MachineModelInfo* machine_model_info; |
| 166 const More* more; |
| 251 | 167 |
| 252 typedef base::hash_map<std::string, int> FeatureMap; | 168 bool Contains(OsType os_type, |
| 169 const std::string& os_version, |
| 170 const GPUInfo& gpu_info) const; |
| 253 | 171 |
| 254 class GPU_EXPORT GpuControlListEntry | 172 // Determines whether we needs more gpu info to make the blacklisting |
| 255 : public base::RefCounted<GpuControlListEntry> { | 173 // decision. It should only be checked if Contains() returns true. |
| 256 public: | 174 bool NeedsMoreInfo(const GPUInfo& gpu_info) const; |
| 257 // Constructs GpuControlListEntry from DictionaryValue loaded from json. | 175 }; |
| 258 // Top-level entry must have an id number. Others are exceptions. | |
| 259 static ScopedGpuControlListEntry GetEntryFromValue( | |
| 260 const base::DictionaryValue* value, bool top_level, | |
| 261 const FeatureMap& feature_map, | |
| 262 bool supports_feature_type_all); | |
| 263 | 176 |
| 264 // Logs a control list match for this rule in the list identified by | 177 struct GPU_EXPORT Entry { |
| 265 // |control_list_logging_name|. | 178 uint32_t id; |
| 266 void LogControlListMatch( | 179 const char* description; |
| 267 const std::string& control_list_logging_name) const; | 180 size_t feature_size; |
| 181 const int* features; |
| 182 size_t disabled_extension_size; |
| 183 const char** disabled_extensions; |
| 184 size_t cr_bug_size; |
| 185 const uint32_t* cr_bugs; |
| 186 Conditions conditions; |
| 187 size_t exception_size; |
| 188 const Conditions* exceptions; |
| 268 | 189 |
| 269 // Determines if a given os/gc/machine_model/driver is included in the | 190 bool Contains(OsType os_type, |
| 270 // Entry set. | 191 const std::string& os_version, |
| 271 bool Contains(OsType os_type, const std::string& os_version, | |
| 272 const GPUInfo& gpu_info) const; | 192 const GPUInfo& gpu_info) const; |
| 273 | 193 |
| 274 // Determines whether we needs more gpu info to make the blacklisting | 194 // Determines whether we needs more gpu info to make the blacklisting |
| 275 // decision. It should only be checked if Contains() returns true. | 195 // decision. It should only be checked if Contains() returns true. |
| 276 bool NeedsMoreInfo(const GPUInfo& gpu_info, bool consider_exceptions) const; | 196 bool NeedsMoreInfo(const GPUInfo& gpu_info, bool consider_exceptions) const; |
| 277 | 197 |
| 278 // Returns the OsType. | 198 void GetFeatureNames(base::ListValue* feature_names, |
| 279 OsType GetOsType() const; | 199 const FeatureMap& feature_map) const; |
| 280 | 200 |
| 281 // Returns the entry's unique id. 0 is reserved. | 201 // Logs a control list match for this rule in the list identified by |
| 282 uint32_t id() const; | 202 // |control_list_logging_name|. |
| 203 void LogControlListMatch( |
| 204 const std::string& control_list_logging_name) const; |
| 205 }; |
| 283 | 206 |
| 284 // Returns whether the entry is disabled. | 207 explicit GpuControlList(const GpuControlListData& data); |
| 285 bool disabled() const; | 208 virtual ~GpuControlList(); |
| 286 | 209 |
| 287 // Returns the description of the entry | 210 // Collects system information and combines them with gpu_info and control |
| 288 const std::string& description() const { return description_; } | 211 // list information to decide which entries are applied to the current |
| 212 // system and returns the union of features specified in each entry. |
| 213 // If os is kOsAny, use the current OS; if os_version is empty, use the |
| 214 // current OS version. |
| 215 std::set<int> MakeDecision(OsType os, |
| 216 const std::string& os_version, |
| 217 const GPUInfo& gpu_info); |
| 289 | 218 |
| 290 // Returns a list of Chromium and Webkit bugs applicable to this entry | 219 // Collects the active entries from the last MakeDecision() call. |
| 291 const std::vector<int>& cr_bugs() const { return cr_bugs_; } | 220 void GetDecisionEntries(std::vector<uint32_t>* entry_ids) const; |
| 292 const std::vector<int>& webkit_bugs() const { return webkit_bugs_; } | |
| 293 const std::vector<std::string>& disabled_extensions() const { | |
| 294 return disabled_extensions_; | |
| 295 } | |
| 296 | 221 |
| 297 // Returns the blacklisted features in this entry. | 222 // Collects all disabled extensions. |
| 298 const std::set<int>& features() const; | 223 std::vector<std::string> GetDisabledExtensions(); |
| 299 | 224 |
| 300 // Returns a list of blacklisted feature names in this entry. | 225 // Returns the description and bugs from active entries from the last |
| 301 void GetFeatureNames(base::ListValue* feature_names, | 226 // MakeDecision() call. |
| 302 const FeatureMap& feature_map, | 227 // |
| 303 bool supports_feature_type_all) const; | 228 // Each problems has: |
| 229 // { |
| 230 // "description": "Your GPU is too old", |
| 231 // "crBugs": [1234], |
| 232 // } |
| 233 void GetReasons(base::ListValue* problem_list, const std::string& tag) const; |
| 304 | 234 |
| 305 private: | 235 // Return the largest entry id. This is used for histogramming. |
| 306 friend class base::RefCounted<GpuControlListEntry>; | 236 uint32_t max_entry_id() const; |
| 307 | 237 |
| 308 enum MultiGpuStyle { | 238 // Returns the version of the control list. |
| 309 kMultiGpuStyleOptimus, | 239 std::string version() const; |
| 310 kMultiGpuStyleAMDSwitchable, | |
| 311 kMultiGpuStyleAMDSwitchableIntegrated, | |
| 312 kMultiGpuStyleAMDSwitchableDiscrete, | |
| 313 kMultiGpuStyleNone | |
| 314 }; | |
| 315 | 240 |
| 316 enum MultiGpuCategory { | 241 // Check if we need more gpu info to make the decisions. |
| 317 // This entry applies if this is the primary GPU on the system. | 242 // This is computed from the last MakeDecision() call. |
| 318 kMultiGpuCategoryPrimary, | 243 // If yes, we should create a gl context and do a full gpu info collection. |
| 319 // This entry applies if this is a secondary GPU on the system. | 244 bool needs_more_info() const { return needs_more_info_; } |
| 320 kMultiGpuCategorySecondary, | |
| 321 // This entry applies if this is the active GPU on the system. | |
| 322 kMultiGpuCategoryActive, | |
| 323 // This entry applies if this is any of the GPUs on the system. | |
| 324 kMultiGpuCategoryAny, | |
| 325 kMultiGpuCategoryNone | |
| 326 }; | |
| 327 | 245 |
| 328 enum GLType { | 246 // Returns the number of entries. This is only for tests. |
| 329 kGLTypeGL, // This is default on MacOSX, Linux, ChromeOS | 247 size_t num_entries() const; |
| 330 kGLTypeGLES, // This is default on Android | |
| 331 kGLTypeANGLE, // This is default on Windows | |
| 332 kGLTypeNone | |
| 333 }; | |
| 334 | 248 |
| 335 GpuControlListEntry(); | 249 // Register a feature to FeatureMap. |
| 336 ~GpuControlListEntry(); | 250 void AddSupportedFeature(const std::string& feature_name, int feature_id); |
| 337 | 251 |
| 338 bool SetId(uint32_t id); | 252 // Enables logging of control list decisions. |
| 253 void EnableControlListLogging(const std::string& control_list_logging_name) { |
| 254 control_list_logging_enabled_ = true; |
| 255 control_list_logging_name_ = control_list_logging_name; |
| 256 } |
| 339 | 257 |
| 340 void SetDisabled(bool disabled); | 258 private: |
| 341 | 259 friend class GpuControlListEntryTest; |
| 342 bool SetOsInfo(const std::string& os, | 260 friend class VersionInfoTest; |
| 343 const std::string& version_op, | |
| 344 const std::string& version_string, | |
| 345 const std::string& version_string2); | |
| 346 | |
| 347 bool SetVendorId(const std::string& vendor_id_string); | |
| 348 | |
| 349 bool AddDeviceId(const std::string& device_id_string); | |
| 350 | |
| 351 bool SetMultiGpuStyle(const std::string& multi_gpu_style_string); | |
| 352 | |
| 353 bool SetMultiGpuCategory(const std::string& multi_gpu_category_string); | |
| 354 | |
| 355 bool SetGLType(const std::string& gl_type_string); | |
| 356 | |
| 357 bool SetDriverVendorInfo(const std::string& vendor_value); | |
| 358 | |
| 359 bool SetDriverVersionInfo(const std::string& version_op, | |
| 360 const std::string& version_style, | |
| 361 const std::string& version_string, | |
| 362 const std::string& version_string2); | |
| 363 | |
| 364 bool SetDriverDateInfo(const std::string& date_op, | |
| 365 const std::string& date_string, | |
| 366 const std::string& date_string2); | |
| 367 | |
| 368 bool SetGLVersionInfo(const std::string& version_op, | |
| 369 const std::string& version_string, | |
| 370 const std::string& version_string2); | |
| 371 | |
| 372 bool SetGLVersionStringInfo(const std::string& version_string_value); | |
| 373 | |
| 374 bool SetGLVendorInfo(const std::string& vendor_value); | |
| 375 | |
| 376 bool SetGLRendererInfo(const std::string& renderer_value); | |
| 377 | |
| 378 bool SetGLExtensionsInfo(const std::string& extensions_value); | |
| 379 | |
| 380 bool SetGLResetNotificationStrategyInfo(const std::string& op, | |
| 381 const std::string& int_string, | |
| 382 const std::string& int_string2); | |
| 383 | |
| 384 bool SetCpuBrand(const std::string& cpu_value); | |
| 385 | |
| 386 bool SetPerfGraphicsInfo(const std::string& op, | |
| 387 const std::string& float_string, | |
| 388 const std::string& float_string2); | |
| 389 | |
| 390 bool SetPerfGamingInfo(const std::string& op, | |
| 391 const std::string& float_string, | |
| 392 const std::string& float_string2); | |
| 393 | |
| 394 bool SetPerfOverallInfo(const std::string& op, | |
| 395 const std::string& float_string, | |
| 396 const std::string& float_string2); | |
| 397 | |
| 398 bool AddMachineModelName(const std::string& model_name); | |
| 399 | |
| 400 bool SetMachineModelVersionInfo(const std::string& version_op, | |
| 401 const std::string& version_string, | |
| 402 const std::string& version_string2); | |
| 403 | |
| 404 bool SetGpuCountInfo(const std::string& op, | |
| 405 const std::string& int_string, | |
| 406 const std::string& int_string2); | |
| 407 | |
| 408 void SetDirectRenderingInfo(bool value); | |
| 409 void SetInProcessGPUInfo(bool value); | |
| 410 | |
| 411 bool SetPixelShaderVersionInfo(const std::string& version_op, | |
| 412 const std::string& version_string, | |
| 413 const std::string& version_string2); | |
| 414 | |
| 415 bool SetFeatures(const std::vector<std::string>& features, | |
| 416 const std::vector<std::string>& exceptions, | |
| 417 const FeatureMap& feature_map, | |
| 418 bool supports_feature_type_all); | |
| 419 | |
| 420 void AddException(ScopedGpuControlListEntry exception); | |
| 421 | |
| 422 // Return true if GL_VERSION string does not fit the entry info | |
| 423 // on GL type and GL version. | |
| 424 bool GLVersionInfoMismatch(const std::string& gl_version) const; | |
| 425 | |
| 426 static MultiGpuStyle StringToMultiGpuStyle(const std::string& style); | |
| 427 | |
| 428 static MultiGpuCategory StringToMultiGpuCategory( | |
| 429 const std::string& category); | |
| 430 | |
| 431 static GLType StringToGLType(const std::string& gl_type); | |
| 432 | |
| 433 // map a feature_name to feature_id. If the string is not a registered | |
| 434 // feature name, return false. | |
| 435 static bool StringToFeature(const std::string& feature_name, | |
| 436 int* feature_id, | |
| 437 const FeatureMap& feature_map); | |
| 438 | |
| 439 // Return the default GL type, depending on the OS. | |
| 440 // See GLType declaration. | |
| 441 static GLType GetDefaultGLType(); | |
| 442 | |
| 443 uint32_t id_; | |
| 444 bool disabled_; | |
| 445 std::string description_; | |
| 446 std::vector<int> cr_bugs_; | |
| 447 std::vector<int> webkit_bugs_; | |
| 448 std::vector<std::string> disabled_extensions_; | |
| 449 std::unique_ptr<OsInfo> os_info_; | |
| 450 uint32_t vendor_id_; | |
| 451 std::vector<uint32_t> device_id_list_; | |
| 452 MultiGpuStyle multi_gpu_style_; | |
| 453 MultiGpuCategory multi_gpu_category_; | |
| 454 GLType gl_type_; | |
| 455 std::string driver_vendor_info_; | |
| 456 std::unique_ptr<VersionInfo> driver_version_info_; | |
| 457 std::unique_ptr<VersionInfo> driver_date_info_; | |
| 458 std::unique_ptr<VersionInfo> gl_version_info_; | |
| 459 std::string gl_version_string_info_; | |
| 460 std::string gl_vendor_info_; | |
| 461 std::string gl_renderer_info_; | |
| 462 std::string gl_extensions_info_; | |
| 463 std::unique_ptr<IntInfo> gl_reset_notification_strategy_info_; | |
| 464 std::string cpu_brand_; | |
| 465 std::unique_ptr<FloatInfo> perf_graphics_info_; | |
| 466 std::unique_ptr<FloatInfo> perf_gaming_info_; | |
| 467 std::unique_ptr<FloatInfo> perf_overall_info_; | |
| 468 std::vector<std::string> machine_model_name_list_; | |
| 469 std::unique_ptr<VersionInfo> machine_model_version_info_; | |
| 470 std::unique_ptr<IntInfo> gpu_count_info_; | |
| 471 std::unique_ptr<BoolInfo> direct_rendering_info_; | |
| 472 std::unique_ptr<BoolInfo> in_process_gpu_info_; | |
| 473 std::unique_ptr<VersionInfo> pixel_shader_version_info_; | |
| 474 std::set<int> features_; | |
| 475 std::vector<ScopedGpuControlListEntry> exceptions_; | |
| 476 }; | |
| 477 | 261 |
| 478 // Gets the current OS type. | 262 // Gets the current OS type. |
| 479 static OsType GetOsType(); | 263 static OsType GetOsType(); |
| 480 | 264 |
| 481 bool LoadList(const base::DictionaryValue& parsed_json, OsFilter os_filter); | |
| 482 | |
| 483 void Clear(); | |
| 484 | |
| 485 static NumericOp StringToNumericOp(const std::string& op); | |
| 486 | |
| 487 std::string version_; | 265 std::string version_; |
| 488 std::vector<ScopedGpuControlListEntry> entries_; | 266 size_t entry_count_; |
| 489 | 267 const Entry* entries_; |
| 490 // This records all the blacklist entries that are appliable to the current | 268 // This records all the entries that are appliable to the current user |
| 491 // user machine. It is updated everytime MakeDecision() is called and is | 269 // machine. It is updated everytime MakeDecision() is called and is used |
| 492 // used later by GetDecisionEntries(). | 270 // later by GetDecisionEntries(). |
| 493 std::vector<ScopedGpuControlListEntry> active_entries_; | 271 std::vector<size_t> active_entries_; |
| 494 | 272 |
| 495 uint32_t max_entry_id_; | 273 uint32_t max_entry_id_; |
| 496 | 274 |
| 497 bool needs_more_info_; | 275 bool needs_more_info_; |
| 498 | 276 |
| 499 // The features a GpuControlList recognizes and handles. | 277 // The features a GpuControlList recognizes and handles. |
| 500 FeatureMap feature_map_; | 278 FeatureMap feature_map_; |
| 501 bool supports_feature_type_all_; | |
| 502 | 279 |
| 503 bool control_list_logging_enabled_; | 280 bool control_list_logging_enabled_; |
| 504 std::string control_list_logging_name_; | 281 std::string control_list_logging_name_; |
| 505 }; | 282 }; |
| 506 | 283 |
| 284 struct GPU_EXPORT GpuControlListData { |
| 285 const char* version; |
| 286 size_t entry_count; |
| 287 const GpuControlList::Entry* entries; |
| 288 |
| 289 GpuControlListData() : version(nullptr), entry_count(0u), entries(nullptr) {} |
| 290 |
| 291 GpuControlListData(const char* a_version, |
| 292 size_t a_entry_count, |
| 293 const GpuControlList::Entry* a_entries) |
| 294 : version(a_version), entry_count(a_entry_count), entries(a_entries) {} |
| 295 }; |
| 296 |
| 507 } // namespace gpu | 297 } // namespace gpu |
| 508 | 298 |
| 509 #endif // GPU_CONFIG_GPU_CONTROL_LIST_H_ | 299 #endif // GPU_CONFIG_GPU_CONTROL_LIST_H_ |
| 510 | |
| OLD | NEW |