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
3 // found in the LICENSE file.
5 #include "gpu/config/gpu_control_list.h"
8 #include "base/json/json_reader.h"
9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h"
14 #include "base/sys_info.h"
15 #include "gpu/config/gpu_info.h"
16 #include "gpu/config/gpu_util.h"
17 #include "third_party/re2/re2/re2.h"
22 // Break a version string into segments. Return true if each segment is
23 // a valid number, and not all segment is 0.
24 bool ProcessVersionString(const std::string
& version_string
,
26 std::vector
<std::string
>* version
) {
28 base::SplitString(version_string
, splitter
, version
);
29 if (version
->size() == 0)
31 // If the splitter is '-', we assume it's a date with format "mm-dd-yyyy";
32 // we split it into the order of "yyyy", "mm", "dd".
33 if (splitter
== '-') {
34 std::string year
= (*version
)[version
->size() - 1];
35 for (int i
= version
->size() - 1; i
> 0; --i
) {
36 (*version
)[i
] = (*version
)[i
- 1];
41 for (size_t i
= 0; i
< version
->size(); ++i
) {
43 if (!base::StringToUint((*version
)[i
], &num
))
51 // Compare two number strings using numerical ordering.
52 // Return 0 if number = number_ref,
53 // 1 if number > number_ref,
54 // -1 if number < number_ref.
55 int CompareNumericalNumberStrings(
56 const std::string
& number
, const std::string
& number_ref
) {
59 bool valid
= base::StringToUint(number
, &value1
);
61 valid
= base::StringToUint(number_ref
, &value2
);
70 // Compare two number strings using lexical ordering.
71 // Return 0 if number = number_ref,
72 // 1 if number > number_ref,
73 // -1 if number < number_ref.
74 // We only compare as many digits as number_ref contains.
75 // If number_ref is xxx, it's considered as xxx*
76 // For example: CompareLexicalNumberStrings("121", "12") returns 0,
77 // CompareLexicalNumberStrings("12", "121") returns -1.
78 int CompareLexicalNumberStrings(
79 const std::string
& number
, const std::string
& number_ref
) {
80 for (size_t i
= 0; i
< number_ref
.length(); ++i
) {
82 if (i
< number
.length())
83 value1
= number
[i
] - '0';
84 unsigned value2
= number_ref
[i
] - '0';
93 // A mismatch is identified only if both |input| and |pattern| are not empty.
94 bool StringMismatch(const std::string
& input
, const std::string
& pattern
) {
95 if (input
.empty() || pattern
.empty())
97 return !RE2::FullMatch(input
, pattern
);
100 const char kMultiGpuStyleStringAMDSwitchable
[] = "amd_switchable";
101 const char kMultiGpuStyleStringAMDSwitchableDiscrete
[] =
102 "amd_switchable_discrete";
103 const char kMultiGpuStyleStringAMDSwitchableIntegrated
[] =
104 "amd_switchable_integrated";
105 const char kMultiGpuStyleStringOptimus
[] = "optimus";
107 const char kMultiGpuCategoryStringPrimary
[] = "primary";
108 const char kMultiGpuCategoryStringSecondary
[] = "secondary";
109 const char kMultiGpuCategoryStringActive
[] = "active";
110 const char kMultiGpuCategoryStringAny
[] = "any";
112 const char kGLTypeStringGL
[] = "gl";
113 const char kGLTypeStringGLES
[] = "gles";
114 const char kGLTypeStringANGLE
[] = "angle";
116 const char kVersionStyleStringNumerical
[] = "numerical";
117 const char kVersionStyleStringLexical
[] = "lexical";
119 const char kOp
[] = "op";
121 } // namespace anonymous
123 GpuControlList::VersionInfo::VersionInfo(
124 const std::string
& version_op
,
125 const std::string
& version_style
,
126 const std::string
& version_string
,
127 const std::string
& version_string2
)
128 : version_style_(kVersionStyleNumerical
) {
129 op_
= StringToNumericOp(version_op
);
130 if (op_
== kUnknown
|| op_
== kAny
)
132 version_style_
= StringToVersionStyle(version_style
);
133 if (!ProcessVersionString(version_string
, '.', &version_
)) {
137 if (op_
== kBetween
) {
138 if (!ProcessVersionString(version_string2
, '.', &version2_
))
143 GpuControlList::VersionInfo::~VersionInfo() {
146 bool GpuControlList::VersionInfo::Contains(
147 const std::string
& version_string
) const {
148 return Contains(version_string
, '.');
151 bool GpuControlList::VersionInfo::Contains(
152 const std::string
& version_string
, char splitter
) const {
157 std::vector
<std::string
> version
;
158 if (!ProcessVersionString(version_string
, splitter
, &version
))
160 int relation
= Compare(version
, version_
, version_style_
);
162 return (relation
== 0);
164 return (relation
< 0);
166 return (relation
<= 0);
168 return (relation
> 0);
170 return (relation
>= 0);
174 return Compare(version
, version2_
, version_style_
) <= 0;
177 bool GpuControlList::VersionInfo::IsValid() const {
178 return (op_
!= kUnknown
&& version_style_
!= kVersionStyleUnknown
);
181 bool GpuControlList::VersionInfo::IsLexical() const {
182 return version_style_
== kVersionStyleLexical
;
186 int GpuControlList::VersionInfo::Compare(
187 const std::vector
<std::string
>& version
,
188 const std::vector
<std::string
>& version_ref
,
189 VersionStyle version_style
) {
190 DCHECK(version
.size() > 0 && version_ref
.size() > 0);
191 DCHECK(version_style
!= kVersionStyleUnknown
);
192 for (size_t i
= 0; i
< version_ref
.size(); ++i
) {
193 if (i
>= version
.size())
196 // We assume both versions are checked by ProcessVersionString().
197 if (i
> 0 && version_style
== kVersionStyleLexical
)
198 ret
= CompareLexicalNumberStrings(version
[i
], version_ref
[i
]);
200 ret
= CompareNumericalNumberStrings(version
[i
], version_ref
[i
]);
208 GpuControlList::VersionInfo::VersionStyle
209 GpuControlList::VersionInfo::StringToVersionStyle(
210 const std::string
& version_style
) {
211 if (version_style
.empty() || version_style
== kVersionStyleStringNumerical
)
212 return kVersionStyleNumerical
;
213 if (version_style
== kVersionStyleStringLexical
)
214 return kVersionStyleLexical
;
215 return kVersionStyleUnknown
;
218 GpuControlList::OsInfo::OsInfo(const std::string
& os
,
219 const std::string
& version_op
,
220 const std::string
& version_string
,
221 const std::string
& version_string2
) {
222 type_
= StringToOsType(os
);
223 if (type_
!= kOsUnknown
) {
224 version_info_
.reset(new VersionInfo(
225 version_op
, std::string(), version_string
, version_string2
));
229 GpuControlList::OsInfo::~OsInfo() {}
231 bool GpuControlList::OsInfo::Contains(
232 OsType type
, const std::string
& version
) const {
235 if (type_
!= type
&& type_
!= kOsAny
)
237 std::string processed_version
;
238 size_t pos
= version
.find_first_not_of("0123456789.");
239 if (pos
!= std::string::npos
)
240 processed_version
= version
.substr(0, pos
);
242 processed_version
= version
;
244 return version_info_
->Contains(processed_version
);
247 bool GpuControlList::OsInfo::IsValid() const {
248 return type_
!= kOsUnknown
&& version_info_
->IsValid();
251 GpuControlList::OsType
GpuControlList::OsInfo::type() const {
255 GpuControlList::OsType
GpuControlList::OsInfo::StringToOsType(
256 const std::string
& os
) {
259 else if (os
== "macosx")
261 else if (os
== "android")
263 else if (os
== "linux")
265 else if (os
== "chromeos")
267 else if (os
== "any")
272 GpuControlList::FloatInfo::FloatInfo(const std::string
& float_op
,
273 const std::string
& float_value
,
274 const std::string
& float_value2
)
278 op_
= StringToNumericOp(float_op
);
282 if (!base::StringToDouble(float_value
, &dvalue
)) {
286 value_
= static_cast<float>(dvalue
);
287 if (op_
== kBetween
) {
288 if (!base::StringToDouble(float_value2
, &dvalue
)) {
292 value2_
= static_cast<float>(dvalue
);
296 bool GpuControlList::FloatInfo::Contains(float value
) const {
302 return (value
== value_
);
304 return (value
< value_
);
306 return (value
<= value_
);
308 return (value
> value_
);
310 return (value
>= value_
);
311 DCHECK(op_
== kBetween
);
312 return ((value_
<= value
&& value
<= value2_
) ||
313 (value2_
<= value
&& value
<= value_
));
316 bool GpuControlList::FloatInfo::IsValid() const {
317 return op_
!= kUnknown
;
320 GpuControlList::IntInfo::IntInfo(const std::string
& int_op
,
321 const std::string
& int_value
,
322 const std::string
& int_value2
)
326 op_
= StringToNumericOp(int_op
);
329 if (!base::StringToInt(int_value
, &value_
)) {
333 if (op_
== kBetween
&&
334 !base::StringToInt(int_value2
, &value2_
))
338 bool GpuControlList::IntInfo::Contains(int value
) const {
344 return (value
== value_
);
346 return (value
< value_
);
348 return (value
<= value_
);
350 return (value
> value_
);
352 return (value
>= value_
);
353 DCHECK(op_
== kBetween
);
354 return ((value_
<= value
&& value
<= value2_
) ||
355 (value2_
<= value
&& value
<= value_
));
358 bool GpuControlList::IntInfo::IsValid() const {
359 return op_
!= kUnknown
;
362 GpuControlList::BoolInfo::BoolInfo(bool value
) : value_(value
) {}
364 bool GpuControlList::BoolInfo::Contains(bool value
) const {
365 return value_
== value
;
369 GpuControlList::ScopedGpuControlListEntry
370 GpuControlList::GpuControlListEntry::GetEntryFromValue(
371 const base::DictionaryValue
* value
, bool top_level
,
372 const FeatureMap
& feature_map
,
373 bool supports_feature_type_all
) {
375 ScopedGpuControlListEntry
entry(new GpuControlListEntry());
377 size_t dictionary_entry_count
= 0;
381 if (!value
->GetInteger("id", reinterpret_cast<int*>(&id
)) ||
383 LOG(WARNING
) << "Malformed id entry " << entry
->id();
386 dictionary_entry_count
++;
389 if (value
->GetBoolean("disabled", &disabled
)) {
390 entry
->SetDisabled(disabled
);
391 dictionary_entry_count
++;
395 std::string description
;
396 if (value
->GetString("description", &description
)) {
397 entry
->description_
= description
;
398 dictionary_entry_count
++;
400 entry
->description_
= "The GPU is unavailable for an unexplained reason.";
403 const base::ListValue
* cr_bugs
;
404 if (value
->GetList("cr_bugs", &cr_bugs
)) {
405 for (size_t i
= 0; i
< cr_bugs
->GetSize(); ++i
) {
407 if (cr_bugs
->GetInteger(i
, &bug_id
)) {
408 entry
->cr_bugs_
.push_back(bug_id
);
410 LOG(WARNING
) << "Malformed cr_bugs entry " << entry
->id();
414 dictionary_entry_count
++;
417 const base::ListValue
* webkit_bugs
;
418 if (value
->GetList("webkit_bugs", &webkit_bugs
)) {
419 for (size_t i
= 0; i
< webkit_bugs
->GetSize(); ++i
) {
421 if (webkit_bugs
->GetInteger(i
, &bug_id
)) {
422 entry
->webkit_bugs_
.push_back(bug_id
);
424 LOG(WARNING
) << "Malformed webkit_bugs entry " << entry
->id();
428 dictionary_entry_count
++;
431 const base::DictionaryValue
* os_value
= NULL
;
432 if (value
->GetDictionary("os", &os_value
)) {
434 std::string os_version_op
= "any";
435 std::string os_version_string
;
436 std::string os_version_string2
;
437 os_value
->GetString("type", &os_type
);
438 const base::DictionaryValue
* os_version_value
= NULL
;
439 if (os_value
->GetDictionary("version", &os_version_value
)) {
440 os_version_value
->GetString(kOp
, &os_version_op
);
441 os_version_value
->GetString("value", &os_version_string
);
442 os_version_value
->GetString("value2", &os_version_string2
);
444 if (!entry
->SetOsInfo(os_type
, os_version_op
, os_version_string
,
445 os_version_string2
)) {
446 LOG(WARNING
) << "Malformed os entry " << entry
->id();
449 dictionary_entry_count
++;
452 std::string vendor_id
;
453 if (value
->GetString("vendor_id", &vendor_id
)) {
454 if (!entry
->SetVendorId(vendor_id
)) {
455 LOG(WARNING
) << "Malformed vendor_id entry " << entry
->id();
458 dictionary_entry_count
++;
461 const base::ListValue
* device_id_list
;
462 if (value
->GetList("device_id", &device_id_list
)) {
463 for (size_t i
= 0; i
< device_id_list
->GetSize(); ++i
) {
464 std::string device_id
;
465 if (!device_id_list
->GetString(i
, &device_id
) ||
466 !entry
->AddDeviceId(device_id
)) {
467 LOG(WARNING
) << "Malformed device_id entry " << entry
->id();
471 dictionary_entry_count
++;
474 std::string multi_gpu_style
;
475 if (value
->GetString("multi_gpu_style", &multi_gpu_style
)) {
476 if (!entry
->SetMultiGpuStyle(multi_gpu_style
)) {
477 LOG(WARNING
) << "Malformed multi_gpu_style entry " << entry
->id();
480 dictionary_entry_count
++;
483 std::string multi_gpu_category
;
484 if (value
->GetString("multi_gpu_category", &multi_gpu_category
)) {
485 if (!entry
->SetMultiGpuCategory(multi_gpu_category
)) {
486 LOG(WARNING
) << "Malformed multi_gpu_category entry " << entry
->id();
489 dictionary_entry_count
++;
492 std::string driver_vendor_value
;
493 if (value
->GetString("driver_vendor", &driver_vendor_value
)) {
494 if (!entry
->SetDriverVendorInfo(driver_vendor_value
)) {
495 LOG(WARNING
) << "Malformed driver_vendor entry " << entry
->id();
498 dictionary_entry_count
++;
501 const base::DictionaryValue
* driver_version_value
= NULL
;
502 if (value
->GetDictionary("driver_version", &driver_version_value
)) {
503 std::string driver_version_op
= "any";
504 std::string driver_version_style
;
505 std::string driver_version_string
;
506 std::string driver_version_string2
;
507 driver_version_value
->GetString(kOp
, &driver_version_op
);
508 driver_version_value
->GetString("style", &driver_version_style
);
509 driver_version_value
->GetString("value", &driver_version_string
);
510 driver_version_value
->GetString("value2", &driver_version_string2
);
511 if (!entry
->SetDriverVersionInfo(driver_version_op
,
512 driver_version_style
,
513 driver_version_string
,
514 driver_version_string2
)) {
515 LOG(WARNING
) << "Malformed driver_version entry " << entry
->id();
518 dictionary_entry_count
++;
521 const base::DictionaryValue
* driver_date_value
= NULL
;
522 if (value
->GetDictionary("driver_date", &driver_date_value
)) {
523 std::string driver_date_op
= "any";
524 std::string driver_date_string
;
525 std::string driver_date_string2
;
526 driver_date_value
->GetString(kOp
, &driver_date_op
);
527 driver_date_value
->GetString("value", &driver_date_string
);
528 driver_date_value
->GetString("value2", &driver_date_string2
);
529 if (!entry
->SetDriverDateInfo(driver_date_op
, driver_date_string
,
530 driver_date_string2
)) {
531 LOG(WARNING
) << "Malformed driver_date entry " << entry
->id();
534 dictionary_entry_count
++;
538 if (value
->GetString("gl_type", &gl_type
)) {
539 if (!entry
->SetGLType(gl_type
)) {
540 LOG(WARNING
) << "Malformed gl_type entry " << entry
->id();
543 dictionary_entry_count
++;
546 const base::DictionaryValue
* gl_version_value
= NULL
;
547 if (value
->GetDictionary("gl_version", &gl_version_value
)) {
548 std::string version_op
= "any";
549 std::string version_string
;
550 std::string version_string2
;
551 gl_version_value
->GetString(kOp
, &version_op
);
552 gl_version_value
->GetString("value", &version_string
);
553 gl_version_value
->GetString("value2", &version_string2
);
554 if (!entry
->SetGLVersionInfo(
555 version_op
, version_string
, version_string2
)) {
556 LOG(WARNING
) << "Malformed gl_version entry " << entry
->id();
559 dictionary_entry_count
++;
562 std::string gl_vendor_value
;
563 if (value
->GetString("gl_vendor", &gl_vendor_value
)) {
564 if (!entry
->SetGLVendorInfo(gl_vendor_value
)) {
565 LOG(WARNING
) << "Malformed gl_vendor entry " << entry
->id();
568 dictionary_entry_count
++;
571 std::string gl_renderer_value
;
572 if (value
->GetString("gl_renderer", &gl_renderer_value
)) {
573 if (!entry
->SetGLRendererInfo(gl_renderer_value
)) {
574 LOG(WARNING
) << "Malformed gl_renderer entry " << entry
->id();
577 dictionary_entry_count
++;
580 std::string gl_extensions_value
;
581 if (value
->GetString("gl_extensions", &gl_extensions_value
)) {
582 if (!entry
->SetGLExtensionsInfo(gl_extensions_value
)) {
583 LOG(WARNING
) << "Malformed gl_extensions entry " << entry
->id();
586 dictionary_entry_count
++;
589 const base::DictionaryValue
* gl_reset_notification_strategy_value
= NULL
;
590 if (value
->GetDictionary("gl_reset_notification_strategy",
591 &gl_reset_notification_strategy_value
)) {
593 std::string int_value
;
594 std::string int_value2
;
595 gl_reset_notification_strategy_value
->GetString(kOp
, &op
);
596 gl_reset_notification_strategy_value
->GetString("value", &int_value
);
597 gl_reset_notification_strategy_value
->GetString("value2", &int_value2
);
598 if (!entry
->SetGLResetNotificationStrategyInfo(
599 op
, int_value
, int_value2
)) {
600 LOG(WARNING
) << "Malformed gl_reset_notification_strategy entry "
604 dictionary_entry_count
++;
607 std::string cpu_brand_value
;
608 if (value
->GetString("cpu_info", &cpu_brand_value
)) {
609 if (!entry
->SetCpuBrand(cpu_brand_value
)) {
610 LOG(WARNING
) << "Malformed cpu_brand entry " << entry
->id();
613 dictionary_entry_count
++;
616 const base::DictionaryValue
* perf_graphics_value
= NULL
;
617 if (value
->GetDictionary("perf_graphics", &perf_graphics_value
)) {
619 std::string float_value
;
620 std::string float_value2
;
621 perf_graphics_value
->GetString(kOp
, &op
);
622 perf_graphics_value
->GetString("value", &float_value
);
623 perf_graphics_value
->GetString("value2", &float_value2
);
624 if (!entry
->SetPerfGraphicsInfo(op
, float_value
, float_value2
)) {
625 LOG(WARNING
) << "Malformed perf_graphics entry " << entry
->id();
628 dictionary_entry_count
++;
631 const base::DictionaryValue
* perf_gaming_value
= NULL
;
632 if (value
->GetDictionary("perf_gaming", &perf_gaming_value
)) {
634 std::string float_value
;
635 std::string float_value2
;
636 perf_gaming_value
->GetString(kOp
, &op
);
637 perf_gaming_value
->GetString("value", &float_value
);
638 perf_gaming_value
->GetString("value2", &float_value2
);
639 if (!entry
->SetPerfGamingInfo(op
, float_value
, float_value2
)) {
640 LOG(WARNING
) << "Malformed perf_gaming entry " << entry
->id();
643 dictionary_entry_count
++;
646 const base::DictionaryValue
* perf_overall_value
= NULL
;
647 if (value
->GetDictionary("perf_overall", &perf_overall_value
)) {
649 std::string float_value
;
650 std::string float_value2
;
651 perf_overall_value
->GetString(kOp
, &op
);
652 perf_overall_value
->GetString("value", &float_value
);
653 perf_overall_value
->GetString("value2", &float_value2
);
654 if (!entry
->SetPerfOverallInfo(op
, float_value
, float_value2
)) {
655 LOG(WARNING
) << "Malformed perf_overall entry " << entry
->id();
658 dictionary_entry_count
++;
661 const base::ListValue
* machine_model_name_list
;
662 if (value
->GetList("machine_model_name", &machine_model_name_list
)) {
663 for (size_t i
= 0; i
< machine_model_name_list
->GetSize(); ++i
) {
664 std::string model_name
;
665 if (!machine_model_name_list
->GetString(i
, &model_name
) ||
666 !entry
->AddMachineModelName(model_name
)) {
667 LOG(WARNING
) << "Malformed machine_model_name entry " << entry
->id();
671 dictionary_entry_count
++;
674 const base::DictionaryValue
* machine_model_version_value
= NULL
;
675 if (value
->GetDictionary(
676 "machine_model_version", &machine_model_version_value
)) {
677 std::string version_op
= "any";
678 std::string version_string
;
679 std::string version_string2
;
680 machine_model_version_value
->GetString(kOp
, &version_op
);
681 machine_model_version_value
->GetString("value", &version_string
);
682 machine_model_version_value
->GetString("value2", &version_string2
);
683 if (!entry
->SetMachineModelVersionInfo(
684 version_op
, version_string
, version_string2
)) {
685 LOG(WARNING
) << "Malformed machine_model_version entry " << entry
->id();
688 dictionary_entry_count
++;
691 const base::DictionaryValue
* gpu_count_value
= NULL
;
692 if (value
->GetDictionary("gpu_count", &gpu_count_value
)) {
694 std::string int_value
;
695 std::string int_value2
;
696 gpu_count_value
->GetString(kOp
, &op
);
697 gpu_count_value
->GetString("value", &int_value
);
698 gpu_count_value
->GetString("value2", &int_value2
);
699 if (!entry
->SetGpuCountInfo(op
, int_value
, int_value2
)) {
700 LOG(WARNING
) << "Malformed gpu_count entry " << entry
->id();
703 dictionary_entry_count
++;
706 bool direct_rendering
;
707 if (value
->GetBoolean("direct_rendering", &direct_rendering
)) {
708 entry
->SetDirectRenderingInfo(direct_rendering
);
709 dictionary_entry_count
++;
713 const base::ListValue
* feature_value
= NULL
;
714 if (value
->GetList("features", &feature_value
)) {
715 std::vector
<std::string
> feature_list
;
716 for (size_t i
= 0; i
< feature_value
->GetSize(); ++i
) {
718 if (feature_value
->GetString(i
, &feature
)) {
719 feature_list
.push_back(feature
);
721 LOG(WARNING
) << "Malformed feature entry " << entry
->id();
725 if (!entry
->SetFeatures(
726 feature_list
, feature_map
, supports_feature_type_all
)) {
727 LOG(WARNING
) << "Malformed feature entry " << entry
->id();
730 dictionary_entry_count
++;
735 const base::ListValue
* exception_list_value
= NULL
;
736 if (value
->GetList("exceptions", &exception_list_value
)) {
737 for (size_t i
= 0; i
< exception_list_value
->GetSize(); ++i
) {
738 const base::DictionaryValue
* exception_value
= NULL
;
739 if (!exception_list_value
->GetDictionary(i
, &exception_value
)) {
740 LOG(WARNING
) << "Malformed exceptions entry " << entry
->id();
743 ScopedGpuControlListEntry
exception(GetEntryFromValue(
744 exception_value
, false, feature_map
, supports_feature_type_all
));
745 if (exception
.get() == NULL
) {
746 LOG(WARNING
) << "Malformed exceptions entry " << entry
->id();
749 // Exception should inherit vendor_id from parent, otherwise if only
750 // device_ids are specified in Exception, the info will be incomplete.
751 if (exception
->vendor_id_
== 0 && entry
->vendor_id_
!= 0)
752 exception
->vendor_id_
= entry
->vendor_id_
;
753 entry
->AddException(exception
);
755 dictionary_entry_count
++;
759 if (value
->size() != dictionary_entry_count
) {
760 LOG(WARNING
) << "Entry with unknown fields " << entry
->id();
764 // If GL_VERSION is specified, but no info about whether it's GL or GLES,
765 // we use the default for the platform. See GLType enum declaration.
766 if (entry
->gl_version_info_
.get() != NULL
&& entry
->gl_type_
== kGLTypeNone
)
767 entry
->gl_type_
= GetDefaultGLType();
772 GpuControlList::GpuControlListEntry::GpuControlListEntry()
776 multi_gpu_style_(kMultiGpuStyleNone
),
777 multi_gpu_category_(kMultiGpuCategoryPrimary
),
778 gl_type_(kGLTypeNone
) {
781 GpuControlList::GpuControlListEntry::~GpuControlListEntry() { }
783 bool GpuControlList::GpuControlListEntry::SetId(uint32 id
) {
791 void GpuControlList::GpuControlListEntry::SetDisabled(bool disabled
) {
792 disabled_
= disabled
;
795 bool GpuControlList::GpuControlListEntry::SetOsInfo(
796 const std::string
& os
,
797 const std::string
& version_op
,
798 const std::string
& version_string
,
799 const std::string
& version_string2
) {
800 os_info_
.reset(new OsInfo(os
, version_op
, version_string
, version_string2
));
801 return os_info_
->IsValid();
804 bool GpuControlList::GpuControlListEntry::SetVendorId(
805 const std::string
& vendor_id_string
) {
807 return base::HexStringToUInt(vendor_id_string
, &vendor_id_
) &&
811 bool GpuControlList::GpuControlListEntry::AddDeviceId(
812 const std::string
& device_id_string
) {
813 uint32 device_id
= 0;
814 if (base::HexStringToUInt(device_id_string
, &device_id
) && device_id
!= 0) {
815 device_id_list_
.push_back(device_id
);
821 bool GpuControlList::GpuControlListEntry::SetMultiGpuStyle(
822 const std::string
& multi_gpu_style_string
) {
823 MultiGpuStyle style
= StringToMultiGpuStyle(multi_gpu_style_string
);
824 if (style
== kMultiGpuStyleNone
)
826 multi_gpu_style_
= style
;
830 bool GpuControlList::GpuControlListEntry::SetMultiGpuCategory(
831 const std::string
& multi_gpu_category_string
) {
832 MultiGpuCategory category
=
833 StringToMultiGpuCategory(multi_gpu_category_string
);
834 if (category
== kMultiGpuCategoryNone
)
836 multi_gpu_category_
= category
;
840 bool GpuControlList::GpuControlListEntry::SetGLType(
841 const std::string
& gl_type_string
) {
842 GLType gl_type
= StringToGLType(gl_type_string
);
843 if (gl_type
== kGLTypeNone
)
849 bool GpuControlList::GpuControlListEntry::SetDriverVendorInfo(
850 const std::string
& vendor_value
) {
851 driver_vendor_info_
= vendor_value
;
852 return !driver_vendor_info_
.empty();
855 bool GpuControlList::GpuControlListEntry::SetDriverVersionInfo(
856 const std::string
& version_op
,
857 const std::string
& version_style
,
858 const std::string
& version_string
,
859 const std::string
& version_string2
) {
860 driver_version_info_
.reset(new VersionInfo(
861 version_op
, version_style
, version_string
, version_string2
));
862 return driver_version_info_
->IsValid();
865 bool GpuControlList::GpuControlListEntry::SetDriverDateInfo(
866 const std::string
& date_op
,
867 const std::string
& date_string
,
868 const std::string
& date_string2
) {
869 driver_date_info_
.reset(
870 new VersionInfo(date_op
, std::string(), date_string
, date_string2
));
871 return driver_date_info_
->IsValid();
874 bool GpuControlList::GpuControlListEntry::SetGLVersionInfo(
875 const std::string
& version_op
,
876 const std::string
& version_string
,
877 const std::string
& version_string2
) {
878 gl_version_info_
.reset(new VersionInfo(
879 version_op
, std::string(), version_string
, version_string2
));
880 return gl_version_info_
->IsValid();
883 bool GpuControlList::GpuControlListEntry::SetGLVendorInfo(
884 const std::string
& vendor_value
) {
885 gl_vendor_info_
= vendor_value
;
886 return !gl_vendor_info_
.empty();
889 bool GpuControlList::GpuControlListEntry::SetGLRendererInfo(
890 const std::string
& renderer_value
) {
891 gl_renderer_info_
= renderer_value
;
892 return !gl_renderer_info_
.empty();
895 bool GpuControlList::GpuControlListEntry::SetGLExtensionsInfo(
896 const std::string
& extensions_value
) {
897 gl_extensions_info_
= extensions_value
;
898 return !gl_extensions_info_
.empty();
901 bool GpuControlList::GpuControlListEntry::SetGLResetNotificationStrategyInfo(
902 const std::string
& op
,
903 const std::string
& int_string
,
904 const std::string
& int_string2
) {
905 gl_reset_notification_strategy_info_
.reset(
906 new IntInfo(op
, int_string
, int_string2
));
907 return gl_reset_notification_strategy_info_
->IsValid();
910 bool GpuControlList::GpuControlListEntry::SetCpuBrand(
911 const std::string
& cpu_value
) {
912 cpu_brand_
= cpu_value
;
913 return !cpu_brand_
.empty();
916 bool GpuControlList::GpuControlListEntry::SetPerfGraphicsInfo(
917 const std::string
& op
,
918 const std::string
& float_string
,
919 const std::string
& float_string2
) {
920 perf_graphics_info_
.reset(new FloatInfo(op
, float_string
, float_string2
));
921 return perf_graphics_info_
->IsValid();
924 bool GpuControlList::GpuControlListEntry::SetPerfGamingInfo(
925 const std::string
& op
,
926 const std::string
& float_string
,
927 const std::string
& float_string2
) {
928 perf_gaming_info_
.reset(new FloatInfo(op
, float_string
, float_string2
));
929 return perf_gaming_info_
->IsValid();
932 bool GpuControlList::GpuControlListEntry::SetPerfOverallInfo(
933 const std::string
& op
,
934 const std::string
& float_string
,
935 const std::string
& float_string2
) {
936 perf_overall_info_
.reset(new FloatInfo(op
, float_string
, float_string2
));
937 return perf_overall_info_
->IsValid();
940 bool GpuControlList::GpuControlListEntry::AddMachineModelName(
941 const std::string
& model_name
) {
942 if (model_name
.empty())
944 machine_model_name_list_
.push_back(model_name
);
948 bool GpuControlList::GpuControlListEntry::SetMachineModelVersionInfo(
949 const std::string
& version_op
,
950 const std::string
& version_string
,
951 const std::string
& version_string2
) {
952 machine_model_version_info_
.reset(new VersionInfo(
953 version_op
, std::string(), version_string
, version_string2
));
954 return machine_model_version_info_
->IsValid();
957 bool GpuControlList::GpuControlListEntry::SetGpuCountInfo(
958 const std::string
& op
,
959 const std::string
& int_string
,
960 const std::string
& int_string2
) {
961 gpu_count_info_
.reset(new IntInfo(op
, int_string
, int_string2
));
962 return gpu_count_info_
->IsValid();
965 void GpuControlList::GpuControlListEntry::SetDirectRenderingInfo(bool value
) {
966 direct_rendering_info_
.reset(new BoolInfo(value
));
969 bool GpuControlList::GpuControlListEntry::SetFeatures(
970 const std::vector
<std::string
>& feature_strings
,
971 const FeatureMap
& feature_map
,
972 bool supports_feature_type_all
) {
973 size_t size
= feature_strings
.size();
977 for (size_t i
= 0; i
< size
; ++i
) {
979 if (supports_feature_type_all
&& feature_strings
[i
] == "all") {
980 for (FeatureMap::const_iterator iter
= feature_map
.begin();
981 iter
!= feature_map
.end(); ++iter
)
982 features_
.insert(iter
->second
);
985 if (!StringToFeature(feature_strings
[i
], &feature
, feature_map
)) {
989 features_
.insert(feature
);
994 void GpuControlList::GpuControlListEntry::AddException(
995 ScopedGpuControlListEntry exception
) {
996 exceptions_
.push_back(exception
);
999 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch(
1000 const std::string
& gl_version
) const {
1001 if (gl_version
.empty())
1004 if (gl_version_info_
.get() == NULL
&& gl_type_
== kGLTypeNone
)
1007 std::vector
<std::string
> segments
;
1008 base::SplitString(gl_version
, ' ', &segments
);
1010 GLType gl_type
= kGLTypeNone
;
1011 if (segments
.size() > 2 &&
1012 segments
[0] == "OpenGL" && segments
[1] == "ES") {
1013 number
= segments
[2];
1014 gl_type
= kGLTypeGLES
;
1015 if (segments
.size() > 3 &&
1016 StartsWithASCII(segments
[3], "(ANGLE", false)) {
1017 gl_type
= kGLTypeANGLE
;
1020 number
= segments
[0];
1021 gl_type
= kGLTypeGL
;
1024 if (gl_type_
!= kGLTypeNone
&& gl_type_
!= gl_type
)
1026 if (gl_version_info_
.get() != NULL
&& !gl_version_info_
->Contains(number
))
1032 GpuControlList::GpuControlListEntry::MultiGpuStyle
1033 GpuControlList::GpuControlListEntry::StringToMultiGpuStyle(
1034 const std::string
& style
) {
1035 if (style
== kMultiGpuStyleStringOptimus
)
1036 return kMultiGpuStyleOptimus
;
1037 if (style
== kMultiGpuStyleStringAMDSwitchable
)
1038 return kMultiGpuStyleAMDSwitchable
;
1039 if (style
== kMultiGpuStyleStringAMDSwitchableIntegrated
)
1040 return kMultiGpuStyleAMDSwitchableIntegrated
;
1041 if (style
== kMultiGpuStyleStringAMDSwitchableDiscrete
)
1042 return kMultiGpuStyleAMDSwitchableDiscrete
;
1043 return kMultiGpuStyleNone
;
1047 GpuControlList::GpuControlListEntry::MultiGpuCategory
1048 GpuControlList::GpuControlListEntry::StringToMultiGpuCategory(
1049 const std::string
& category
) {
1050 if (category
== kMultiGpuCategoryStringPrimary
)
1051 return kMultiGpuCategoryPrimary
;
1052 if (category
== kMultiGpuCategoryStringSecondary
)
1053 return kMultiGpuCategorySecondary
;
1054 if (category
== kMultiGpuCategoryStringActive
)
1055 return kMultiGpuCategoryActive
;
1056 if (category
== kMultiGpuCategoryStringAny
)
1057 return kMultiGpuCategoryAny
;
1058 return kMultiGpuCategoryNone
;
1062 GpuControlList::GpuControlListEntry::GLType
1063 GpuControlList::GpuControlListEntry::StringToGLType(
1064 const std::string
& gl_type
) {
1065 if (gl_type
== kGLTypeStringGL
)
1067 if (gl_type
== kGLTypeStringGLES
)
1069 if (gl_type
== kGLTypeStringANGLE
)
1070 return kGLTypeANGLE
;
1075 GpuControlList::GpuControlListEntry::GLType
1076 GpuControlList::GpuControlListEntry::GetDefaultGLType() {
1077 #if defined(OS_CHROMEOS)
1079 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
1081 #elif defined(OS_MACOSX)
1083 #elif defined(OS_WIN)
1084 return kGLTypeANGLE
;
1085 #elif defined(OS_ANDROID)
1092 void GpuControlList::GpuControlListEntry::LogControlListMatch(
1093 const std::string
& control_list_logging_name
) const {
1094 static const char kControlListMatchMessage
[] =
1095 "Control list match for rule #%u in %s.";
1096 VLOG(1) << base::StringPrintf(kControlListMatchMessage
, id_
,
1097 control_list_logging_name
.c_str());
1100 bool GpuControlList::GpuControlListEntry::Contains(
1101 OsType os_type
, const std::string
& os_version
,
1102 const GPUInfo
& gpu_info
) const {
1103 DCHECK(os_type
!= kOsAny
);
1104 if (os_info_
.get() != NULL
&& !os_info_
->Contains(os_type
, os_version
))
1106 if (vendor_id_
!= 0) {
1107 std::vector
<GPUInfo::GPUDevice
> candidates
;
1108 switch (multi_gpu_category_
) {
1109 case kMultiGpuCategoryPrimary
:
1110 candidates
.push_back(gpu_info
.gpu
);
1112 case kMultiGpuCategorySecondary
:
1113 candidates
= gpu_info
.secondary_gpus
;
1115 case kMultiGpuCategoryAny
:
1116 candidates
= gpu_info
.secondary_gpus
;
1117 candidates
.push_back(gpu_info
.gpu
);
1119 case kMultiGpuCategoryActive
:
1120 if (gpu_info
.gpu
.active
)
1121 candidates
.push_back(gpu_info
.gpu
);
1122 for (size_t ii
= 0; ii
< gpu_info
.secondary_gpus
.size(); ++ii
) {
1123 if (gpu_info
.secondary_gpus
[ii
].active
)
1124 candidates
.push_back(gpu_info
.secondary_gpus
[ii
]);
1130 GPUInfo::GPUDevice gpu
;
1131 gpu
.vendor_id
= vendor_id_
;
1133 if (device_id_list_
.empty()) {
1134 for (size_t ii
= 0; ii
< candidates
.size(); ++ii
) {
1135 if (gpu
.vendor_id
== candidates
[ii
].vendor_id
) {
1141 for (size_t ii
= 0; ii
< device_id_list_
.size(); ++ii
) {
1142 gpu
.device_id
= device_id_list_
[ii
];
1143 for (size_t jj
= 0; jj
< candidates
.size(); ++jj
) {
1144 if (gpu
.vendor_id
== candidates
[jj
].vendor_id
&&
1145 gpu
.device_id
== candidates
[jj
].device_id
) {
1155 switch (multi_gpu_style_
) {
1156 case kMultiGpuStyleOptimus
:
1157 if (!gpu_info
.optimus
)
1160 case kMultiGpuStyleAMDSwitchable
:
1161 if (!gpu_info
.amd_switchable
)
1164 case kMultiGpuStyleAMDSwitchableDiscrete
:
1165 if (!gpu_info
.amd_switchable
)
1167 // The discrete GPU is always the primary GPU.
1168 // This is guaranteed by GpuInfoCollector.
1169 if (!gpu_info
.gpu
.active
)
1172 case kMultiGpuStyleAMDSwitchableIntegrated
:
1173 if (!gpu_info
.amd_switchable
)
1175 // Assume the integrated GPU is the first in the secondary GPU list.
1176 if (gpu_info
.secondary_gpus
.size() == 0 ||
1177 !gpu_info
.secondary_gpus
[0].active
)
1180 case kMultiGpuStyleNone
:
1183 if (StringMismatch(gpu_info
.driver_vendor
, driver_vendor_info_
))
1185 if (driver_version_info_
.get() != NULL
&& !gpu_info
.driver_version
.empty()) {
1186 if (!driver_version_info_
->Contains(gpu_info
.driver_version
))
1189 if (driver_date_info_
.get() != NULL
&& !gpu_info
.driver_date
.empty()) {
1190 if (!driver_date_info_
->Contains(gpu_info
.driver_date
, '-'))
1193 if (GLVersionInfoMismatch(gpu_info
.gl_version
))
1195 if (StringMismatch(gpu_info
.gl_vendor
, gl_vendor_info_
))
1197 if (StringMismatch(gpu_info
.gl_renderer
, gl_renderer_info_
))
1199 if (StringMismatch(gpu_info
.gl_extensions
, gl_extensions_info_
))
1201 if (gl_reset_notification_strategy_info_
.get() != NULL
&&
1202 !gl_reset_notification_strategy_info_
->Contains(
1203 gpu_info
.gl_reset_notification_strategy
))
1205 if (perf_graphics_info_
.get() != NULL
&&
1206 (gpu_info
.performance_stats
.graphics
== 0.0 ||
1207 !perf_graphics_info_
->Contains(gpu_info
.performance_stats
.graphics
)))
1209 if (perf_gaming_info_
.get() != NULL
&&
1210 (gpu_info
.performance_stats
.gaming
== 0.0 ||
1211 !perf_gaming_info_
->Contains(gpu_info
.performance_stats
.gaming
)))
1213 if (perf_overall_info_
.get() != NULL
&&
1214 (gpu_info
.performance_stats
.overall
== 0.0 ||
1215 !perf_overall_info_
->Contains(gpu_info
.performance_stats
.overall
)))
1217 if (!machine_model_name_list_
.empty()) {
1218 if (gpu_info
.machine_model_name
.empty())
1220 bool found_match
= false;
1221 for (size_t ii
= 0; ii
< machine_model_name_list_
.size(); ++ii
) {
1222 if (RE2::FullMatch(gpu_info
.machine_model_name
,
1223 machine_model_name_list_
[ii
])) {
1231 if (machine_model_version_info_
.get() != NULL
&&
1232 (gpu_info
.machine_model_version
.empty() ||
1233 !machine_model_version_info_
->Contains(gpu_info
.machine_model_version
)))
1235 if (gpu_count_info_
.get() != NULL
&&
1236 !gpu_count_info_
->Contains(gpu_info
.secondary_gpus
.size() + 1))
1238 if (direct_rendering_info_
.get() != NULL
&&
1239 !direct_rendering_info_
->Contains(gpu_info
.direct_rendering
))
1241 if (!cpu_brand_
.empty()) {
1243 if (StringMismatch(cpu_info
.cpu_brand(), cpu_brand_
))
1247 for (size_t i
= 0; i
< exceptions_
.size(); ++i
) {
1248 if (exceptions_
[i
]->Contains(os_type
, os_version
, gpu_info
) &&
1249 !exceptions_
[i
]->NeedsMoreInfo(gpu_info
))
1255 bool GpuControlList::GpuControlListEntry::NeedsMoreInfo(
1256 const GPUInfo
& gpu_info
) const {
1257 // We only check for missing info that might be collected with a gl context.
1258 // If certain info is missing due to some error, say, we fail to collect
1259 // vendor_id/device_id, then even if we launch GPU process and create a gl
1260 // context, we won't gather such missing info, so we still return false.
1261 if (!driver_vendor_info_
.empty() && gpu_info
.driver_vendor
.empty())
1263 if (driver_version_info_
.get() && gpu_info
.driver_version
.empty())
1265 if (!gl_vendor_info_
.empty() && gpu_info
.gl_vendor
.empty())
1267 if (!gl_renderer_info_
.empty() && gpu_info
.gl_renderer
.empty())
1269 for (size_t i
= 0; i
< exceptions_
.size(); ++i
) {
1270 if (exceptions_
[i
]->NeedsMoreInfo(gpu_info
))
1276 GpuControlList::OsType
GpuControlList::GpuControlListEntry::GetOsType() const {
1277 if (os_info_
.get() == NULL
)
1279 return os_info_
->type();
1282 uint32
GpuControlList::GpuControlListEntry::id() const {
1286 bool GpuControlList::GpuControlListEntry::disabled() const {
1290 const std::set
<int>& GpuControlList::GpuControlListEntry::features() const {
1294 void GpuControlList::GpuControlListEntry::GetFeatureNames(
1295 base::ListValue
* feature_names
,
1296 const FeatureMap
& feature_map
,
1297 bool supports_feature_type_all
) const {
1298 DCHECK(feature_names
);
1299 if (supports_feature_type_all
&& features_
.size() == feature_map
.size()) {
1300 feature_names
->AppendString("all");
1303 for (FeatureMap::const_iterator iter
= feature_map
.begin();
1304 iter
!= feature_map
.end(); ++iter
) {
1305 if (features_
.count(iter
->second
) > 0)
1306 feature_names
->AppendString(iter
->first
);
1311 bool GpuControlList::GpuControlListEntry::StringToFeature(
1312 const std::string
& feature_name
, int* feature_id
,
1313 const FeatureMap
& feature_map
) {
1314 FeatureMap::const_iterator iter
= feature_map
.find(feature_name
);
1315 if (iter
!= feature_map
.end()) {
1316 *feature_id
= iter
->second
;
1322 GpuControlList::GpuControlList()
1324 needs_more_info_(false),
1325 supports_feature_type_all_(false),
1326 control_list_logging_enabled_(false) {
1329 GpuControlList::~GpuControlList() {
1333 bool GpuControlList::LoadList(
1334 const std::string
& json_context
,
1335 GpuControlList::OsFilter os_filter
) {
1336 scoped_ptr
<base::Value
> root
;
1337 root
.reset(base::JSONReader::Read(json_context
));
1338 if (root
.get() == NULL
|| !root
->IsType(base::Value::TYPE_DICTIONARY
))
1341 base::DictionaryValue
* root_dictionary
=
1342 static_cast<base::DictionaryValue
*>(root
.get());
1343 DCHECK(root_dictionary
);
1344 return LoadList(*root_dictionary
, os_filter
);
1347 bool GpuControlList::LoadList(const base::DictionaryValue
& parsed_json
,
1348 GpuControlList::OsFilter os_filter
) {
1349 std::vector
<ScopedGpuControlListEntry
> entries
;
1351 parsed_json
.GetString("version", &version_
);
1352 std::vector
<std::string
> pieces
;
1353 if (!ProcessVersionString(version_
, '.', &pieces
))
1356 const base::ListValue
* list
= NULL
;
1357 if (!parsed_json
.GetList("entries", &list
))
1360 uint32 max_entry_id
= 0;
1361 for (size_t i
= 0; i
< list
->GetSize(); ++i
) {
1362 const base::DictionaryValue
* list_item
= NULL
;
1363 bool valid
= list
->GetDictionary(i
, &list_item
);
1364 if (!valid
|| list_item
== NULL
)
1366 ScopedGpuControlListEntry
entry(GpuControlListEntry::GetEntryFromValue(
1367 list_item
, true, feature_map_
, supports_feature_type_all_
));
1368 if (entry
.get() == NULL
)
1370 if (entry
->id() > max_entry_id
)
1371 max_entry_id
= entry
->id();
1372 entries
.push_back(entry
);
1376 OsType my_os
= GetOsType();
1377 for (size_t i
= 0; i
< entries
.size(); ++i
) {
1378 OsType entry_os
= entries
[i
]->GetOsType();
1379 if (os_filter
== GpuControlList::kAllOs
||
1380 entry_os
== kOsAny
|| entry_os
== my_os
)
1381 entries_
.push_back(entries
[i
]);
1383 max_entry_id_
= max_entry_id
;
1387 std::set
<int> GpuControlList::MakeDecision(
1388 GpuControlList::OsType os
,
1389 std::string os_version
,
1390 const GPUInfo
& gpu_info
) {
1391 active_entries_
.clear();
1392 std::set
<int> features
;
1394 needs_more_info_
= false;
1395 std::set
<int> possible_features
;
1399 if (os_version
.empty())
1400 os_version
= base::SysInfo::OperatingSystemVersion();
1402 for (size_t i
= 0; i
< entries_
.size(); ++i
) {
1403 if (entries_
[i
]->Contains(os
, os_version
, gpu_info
)) {
1404 bool needs_more_info
= entries_
[i
]->NeedsMoreInfo(gpu_info
);
1405 if (!entries_
[i
]->disabled()) {
1406 if (control_list_logging_enabled_
)
1407 entries_
[i
]->LogControlListMatch(control_list_logging_name_
);
1408 MergeFeatureSets(&possible_features
, entries_
[i
]->features());
1409 if (!needs_more_info
)
1410 MergeFeatureSets(&features
, entries_
[i
]->features());
1412 if (!needs_more_info
)
1413 active_entries_
.push_back(entries_
[i
]);
1417 if (possible_features
.size() > features
.size())
1418 needs_more_info_
= true;
1423 void GpuControlList::GetDecisionEntries(
1424 std::vector
<uint32
>* entry_ids
, bool disabled
) const {
1427 for (size_t i
= 0; i
< active_entries_
.size(); ++i
) {
1428 if (disabled
== active_entries_
[i
]->disabled())
1429 entry_ids
->push_back(active_entries_
[i
]->id());
1433 void GpuControlList::GetReasons(base::ListValue
* problem_list
,
1434 const std::string
& tag
) const {
1435 DCHECK(problem_list
);
1436 for (size_t i
= 0; i
< active_entries_
.size(); ++i
) {
1437 GpuControlListEntry
* entry
= active_entries_
[i
].get();
1438 if (entry
->disabled())
1440 base::DictionaryValue
* problem
= new base::DictionaryValue();
1442 problem
->SetString("description", entry
->description());
1444 base::ListValue
* cr_bugs
= new base::ListValue();
1445 for (size_t j
= 0; j
< entry
->cr_bugs().size(); ++j
)
1446 cr_bugs
->Append(new base::FundamentalValue(entry
->cr_bugs()[j
]));
1447 problem
->Set("crBugs", cr_bugs
);
1449 base::ListValue
* webkit_bugs
= new base::ListValue();
1450 for (size_t j
= 0; j
< entry
->webkit_bugs().size(); ++j
) {
1451 webkit_bugs
->Append(new base::FundamentalValue(entry
->webkit_bugs()[j
]));
1453 problem
->Set("webkitBugs", webkit_bugs
);
1455 base::ListValue
* features
= new base::ListValue();
1456 entry
->GetFeatureNames(features
, feature_map_
, supports_feature_type_all_
);
1457 problem
->Set("affectedGpuSettings", features
);
1459 DCHECK(tag
== "workarounds" || tag
== "disabledFeatures");
1460 problem
->SetString("tag", tag
);
1462 problem_list
->Append(problem
);
1466 size_t GpuControlList::num_entries() const {
1467 return entries_
.size();
1470 uint32
GpuControlList::max_entry_id() const {
1471 return max_entry_id_
;
1474 std::string
GpuControlList::version() const {
1478 GpuControlList::OsType
GpuControlList::GetOsType() {
1479 #if defined(OS_CHROMEOS)
1481 #elif defined(OS_WIN)
1483 #elif defined(OS_ANDROID)
1485 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
1487 #elif defined(OS_MACOSX)
1494 void GpuControlList::Clear() {
1496 active_entries_
.clear();
1501 GpuControlList::NumericOp
GpuControlList::StringToNumericOp(
1502 const std::string
& op
) {
1515 if (op
== "between")
1520 void GpuControlList::AddSupportedFeature(
1521 const std::string
& feature_name
, int feature_id
) {
1522 feature_map_
[feature_name
] = feature_id
;
1525 void GpuControlList::set_supports_feature_type_all(bool supported
) {
1526 supports_feature_type_all_
= supported
;