Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: content/browser/gpu/gpu_blacklist.cc

Issue 11009011: Use the cpuid instruction to generate the CPU brand string. And (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/gpu/gpu_blacklist.h" 5 #include "content/browser/gpu/gpu_blacklist.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 #if defined(OS_MACOSX) 11 #if defined(OS_MACOSX)
12 #include "base/mac/mac_util.h" 12 #include "base/mac/mac_util.h"
13 #endif // OS_MACOSX 13 #endif // OS_MACOSX
14 14
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/string_split.h" 16 #include "base/string_split.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/sys_info.h" 18 #include "base/sys_info.h"
19 #include "base/cpu.h"
Zhenyao Mo 2012/10/01 19:04:33 You need to insert the include in the right place
19 #include "base/version.h" 20 #include "base/version.h"
20 #include "content/browser/gpu/gpu_util.h" 21 #include "content/browser/gpu/gpu_util.h"
21 #include "content/public/common/content_switches.h" 22 #include "content/public/common/content_switches.h"
22 #include "content/public/common/gpu_info.h" 23 #include "content/public/common/gpu_info.h"
23 24
24 using content::GpuFeatureType; 25 using content::GpuFeatureType;
25 using content::GpuSwitchingOption; 26 using content::GpuSwitchingOption;
26 27
27 namespace { 28 namespace {
28 29
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 std::string renderer_value; 572 std::string renderer_value;
572 gl_renderer_value->GetString("op", &renderer_op); 573 gl_renderer_value->GetString("op", &renderer_op);
573 gl_renderer_value->GetString("value", &renderer_value); 574 gl_renderer_value->GetString("value", &renderer_value);
574 if (!entry->SetGLRendererInfo(renderer_op, renderer_value)) { 575 if (!entry->SetGLRendererInfo(renderer_op, renderer_value)) {
575 LOG(WARNING) << "Malformed gl_renderer entry " << entry->id(); 576 LOG(WARNING) << "Malformed gl_renderer entry " << entry->id();
576 return NULL; 577 return NULL;
577 } 578 }
578 dictionary_entry_count++; 579 dictionary_entry_count++;
579 } 580 }
580 581
582 const DictionaryValue* cpu_info_value = NULL;
Zhenyao Mo 2012/10/01 19:04:33 cpu_brand_value, here and below.
583 if (value->GetDictionary("cpu_info", &cpu_info_value)) {
584 std::string cpu_op;
585 std::string cpu_value;
586 cpu_info_value->GetString("op", &cpu_op);
587 cpu_info_value->GetString("value", &cpu_value);
588 if (!entry->SetCpuInfo(cpu_op, cpu_value)) {
589 LOG(WARNING) << "Malformed cpu_info entry " << entry->id();
590 return NULL;
591 }
592 dictionary_entry_count++;
593 }
594
581 const DictionaryValue* perf_graphics_value = NULL; 595 const DictionaryValue* perf_graphics_value = NULL;
582 if (value->GetDictionary("perf_graphics", &perf_graphics_value)) { 596 if (value->GetDictionary("perf_graphics", &perf_graphics_value)) {
583 std::string op; 597 std::string op;
584 std::string float_value; 598 std::string float_value;
585 std::string float_value2; 599 std::string float_value2;
586 perf_graphics_value->GetString("op", &op); 600 perf_graphics_value->GetString("op", &op);
587 perf_graphics_value->GetString("value", &float_value); 601 perf_graphics_value->GetString("value", &float_value);
588 perf_graphics_value->GetString("value2", &float_value2); 602 perf_graphics_value->GetString("value2", &float_value2);
589 if (!entry->SetPerfGraphicsInfo(op, float_value, float_value2)) { 603 if (!entry->SetPerfGraphicsInfo(op, float_value, float_value2)) {
590 LOG(WARNING) << "Malformed perf_graphics entry " << entry->id(); 604 LOG(WARNING) << "Malformed perf_graphics entry " << entry->id();
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 } 853 }
840 854
841 bool GpuBlacklist::GpuBlacklistEntry::SetGLRendererInfo( 855 bool GpuBlacklist::GpuBlacklistEntry::SetGLRendererInfo(
842 const std::string& renderer_op, 856 const std::string& renderer_op,
843 const std::string& renderer_value) { 857 const std::string& renderer_value) {
844 gl_renderer_info_.reset( 858 gl_renderer_info_.reset(
845 new StringInfo(renderer_op, renderer_value)); 859 new StringInfo(renderer_op, renderer_value));
846 return gl_renderer_info_->IsValid(); 860 return gl_renderer_info_->IsValid();
847 } 861 }
848 862
863 bool GpuBlacklist::GpuBlacklistEntry::SetCpuInfo(
864 const std::string& cpu_op,
865 const std::string& cpu_value) {
866 cpu_info_.reset(
867 new StringInfo(cpu_op, cpu_value));
868 return cpu_info_->IsValid();
869 }
870
849 bool GpuBlacklist::GpuBlacklistEntry::SetPerfGraphicsInfo( 871 bool GpuBlacklist::GpuBlacklistEntry::SetPerfGraphicsInfo(
850 const std::string& op, 872 const std::string& op,
851 const std::string& float_string, 873 const std::string& float_string,
852 const std::string& float_string2) { 874 const std::string& float_string2) {
853 perf_graphics_info_.reset( 875 perf_graphics_info_.reset(
854 new FloatInfo(op, float_string, float_string2)); 876 new FloatInfo(op, float_string, float_string2));
855 return perf_graphics_info_->IsValid(); 877 return perf_graphics_info_->IsValid();
856 } 878 }
857 879
858 bool GpuBlacklist::GpuBlacklistEntry::SetPerfGamingInfo( 880 bool GpuBlacklist::GpuBlacklistEntry::SetPerfGamingInfo(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 if (perf_overall_info_.get() != NULL && 1063 if (perf_overall_info_.get() != NULL &&
1042 (gpu_info.performance_stats.overall == 0.0 || 1064 (gpu_info.performance_stats.overall == 0.0 ||
1043 !perf_overall_info_->Contains(gpu_info.performance_stats.overall))) 1065 !perf_overall_info_->Contains(gpu_info.performance_stats.overall)))
1044 return false; 1066 return false;
1045 if (machine_model_info_.get() != NULL && 1067 if (machine_model_info_.get() != NULL &&
1046 !machine_model_info_->Contains(machine_model_name, machine_model_version)) 1068 !machine_model_info_->Contains(machine_model_name, machine_model_version))
1047 return false; 1069 return false;
1048 if (gpu_count_info_.get() != NULL && 1070 if (gpu_count_info_.get() != NULL &&
1049 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1)) 1071 !gpu_count_info_->Contains(gpu_info.secondary_gpus.size() + 1))
1050 return false; 1072 return false;
1073 if (cpu_info_.get() != NULL) {
1074 base::CPU cpu_info;
Zhenyao Mo 2012/10/01 19:04:33 indent two spaces instead of four.
1075 if (!cpu_info_->Contains(cpu_info.cpu_brand()))
1076 return false;
Zhenyao Mo 2012/10/01 19:04:33 indent two spaces
1077 }
1078
1051 for (size_t i = 0; i < exceptions_.size(); ++i) { 1079 for (size_t i = 0; i < exceptions_.size(); ++i) {
1052 if (exceptions_[i]->Contains(os_type, os_version, machine_model_name, 1080 if (exceptions_[i]->Contains(os_type, os_version, machine_model_name,
1053 machine_model_version, gpu_info)) 1081 machine_model_version, gpu_info))
1054 return false; 1082 return false;
1055 } 1083 }
1056 return true; 1084 return true;
1057 } 1085 }
1058 1086
1059 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { 1087 GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const {
1060 if (os_info_.get() == NULL) 1088 if (os_info_.get() == NULL)
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 if (op == ">") 1374 if (op == ">")
1347 return kGT; 1375 return kGT;
1348 if (op == ">=") 1376 if (op == ">=")
1349 return kGE; 1377 return kGE;
1350 if (op == "any") 1378 if (op == "any")
1351 return kAny; 1379 return kAny;
1352 if (op == "between") 1380 if (op == "between")
1353 return kBetween; 1381 return kBetween;
1354 return kUnknown; 1382 return kUnknown;
1355 } 1383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698