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::ListValue
* disabled_extensions
;
432 if (value
->GetList("disabled_extensions", &disabled_extensions
)) {
433 for (size_t i
= 0; i
< disabled_extensions
->GetSize(); ++i
) {
434 std::string disabled_extension
;
435 if (disabled_extensions
->GetString(i
, &disabled_extension
)) {
436 entry
->disabled_extensions_
.push_back(disabled_extension
);
438 LOG(WARNING
) << "Malformed disabled_extensions entry " << entry
->id();
442 dictionary_entry_count
++;
445 const base::DictionaryValue
* os_value
= NULL
;
446 if (value
->GetDictionary("os", &os_value
)) {
448 std::string os_version_op
= "any";
449 std::string os_version_string
;
450 std::string os_version_string2
;
451 os_value
->GetString("type", &os_type
);
452 const base::DictionaryValue
* os_version_value
= NULL
;
453 if (os_value
->GetDictionary("version", &os_version_value
)) {
454 os_version_value
->GetString(kOp
, &os_version_op
);
455 os_version_value
->GetString("value", &os_version_string
);
456 os_version_value
->GetString("value2", &os_version_string2
);
458 if (!entry
->SetOsInfo(os_type
, os_version_op
, os_version_string
,
459 os_version_string2
)) {
460 LOG(WARNING
) << "Malformed os entry " << entry
->id();
463 dictionary_entry_count
++;
466 std::string vendor_id
;
467 if (value
->GetString("vendor_id", &vendor_id
)) {
468 if (!entry
->SetVendorId(vendor_id
)) {
469 LOG(WARNING
) << "Malformed vendor_id entry " << entry
->id();
472 dictionary_entry_count
++;
475 const base::ListValue
* device_id_list
;
476 if (value
->GetList("device_id", &device_id_list
)) {
477 for (size_t i
= 0; i
< device_id_list
->GetSize(); ++i
) {
478 std::string device_id
;
479 if (!device_id_list
->GetString(i
, &device_id
) ||
480 !entry
->AddDeviceId(device_id
)) {
481 LOG(WARNING
) << "Malformed device_id entry " << entry
->id();
485 dictionary_entry_count
++;
488 std::string multi_gpu_style
;
489 if (value
->GetString("multi_gpu_style", &multi_gpu_style
)) {
490 if (!entry
->SetMultiGpuStyle(multi_gpu_style
)) {
491 LOG(WARNING
) << "Malformed multi_gpu_style entry " << entry
->id();
494 dictionary_entry_count
++;
497 std::string multi_gpu_category
;
498 if (value
->GetString("multi_gpu_category", &multi_gpu_category
)) {
499 if (!entry
->SetMultiGpuCategory(multi_gpu_category
)) {
500 LOG(WARNING
) << "Malformed multi_gpu_category entry " << entry
->id();
503 dictionary_entry_count
++;
506 std::string driver_vendor_value
;
507 if (value
->GetString("driver_vendor", &driver_vendor_value
)) {
508 if (!entry
->SetDriverVendorInfo(driver_vendor_value
)) {
509 LOG(WARNING
) << "Malformed driver_vendor entry " << entry
->id();
512 dictionary_entry_count
++;
515 const base::DictionaryValue
* driver_version_value
= NULL
;
516 if (value
->GetDictionary("driver_version", &driver_version_value
)) {
517 std::string driver_version_op
= "any";
518 std::string driver_version_style
;
519 std::string driver_version_string
;
520 std::string driver_version_string2
;
521 driver_version_value
->GetString(kOp
, &driver_version_op
);
522 driver_version_value
->GetString("style", &driver_version_style
);
523 driver_version_value
->GetString("value", &driver_version_string
);
524 driver_version_value
->GetString("value2", &driver_version_string2
);
525 if (!entry
->SetDriverVersionInfo(driver_version_op
,
526 driver_version_style
,
527 driver_version_string
,
528 driver_version_string2
)) {
529 LOG(WARNING
) << "Malformed driver_version entry " << entry
->id();
532 dictionary_entry_count
++;
535 const base::DictionaryValue
* driver_date_value
= NULL
;
536 if (value
->GetDictionary("driver_date", &driver_date_value
)) {
537 std::string driver_date_op
= "any";
538 std::string driver_date_string
;
539 std::string driver_date_string2
;
540 driver_date_value
->GetString(kOp
, &driver_date_op
);
541 driver_date_value
->GetString("value", &driver_date_string
);
542 driver_date_value
->GetString("value2", &driver_date_string2
);
543 if (!entry
->SetDriverDateInfo(driver_date_op
, driver_date_string
,
544 driver_date_string2
)) {
545 LOG(WARNING
) << "Malformed driver_date entry " << entry
->id();
548 dictionary_entry_count
++;
552 if (value
->GetString("gl_type", &gl_type
)) {
553 if (!entry
->SetGLType(gl_type
)) {
554 LOG(WARNING
) << "Malformed gl_type entry " << entry
->id();
557 dictionary_entry_count
++;
560 const base::DictionaryValue
* gl_version_value
= NULL
;
561 if (value
->GetDictionary("gl_version", &gl_version_value
)) {
562 std::string version_op
= "any";
563 std::string version_string
;
564 std::string version_string2
;
565 gl_version_value
->GetString(kOp
, &version_op
);
566 gl_version_value
->GetString("value", &version_string
);
567 gl_version_value
->GetString("value2", &version_string2
);
568 if (!entry
->SetGLVersionInfo(
569 version_op
, version_string
, version_string2
)) {
570 LOG(WARNING
) << "Malformed gl_version entry " << entry
->id();
573 dictionary_entry_count
++;
576 std::string gl_vendor_value
;
577 if (value
->GetString("gl_vendor", &gl_vendor_value
)) {
578 if (!entry
->SetGLVendorInfo(gl_vendor_value
)) {
579 LOG(WARNING
) << "Malformed gl_vendor entry " << entry
->id();
582 dictionary_entry_count
++;
585 std::string gl_renderer_value
;
586 if (value
->GetString("gl_renderer", &gl_renderer_value
)) {
587 if (!entry
->SetGLRendererInfo(gl_renderer_value
)) {
588 LOG(WARNING
) << "Malformed gl_renderer entry " << entry
->id();
591 dictionary_entry_count
++;
594 std::string gl_extensions_value
;
595 if (value
->GetString("gl_extensions", &gl_extensions_value
)) {
596 if (!entry
->SetGLExtensionsInfo(gl_extensions_value
)) {
597 LOG(WARNING
) << "Malformed gl_extensions entry " << entry
->id();
600 dictionary_entry_count
++;
603 const base::DictionaryValue
* gl_reset_notification_strategy_value
= NULL
;
604 if (value
->GetDictionary("gl_reset_notification_strategy",
605 &gl_reset_notification_strategy_value
)) {
607 std::string int_value
;
608 std::string int_value2
;
609 gl_reset_notification_strategy_value
->GetString(kOp
, &op
);
610 gl_reset_notification_strategy_value
->GetString("value", &int_value
);
611 gl_reset_notification_strategy_value
->GetString("value2", &int_value2
);
612 if (!entry
->SetGLResetNotificationStrategyInfo(
613 op
, int_value
, int_value2
)) {
614 LOG(WARNING
) << "Malformed gl_reset_notification_strategy entry "
618 dictionary_entry_count
++;
621 std::string cpu_brand_value
;
622 if (value
->GetString("cpu_info", &cpu_brand_value
)) {
623 if (!entry
->SetCpuBrand(cpu_brand_value
)) {
624 LOG(WARNING
) << "Malformed cpu_brand entry " << entry
->id();
627 dictionary_entry_count
++;
630 const base::DictionaryValue
* perf_graphics_value
= NULL
;
631 if (value
->GetDictionary("perf_graphics", &perf_graphics_value
)) {
633 std::string float_value
;
634 std::string float_value2
;
635 perf_graphics_value
->GetString(kOp
, &op
);
636 perf_graphics_value
->GetString("value", &float_value
);
637 perf_graphics_value
->GetString("value2", &float_value2
);
638 if (!entry
->SetPerfGraphicsInfo(op
, float_value
, float_value2
)) {
639 LOG(WARNING
) << "Malformed perf_graphics entry " << entry
->id();
642 dictionary_entry_count
++;
645 const base::DictionaryValue
* perf_gaming_value
= NULL
;
646 if (value
->GetDictionary("perf_gaming", &perf_gaming_value
)) {
648 std::string float_value
;
649 std::string float_value2
;
650 perf_gaming_value
->GetString(kOp
, &op
);
651 perf_gaming_value
->GetString("value", &float_value
);
652 perf_gaming_value
->GetString("value2", &float_value2
);
653 if (!entry
->SetPerfGamingInfo(op
, float_value
, float_value2
)) {
654 LOG(WARNING
) << "Malformed perf_gaming entry " << entry
->id();
657 dictionary_entry_count
++;
660 const base::DictionaryValue
* perf_overall_value
= NULL
;
661 if (value
->GetDictionary("perf_overall", &perf_overall_value
)) {
663 std::string float_value
;
664 std::string float_value2
;
665 perf_overall_value
->GetString(kOp
, &op
);
666 perf_overall_value
->GetString("value", &float_value
);
667 perf_overall_value
->GetString("value2", &float_value2
);
668 if (!entry
->SetPerfOverallInfo(op
, float_value
, float_value2
)) {
669 LOG(WARNING
) << "Malformed perf_overall entry " << entry
->id();
672 dictionary_entry_count
++;
675 const base::ListValue
* machine_model_name_list
;
676 if (value
->GetList("machine_model_name", &machine_model_name_list
)) {
677 for (size_t i
= 0; i
< machine_model_name_list
->GetSize(); ++i
) {
678 std::string model_name
;
679 if (!machine_model_name_list
->GetString(i
, &model_name
) ||
680 !entry
->AddMachineModelName(model_name
)) {
681 LOG(WARNING
) << "Malformed machine_model_name entry " << entry
->id();
685 dictionary_entry_count
++;
688 const base::DictionaryValue
* machine_model_version_value
= NULL
;
689 if (value
->GetDictionary(
690 "machine_model_version", &machine_model_version_value
)) {
691 std::string version_op
= "any";
692 std::string version_string
;
693 std::string version_string2
;
694 machine_model_version_value
->GetString(kOp
, &version_op
);
695 machine_model_version_value
->GetString("value", &version_string
);
696 machine_model_version_value
->GetString("value2", &version_string2
);
697 if (!entry
->SetMachineModelVersionInfo(
698 version_op
, version_string
, version_string2
)) {
699 LOG(WARNING
) << "Malformed machine_model_version entry " << entry
->id();
702 dictionary_entry_count
++;
705 const base::DictionaryValue
* gpu_count_value
= NULL
;
706 if (value
->GetDictionary("gpu_count", &gpu_count_value
)) {
708 std::string int_value
;
709 std::string int_value2
;
710 gpu_count_value
->GetString(kOp
, &op
);
711 gpu_count_value
->GetString("value", &int_value
);
712 gpu_count_value
->GetString("value2", &int_value2
);
713 if (!entry
->SetGpuCountInfo(op
, int_value
, int_value2
)) {
714 LOG(WARNING
) << "Malformed gpu_count entry " << entry
->id();
717 dictionary_entry_count
++;
720 bool direct_rendering
;
721 if (value
->GetBoolean("direct_rendering", &direct_rendering
)) {
722 entry
->SetDirectRenderingInfo(direct_rendering
);
723 dictionary_entry_count
++;
727 const base::ListValue
* feature_value
= NULL
;
728 if (value
->GetList("features", &feature_value
)) {
729 std::vector
<std::string
> feature_list
;
730 for (size_t i
= 0; i
< feature_value
->GetSize(); ++i
) {
732 if (feature_value
->GetString(i
, &feature
)) {
733 feature_list
.push_back(feature
);
735 LOG(WARNING
) << "Malformed feature entry " << entry
->id();
739 if (!entry
->SetFeatures(
740 feature_list
, feature_map
, supports_feature_type_all
)) {
741 LOG(WARNING
) << "Malformed feature entry " << entry
->id();
744 dictionary_entry_count
++;
749 const base::ListValue
* exception_list_value
= NULL
;
750 if (value
->GetList("exceptions", &exception_list_value
)) {
751 for (size_t i
= 0; i
< exception_list_value
->GetSize(); ++i
) {
752 const base::DictionaryValue
* exception_value
= NULL
;
753 if (!exception_list_value
->GetDictionary(i
, &exception_value
)) {
754 LOG(WARNING
) << "Malformed exceptions entry " << entry
->id();
757 ScopedGpuControlListEntry
exception(GetEntryFromValue(
758 exception_value
, false, feature_map
, supports_feature_type_all
));
759 if (exception
.get() == NULL
) {
760 LOG(WARNING
) << "Malformed exceptions entry " << entry
->id();
763 // Exception should inherit vendor_id from parent, otherwise if only
764 // device_ids are specified in Exception, the info will be incomplete.
765 if (exception
->vendor_id_
== 0 && entry
->vendor_id_
!= 0)
766 exception
->vendor_id_
= entry
->vendor_id_
;
767 entry
->AddException(exception
);
769 dictionary_entry_count
++;
773 if (value
->size() != dictionary_entry_count
) {
774 LOG(WARNING
) << "Entry with unknown fields " << entry
->id();
778 // If GL_VERSION is specified, but no info about whether it's GL or GLES,
779 // we use the default for the platform. See GLType enum declaration.
780 if (entry
->gl_version_info_
.get() != NULL
&& entry
->gl_type_
== kGLTypeNone
)
781 entry
->gl_type_
= GetDefaultGLType();
786 GpuControlList::GpuControlListEntry::GpuControlListEntry()
790 multi_gpu_style_(kMultiGpuStyleNone
),
791 multi_gpu_category_(kMultiGpuCategoryPrimary
),
792 gl_type_(kGLTypeNone
) {
795 GpuControlList::GpuControlListEntry::~GpuControlListEntry() { }
797 bool GpuControlList::GpuControlListEntry::SetId(uint32 id
) {
805 void GpuControlList::GpuControlListEntry::SetDisabled(bool disabled
) {
806 disabled_
= disabled
;
809 bool GpuControlList::GpuControlListEntry::SetOsInfo(
810 const std::string
& os
,
811 const std::string
& version_op
,
812 const std::string
& version_string
,
813 const std::string
& version_string2
) {
814 os_info_
.reset(new OsInfo(os
, version_op
, version_string
, version_string2
));
815 return os_info_
->IsValid();
818 bool GpuControlList::GpuControlListEntry::SetVendorId(
819 const std::string
& vendor_id_string
) {
821 return base::HexStringToUInt(vendor_id_string
, &vendor_id_
) &&
825 bool GpuControlList::GpuControlListEntry::AddDeviceId(
826 const std::string
& device_id_string
) {
827 uint32 device_id
= 0;
828 if (base::HexStringToUInt(device_id_string
, &device_id
) && device_id
!= 0) {
829 device_id_list_
.push_back(device_id
);
835 bool GpuControlList::GpuControlListEntry::SetMultiGpuStyle(
836 const std::string
& multi_gpu_style_string
) {
837 MultiGpuStyle style
= StringToMultiGpuStyle(multi_gpu_style_string
);
838 if (style
== kMultiGpuStyleNone
)
840 multi_gpu_style_
= style
;
844 bool GpuControlList::GpuControlListEntry::SetMultiGpuCategory(
845 const std::string
& multi_gpu_category_string
) {
846 MultiGpuCategory category
=
847 StringToMultiGpuCategory(multi_gpu_category_string
);
848 if (category
== kMultiGpuCategoryNone
)
850 multi_gpu_category_
= category
;
854 bool GpuControlList::GpuControlListEntry::SetGLType(
855 const std::string
& gl_type_string
) {
856 GLType gl_type
= StringToGLType(gl_type_string
);
857 if (gl_type
== kGLTypeNone
)
863 bool GpuControlList::GpuControlListEntry::SetDriverVendorInfo(
864 const std::string
& vendor_value
) {
865 driver_vendor_info_
= vendor_value
;
866 return !driver_vendor_info_
.empty();
869 bool GpuControlList::GpuControlListEntry::SetDriverVersionInfo(
870 const std::string
& version_op
,
871 const std::string
& version_style
,
872 const std::string
& version_string
,
873 const std::string
& version_string2
) {
874 driver_version_info_
.reset(new VersionInfo(
875 version_op
, version_style
, version_string
, version_string2
));
876 return driver_version_info_
->IsValid();
879 bool GpuControlList::GpuControlListEntry::SetDriverDateInfo(
880 const std::string
& date_op
,
881 const std::string
& date_string
,
882 const std::string
& date_string2
) {
883 driver_date_info_
.reset(
884 new VersionInfo(date_op
, std::string(), date_string
, date_string2
));
885 return driver_date_info_
->IsValid();
888 bool GpuControlList::GpuControlListEntry::SetGLVersionInfo(
889 const std::string
& version_op
,
890 const std::string
& version_string
,
891 const std::string
& version_string2
) {
892 gl_version_info_
.reset(new VersionInfo(
893 version_op
, std::string(), version_string
, version_string2
));
894 return gl_version_info_
->IsValid();
897 bool GpuControlList::GpuControlListEntry::SetGLVendorInfo(
898 const std::string
& vendor_value
) {
899 gl_vendor_info_
= vendor_value
;
900 return !gl_vendor_info_
.empty();
903 bool GpuControlList::GpuControlListEntry::SetGLRendererInfo(
904 const std::string
& renderer_value
) {
905 gl_renderer_info_
= renderer_value
;
906 return !gl_renderer_info_
.empty();
909 bool GpuControlList::GpuControlListEntry::SetGLExtensionsInfo(
910 const std::string
& extensions_value
) {
911 gl_extensions_info_
= extensions_value
;
912 return !gl_extensions_info_
.empty();
915 bool GpuControlList::GpuControlListEntry::SetGLResetNotificationStrategyInfo(
916 const std::string
& op
,
917 const std::string
& int_string
,
918 const std::string
& int_string2
) {
919 gl_reset_notification_strategy_info_
.reset(
920 new IntInfo(op
, int_string
, int_string2
));
921 return gl_reset_notification_strategy_info_
->IsValid();
924 bool GpuControlList::GpuControlListEntry::SetCpuBrand(
925 const std::string
& cpu_value
) {
926 cpu_brand_
= cpu_value
;
927 return !cpu_brand_
.empty();
930 bool GpuControlList::GpuControlListEntry::SetPerfGraphicsInfo(
931 const std::string
& op
,
932 const std::string
& float_string
,
933 const std::string
& float_string2
) {
934 perf_graphics_info_
.reset(new FloatInfo(op
, float_string
, float_string2
));
935 return perf_graphics_info_
->IsValid();
938 bool GpuControlList::GpuControlListEntry::SetPerfGamingInfo(
939 const std::string
& op
,
940 const std::string
& float_string
,
941 const std::string
& float_string2
) {
942 perf_gaming_info_
.reset(new FloatInfo(op
, float_string
, float_string2
));
943 return perf_gaming_info_
->IsValid();
946 bool GpuControlList::GpuControlListEntry::SetPerfOverallInfo(
947 const std::string
& op
,
948 const std::string
& float_string
,
949 const std::string
& float_string2
) {
950 perf_overall_info_
.reset(new FloatInfo(op
, float_string
, float_string2
));
951 return perf_overall_info_
->IsValid();
954 bool GpuControlList::GpuControlListEntry::AddMachineModelName(
955 const std::string
& model_name
) {
956 if (model_name
.empty())
958 machine_model_name_list_
.push_back(model_name
);
962 bool GpuControlList::GpuControlListEntry::SetMachineModelVersionInfo(
963 const std::string
& version_op
,
964 const std::string
& version_string
,
965 const std::string
& version_string2
) {
966 machine_model_version_info_
.reset(new VersionInfo(
967 version_op
, std::string(), version_string
, version_string2
));
968 return machine_model_version_info_
->IsValid();
971 bool GpuControlList::GpuControlListEntry::SetGpuCountInfo(
972 const std::string
& op
,
973 const std::string
& int_string
,
974 const std::string
& int_string2
) {
975 gpu_count_info_
.reset(new IntInfo(op
, int_string
, int_string2
));
976 return gpu_count_info_
->IsValid();
979 void GpuControlList::GpuControlListEntry::SetDirectRenderingInfo(bool value
) {
980 direct_rendering_info_
.reset(new BoolInfo(value
));
983 bool GpuControlList::GpuControlListEntry::SetFeatures(
984 const std::vector
<std::string
>& feature_strings
,
985 const FeatureMap
& feature_map
,
986 bool supports_feature_type_all
) {
987 size_t size
= feature_strings
.size();
991 for (size_t i
= 0; i
< size
; ++i
) {
993 if (supports_feature_type_all
&& feature_strings
[i
] == "all") {
994 for (FeatureMap::const_iterator iter
= feature_map
.begin();
995 iter
!= feature_map
.end(); ++iter
)
996 features_
.insert(iter
->second
);
999 if (!StringToFeature(feature_strings
[i
], &feature
, feature_map
)) {
1003 features_
.insert(feature
);
1008 void GpuControlList::GpuControlListEntry::AddException(
1009 ScopedGpuControlListEntry exception
) {
1010 exceptions_
.push_back(exception
);
1013 bool GpuControlList::GpuControlListEntry::GLVersionInfoMismatch(
1014 const std::string
& gl_version
) const {
1015 if (gl_version
.empty())
1018 if (gl_version_info_
.get() == NULL
&& gl_type_
== kGLTypeNone
)
1021 std::vector
<std::string
> segments
;
1022 base::SplitString(gl_version
, ' ', &segments
);
1024 GLType gl_type
= kGLTypeNone
;
1025 if (segments
.size() > 2 &&
1026 segments
[0] == "OpenGL" && segments
[1] == "ES") {
1027 bool full_match
= RE2::FullMatch(segments
[2], "([\\d.]+).*", &number
);
1030 gl_type
= kGLTypeGLES
;
1031 if (segments
.size() > 3 &&
1032 StartsWithASCII(segments
[3], "(ANGLE", false)) {
1033 gl_type
= kGLTypeANGLE
;
1036 number
= segments
[0];
1037 gl_type
= kGLTypeGL
;
1040 if (gl_type_
!= kGLTypeNone
&& gl_type_
!= gl_type
)
1042 if (gl_version_info_
.get() != NULL
&& !gl_version_info_
->Contains(number
))
1048 GpuControlList::GpuControlListEntry::MultiGpuStyle
1049 GpuControlList::GpuControlListEntry::StringToMultiGpuStyle(
1050 const std::string
& style
) {
1051 if (style
== kMultiGpuStyleStringOptimus
)
1052 return kMultiGpuStyleOptimus
;
1053 if (style
== kMultiGpuStyleStringAMDSwitchable
)
1054 return kMultiGpuStyleAMDSwitchable
;
1055 if (style
== kMultiGpuStyleStringAMDSwitchableIntegrated
)
1056 return kMultiGpuStyleAMDSwitchableIntegrated
;
1057 if (style
== kMultiGpuStyleStringAMDSwitchableDiscrete
)
1058 return kMultiGpuStyleAMDSwitchableDiscrete
;
1059 return kMultiGpuStyleNone
;
1063 GpuControlList::GpuControlListEntry::MultiGpuCategory
1064 GpuControlList::GpuControlListEntry::StringToMultiGpuCategory(
1065 const std::string
& category
) {
1066 if (category
== kMultiGpuCategoryStringPrimary
)
1067 return kMultiGpuCategoryPrimary
;
1068 if (category
== kMultiGpuCategoryStringSecondary
)
1069 return kMultiGpuCategorySecondary
;
1070 if (category
== kMultiGpuCategoryStringActive
)
1071 return kMultiGpuCategoryActive
;
1072 if (category
== kMultiGpuCategoryStringAny
)
1073 return kMultiGpuCategoryAny
;
1074 return kMultiGpuCategoryNone
;
1078 GpuControlList::GpuControlListEntry::GLType
1079 GpuControlList::GpuControlListEntry::StringToGLType(
1080 const std::string
& gl_type
) {
1081 if (gl_type
== kGLTypeStringGL
)
1083 if (gl_type
== kGLTypeStringGLES
)
1085 if (gl_type
== kGLTypeStringANGLE
)
1086 return kGLTypeANGLE
;
1091 GpuControlList::GpuControlListEntry::GLType
1092 GpuControlList::GpuControlListEntry::GetDefaultGLType() {
1093 #if defined(OS_CHROMEOS)
1095 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
1097 #elif defined(OS_MACOSX)
1099 #elif defined(OS_WIN)
1100 return kGLTypeANGLE
;
1101 #elif defined(OS_ANDROID)
1108 void GpuControlList::GpuControlListEntry::LogControlListMatch(
1109 const std::string
& control_list_logging_name
) const {
1110 static const char kControlListMatchMessage
[] =
1111 "Control list match for rule #%u in %s.";
1112 VLOG(1) << base::StringPrintf(kControlListMatchMessage
, id_
,
1113 control_list_logging_name
.c_str());
1116 bool GpuControlList::GpuControlListEntry::Contains(
1117 OsType os_type
, const std::string
& os_version
,
1118 const GPUInfo
& gpu_info
) const {
1119 DCHECK(os_type
!= kOsAny
);
1120 if (os_info_
.get() != NULL
&& !os_info_
->Contains(os_type
, os_version
))
1122 if (vendor_id_
!= 0) {
1123 std::vector
<GPUInfo::GPUDevice
> candidates
;
1124 switch (multi_gpu_category_
) {
1125 case kMultiGpuCategoryPrimary
:
1126 candidates
.push_back(gpu_info
.gpu
);
1128 case kMultiGpuCategorySecondary
:
1129 candidates
= gpu_info
.secondary_gpus
;
1131 case kMultiGpuCategoryAny
:
1132 candidates
= gpu_info
.secondary_gpus
;
1133 candidates
.push_back(gpu_info
.gpu
);
1135 case kMultiGpuCategoryActive
:
1136 if (gpu_info
.gpu
.active
)
1137 candidates
.push_back(gpu_info
.gpu
);
1138 for (size_t ii
= 0; ii
< gpu_info
.secondary_gpus
.size(); ++ii
) {
1139 if (gpu_info
.secondary_gpus
[ii
].active
)
1140 candidates
.push_back(gpu_info
.secondary_gpus
[ii
]);
1146 GPUInfo::GPUDevice gpu
;
1147 gpu
.vendor_id
= vendor_id_
;
1149 if (device_id_list_
.empty()) {
1150 for (size_t ii
= 0; ii
< candidates
.size(); ++ii
) {
1151 if (gpu
.vendor_id
== candidates
[ii
].vendor_id
) {
1157 for (size_t ii
= 0; ii
< device_id_list_
.size(); ++ii
) {
1158 gpu
.device_id
= device_id_list_
[ii
];
1159 for (size_t jj
= 0; jj
< candidates
.size(); ++jj
) {
1160 if (gpu
.vendor_id
== candidates
[jj
].vendor_id
&&
1161 gpu
.device_id
== candidates
[jj
].device_id
) {
1171 switch (multi_gpu_style_
) {
1172 case kMultiGpuStyleOptimus
:
1173 if (!gpu_info
.optimus
)
1176 case kMultiGpuStyleAMDSwitchable
:
1177 if (!gpu_info
.amd_switchable
)
1180 case kMultiGpuStyleAMDSwitchableDiscrete
:
1181 if (!gpu_info
.amd_switchable
)
1183 // The discrete GPU is always the primary GPU.
1184 // This is guaranteed by GpuInfoCollector.
1185 if (!gpu_info
.gpu
.active
)
1188 case kMultiGpuStyleAMDSwitchableIntegrated
:
1189 if (!gpu_info
.amd_switchable
)
1191 // Assume the integrated GPU is the first in the secondary GPU list.
1192 if (gpu_info
.secondary_gpus
.size() == 0 ||
1193 !gpu_info
.secondary_gpus
[0].active
)
1196 case kMultiGpuStyleNone
:
1199 if (StringMismatch(gpu_info
.driver_vendor
, driver_vendor_info_
))
1201 if (driver_version_info_
.get() != NULL
&& !gpu_info
.driver_version
.empty()) {
1202 if (!driver_version_info_
->Contains(gpu_info
.driver_version
))
1205 if (driver_date_info_
.get() != NULL
&& !gpu_info
.driver_date
.empty()) {
1206 if (!driver_date_info_
->Contains(gpu_info
.driver_date
, '-'))
1209 if (GLVersionInfoMismatch(gpu_info
.gl_version
))
1211 if (StringMismatch(gpu_info
.gl_vendor
, gl_vendor_info_
))
1213 if (StringMismatch(gpu_info
.gl_renderer
, gl_renderer_info_
))
1215 if (StringMismatch(gpu_info
.gl_extensions
, gl_extensions_info_
))
1217 if (gl_reset_notification_strategy_info_
.get() != NULL
&&
1218 !gl_reset_notification_strategy_info_
->Contains(
1219 gpu_info
.gl_reset_notification_strategy
))
1221 if (!machine_model_name_list_
.empty()) {
1222 if (gpu_info
.machine_model_name
.empty())
1224 bool found_match
= false;
1225 for (size_t ii
= 0; ii
< machine_model_name_list_
.size(); ++ii
) {
1226 if (RE2::FullMatch(gpu_info
.machine_model_name
,
1227 machine_model_name_list_
[ii
])) {
1235 if (machine_model_version_info_
.get() != NULL
&&
1236 (gpu_info
.machine_model_version
.empty() ||
1237 !machine_model_version_info_
->Contains(gpu_info
.machine_model_version
)))
1239 if (gpu_count_info_
.get() != NULL
&&
1240 !gpu_count_info_
->Contains(gpu_info
.secondary_gpus
.size() + 1))
1242 if (direct_rendering_info_
.get() != NULL
&&
1243 !direct_rendering_info_
->Contains(gpu_info
.direct_rendering
))
1245 if (!cpu_brand_
.empty()) {
1247 if (StringMismatch(cpu_info
.cpu_brand(), cpu_brand_
))
1251 for (size_t i
= 0; i
< exceptions_
.size(); ++i
) {
1252 if (exceptions_
[i
]->Contains(os_type
, os_version
, gpu_info
) &&
1253 !exceptions_
[i
]->NeedsMoreInfo(gpu_info
))
1259 bool GpuControlList::GpuControlListEntry::NeedsMoreInfo(
1260 const GPUInfo
& gpu_info
) const {
1261 // We only check for missing info that might be collected with a gl context.
1262 // If certain info is missing due to some error, say, we fail to collect
1263 // vendor_id/device_id, then even if we launch GPU process and create a gl
1264 // context, we won't gather such missing info, so we still return false.
1265 if (!driver_vendor_info_
.empty() && gpu_info
.driver_vendor
.empty())
1267 if (driver_version_info_
.get() && gpu_info
.driver_version
.empty())
1269 if (!gl_vendor_info_
.empty() && gpu_info
.gl_vendor
.empty())
1271 if (!gl_renderer_info_
.empty() && gpu_info
.gl_renderer
.empty())
1273 for (size_t i
= 0; i
< exceptions_
.size(); ++i
) {
1274 if (exceptions_
[i
]->NeedsMoreInfo(gpu_info
))
1280 GpuControlList::OsType
GpuControlList::GpuControlListEntry::GetOsType() const {
1281 if (os_info_
.get() == NULL
)
1283 return os_info_
->type();
1286 uint32
GpuControlList::GpuControlListEntry::id() const {
1290 bool GpuControlList::GpuControlListEntry::disabled() const {
1294 const std::set
<int>& GpuControlList::GpuControlListEntry::features() const {
1298 void GpuControlList::GpuControlListEntry::GetFeatureNames(
1299 base::ListValue
* feature_names
,
1300 const FeatureMap
& feature_map
,
1301 bool supports_feature_type_all
) const {
1302 DCHECK(feature_names
);
1303 if (supports_feature_type_all
&& features_
.size() == feature_map
.size()) {
1304 feature_names
->AppendString("all");
1307 for (FeatureMap::const_iterator iter
= feature_map
.begin();
1308 iter
!= feature_map
.end(); ++iter
) {
1309 if (features_
.count(iter
->second
) > 0)
1310 feature_names
->AppendString(iter
->first
);
1315 bool GpuControlList::GpuControlListEntry::StringToFeature(
1316 const std::string
& feature_name
, int* feature_id
,
1317 const FeatureMap
& feature_map
) {
1318 FeatureMap::const_iterator iter
= feature_map
.find(feature_name
);
1319 if (iter
!= feature_map
.end()) {
1320 *feature_id
= iter
->second
;
1326 GpuControlList::GpuControlList()
1328 needs_more_info_(false),
1329 supports_feature_type_all_(false),
1330 control_list_logging_enabled_(false) {
1333 GpuControlList::~GpuControlList() {
1337 bool GpuControlList::LoadList(
1338 const std::string
& json_context
,
1339 GpuControlList::OsFilter os_filter
) {
1340 scoped_ptr
<base::Value
> root
;
1341 root
.reset(base::JSONReader::Read(json_context
));
1342 if (root
.get() == NULL
|| !root
->IsType(base::Value::TYPE_DICTIONARY
))
1345 base::DictionaryValue
* root_dictionary
=
1346 static_cast<base::DictionaryValue
*>(root
.get());
1347 DCHECK(root_dictionary
);
1348 return LoadList(*root_dictionary
, os_filter
);
1351 bool GpuControlList::LoadList(const base::DictionaryValue
& parsed_json
,
1352 GpuControlList::OsFilter os_filter
) {
1353 std::vector
<ScopedGpuControlListEntry
> entries
;
1355 parsed_json
.GetString("version", &version_
);
1356 std::vector
<std::string
> pieces
;
1357 if (!ProcessVersionString(version_
, '.', &pieces
))
1360 const base::ListValue
* list
= NULL
;
1361 if (!parsed_json
.GetList("entries", &list
))
1364 uint32 max_entry_id
= 0;
1365 for (size_t i
= 0; i
< list
->GetSize(); ++i
) {
1366 const base::DictionaryValue
* list_item
= NULL
;
1367 bool valid
= list
->GetDictionary(i
, &list_item
);
1368 if (!valid
|| list_item
== NULL
)
1370 ScopedGpuControlListEntry
entry(GpuControlListEntry::GetEntryFromValue(
1371 list_item
, true, feature_map_
, supports_feature_type_all_
));
1372 if (entry
.get() == NULL
)
1374 if (entry
->id() > max_entry_id
)
1375 max_entry_id
= entry
->id();
1376 entries
.push_back(entry
);
1380 OsType my_os
= GetOsType();
1381 for (size_t i
= 0; i
< entries
.size(); ++i
) {
1382 OsType entry_os
= entries
[i
]->GetOsType();
1383 if (os_filter
== GpuControlList::kAllOs
||
1384 entry_os
== kOsAny
|| entry_os
== my_os
)
1385 entries_
.push_back(entries
[i
]);
1387 max_entry_id_
= max_entry_id
;
1391 std::set
<int> GpuControlList::MakeDecision(
1392 GpuControlList::OsType os
,
1393 std::string os_version
,
1394 const GPUInfo
& gpu_info
) {
1395 active_entries_
.clear();
1396 std::set
<int> features
;
1398 needs_more_info_
= false;
1399 std::set
<int> possible_features
;
1403 if (os_version
.empty())
1404 os_version
= base::SysInfo::OperatingSystemVersion();
1406 for (size_t i
= 0; i
< entries_
.size(); ++i
) {
1407 if (entries_
[i
]->Contains(os
, os_version
, gpu_info
)) {
1408 bool needs_more_info
= entries_
[i
]->NeedsMoreInfo(gpu_info
);
1409 if (!entries_
[i
]->disabled()) {
1410 if (control_list_logging_enabled_
)
1411 entries_
[i
]->LogControlListMatch(control_list_logging_name_
);
1412 MergeFeatureSets(&possible_features
, entries_
[i
]->features());
1413 if (!needs_more_info
)
1414 MergeFeatureSets(&features
, entries_
[i
]->features());
1416 if (!needs_more_info
)
1417 active_entries_
.push_back(entries_
[i
]);
1421 if (possible_features
.size() > features
.size())
1422 needs_more_info_
= true;
1427 void GpuControlList::GetDecisionEntries(
1428 std::vector
<uint32
>* entry_ids
, bool disabled
) const {
1431 for (size_t i
= 0; i
< active_entries_
.size(); ++i
) {
1432 if (disabled
== active_entries_
[i
]->disabled())
1433 entry_ids
->push_back(active_entries_
[i
]->id());
1437 std::vector
<std::string
> GpuControlList::GetDisabledExtensions() {
1438 std::set
<std::string
> disabled_extensions
;
1439 for (size_t i
= 0; i
< active_entries_
.size(); ++i
) {
1440 GpuControlListEntry
* entry
= active_entries_
[i
].get();
1442 if (entry
->disabled())
1445 disabled_extensions
.insert(entry
->disabled_extensions().begin(),
1446 entry
->disabled_extensions().end());
1448 return std::vector
<std::string
>(disabled_extensions
.begin(),
1449 disabled_extensions
.end());
1452 void GpuControlList::GetReasons(base::ListValue
* problem_list
,
1453 const std::string
& tag
) const {
1454 DCHECK(problem_list
);
1455 for (size_t i
= 0; i
< active_entries_
.size(); ++i
) {
1456 GpuControlListEntry
* entry
= active_entries_
[i
].get();
1457 if (entry
->disabled())
1459 base::DictionaryValue
* problem
= new base::DictionaryValue();
1461 problem
->SetString("description", entry
->description());
1463 base::ListValue
* cr_bugs
= new base::ListValue();
1464 for (size_t j
= 0; j
< entry
->cr_bugs().size(); ++j
)
1465 cr_bugs
->Append(new base::FundamentalValue(entry
->cr_bugs()[j
]));
1466 problem
->Set("crBugs", cr_bugs
);
1468 base::ListValue
* webkit_bugs
= new base::ListValue();
1469 for (size_t j
= 0; j
< entry
->webkit_bugs().size(); ++j
) {
1470 webkit_bugs
->Append(new base::FundamentalValue(entry
->webkit_bugs()[j
]));
1472 problem
->Set("webkitBugs", webkit_bugs
);
1474 base::ListValue
* features
= new base::ListValue();
1475 entry
->GetFeatureNames(features
, feature_map_
, supports_feature_type_all_
);
1476 problem
->Set("affectedGpuSettings", features
);
1478 DCHECK(tag
== "workarounds" || tag
== "disabledFeatures");
1479 problem
->SetString("tag", tag
);
1481 problem_list
->Append(problem
);
1485 size_t GpuControlList::num_entries() const {
1486 return entries_
.size();
1489 uint32
GpuControlList::max_entry_id() const {
1490 return max_entry_id_
;
1493 std::string
GpuControlList::version() const {
1497 GpuControlList::OsType
GpuControlList::GetOsType() {
1498 #if defined(OS_CHROMEOS)
1500 #elif defined(OS_WIN)
1502 #elif defined(OS_ANDROID)
1504 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
1506 #elif defined(OS_MACOSX)
1513 void GpuControlList::Clear() {
1515 active_entries_
.clear();
1520 GpuControlList::NumericOp
GpuControlList::StringToNumericOp(
1521 const std::string
& op
) {
1534 if (op
== "between")
1539 void GpuControlList::AddSupportedFeature(
1540 const std::string
& feature_name
, int feature_id
) {
1541 feature_map_
[feature_name
] = feature_id
;
1544 void GpuControlList::set_supports_feature_type_all(bool supported
) {
1545 supports_feature_type_all_
= supported
;