| Index: content/browser/gpu/gpu_blacklist.cc
|
| ===================================================================
|
| --- content/browser/gpu/gpu_blacklist.cc (revision 130192)
|
| +++ content/browser/gpu/gpu_blacklist.cc (working copy)
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -39,7 +39,7 @@
|
| GpuBlacklist::VersionInfo::VersionInfo(const std::string& version_op,
|
| const std::string& version_string,
|
| const std::string& version_string2) {
|
| - op_ = StringToOp(version_op);
|
| + op_ = StringToNumericOp(version_op);
|
| if (op_ == kUnknown || op_ == kAny)
|
| return;
|
| version_.reset(Version::GetVersionFromString(version_string));
|
| @@ -95,25 +95,6 @@
|
| return op_ != kUnknown;
|
| }
|
|
|
| -GpuBlacklist::VersionInfo::Op GpuBlacklist::VersionInfo::StringToOp(
|
| - const std::string& version_op) {
|
| - if (version_op == "=")
|
| - return kEQ;
|
| - else if (version_op == "<")
|
| - return kLT;
|
| - else if (version_op == "<=")
|
| - return kLE;
|
| - else if (version_op == ">")
|
| - return kGT;
|
| - else if (version_op == ">=")
|
| - return kGE;
|
| - else if (version_op == "any")
|
| - return kAny;
|
| - else if (version_op == "between")
|
| - return kBetween;
|
| - return kUnknown;
|
| -}
|
| -
|
| GpuBlacklist::OsInfo::OsInfo(const std::string& os,
|
| const std::string& version_op,
|
| const std::string& version_string,
|
| @@ -198,6 +179,52 @@
|
| return kUnknown;
|
| }
|
|
|
| +GpuBlacklist::FloatInfo::FloatInfo(const std::string& float_op,
|
| + const std::string& float_value,
|
| + const std::string& float_value2)
|
| + : op_(kUnknown),
|
| + value_(0.f),
|
| + value2_(0.f) {
|
| + double dvalue = 0;
|
| + if (!base::StringToDouble(float_value, &dvalue)) {
|
| + op_ = kUnknown;
|
| + return;
|
| + }
|
| + value_ = static_cast<float>(dvalue);
|
| + op_ = StringToNumericOp(float_op);
|
| + if (op_ == kBetween) {
|
| + if (!base::StringToDouble(float_value2, &dvalue)) {
|
| + op_ = kUnknown;
|
| + return;
|
| + }
|
| + value2_ = static_cast<float>(dvalue);
|
| + }
|
| +}
|
| +
|
| +bool GpuBlacklist::FloatInfo::Contains(float value) const {
|
| + if (op_ == kUnknown)
|
| + return false;
|
| + if (op_ == kAny)
|
| + return true;
|
| + if (op_ == kEQ)
|
| + return (value == value_);
|
| + if (op_ == kLT)
|
| + return (value < value_);
|
| + if (op_ == kLE)
|
| + return (value <= value_);
|
| + if (op_ == kGT)
|
| + return (value > value_);
|
| + if (op_ == kGE)
|
| + return (value >= value_);
|
| + DCHECK(op_ == kBetween);
|
| + return ((value_ <= value && value <= value2_) ||
|
| + (value2_ <= value && value <= value_));
|
| +}
|
| +
|
| +bool GpuBlacklist::FloatInfo::IsValid() const {
|
| + return op_ != kUnknown;
|
| +}
|
| +
|
| // static
|
| GpuBlacklist::ScopedGpuBlacklistEntry
|
| GpuBlacklist::GpuBlacklistEntry::GetGpuBlacklistEntryFromValue(
|
| @@ -373,6 +400,51 @@
|
| dictionary_entry_count++;
|
| }
|
|
|
| + DictionaryValue* perf_graphics_value = NULL;
|
| + if (value->GetDictionary("perf_graphics", &perf_graphics_value)) {
|
| + std::string op;
|
| + std::string float_value;
|
| + std::string float_value2;
|
| + perf_graphics_value->GetString("op", &op);
|
| + perf_graphics_value->GetString("value", &float_value);
|
| + perf_graphics_value->GetString("value2", &float_value2);
|
| + if (!entry->SetPerfGraphicsInfo(op, float_value, float_value2)) {
|
| + LOG(WARNING) << "Malformed perf_graphics entry " << entry->id();
|
| + return NULL;
|
| + }
|
| + dictionary_entry_count++;
|
| + }
|
| +
|
| + DictionaryValue* perf_gaming_value = NULL;
|
| + if (value->GetDictionary("perf_gaming", &perf_gaming_value)) {
|
| + std::string op;
|
| + std::string float_value;
|
| + std::string float_value2;
|
| + perf_gaming_value->GetString("op", &op);
|
| + perf_gaming_value->GetString("value", &float_value);
|
| + perf_gaming_value->GetString("value2", &float_value2);
|
| + if (!entry->SetPerfGamingInfo(op, float_value, float_value2)) {
|
| + LOG(WARNING) << "Malformed perf_gaming entry " << entry->id();
|
| + return NULL;
|
| + }
|
| + dictionary_entry_count++;
|
| + }
|
| +
|
| + DictionaryValue* perf_overall_value = NULL;
|
| + if (value->GetDictionary("perf_overall", &perf_overall_value)) {
|
| + std::string op;
|
| + std::string float_value;
|
| + std::string float_value2;
|
| + perf_overall_value->GetString("op", &op);
|
| + perf_overall_value->GetString("value", &float_value);
|
| + perf_overall_value->GetString("value2", &float_value2);
|
| + if (!entry->SetPerfOverallInfo(op, float_value, float_value2)) {
|
| + LOG(WARNING) << "Malformed perf_overall entry " << entry->id();
|
| + return NULL;
|
| + }
|
| + dictionary_entry_count++;
|
| + }
|
| +
|
| if (top_level) {
|
| ListValue* blacklist_value = NULL;
|
| if (!value->GetList("blacklist", &blacklist_value)) {
|
| @@ -523,6 +595,33 @@
|
| return gl_renderer_info_->IsValid();
|
| }
|
|
|
| +bool GpuBlacklist::GpuBlacklistEntry::SetPerfGraphicsInfo(
|
| + const std::string& op,
|
| + const std::string& float_string,
|
| + const std::string& float_string2) {
|
| + perf_graphics_info_.reset(
|
| + new FloatInfo(op, float_string, float_string2));
|
| + return perf_graphics_info_->IsValid();
|
| +}
|
| +
|
| +bool GpuBlacklist::GpuBlacklistEntry::SetPerfGamingInfo(
|
| + const std::string& op,
|
| + const std::string& float_string,
|
| + const std::string& float_string2) {
|
| + perf_gaming_info_.reset(
|
| + new FloatInfo(op, float_string, float_string2));
|
| + return perf_gaming_info_->IsValid();
|
| +}
|
| +
|
| +bool GpuBlacklist::GpuBlacklistEntry::SetPerfOverallInfo(
|
| + const std::string& op,
|
| + const std::string& float_string,
|
| + const std::string& float_string2) {
|
| + perf_overall_info_.reset(
|
| + new FloatInfo(op, float_string, float_string2));
|
| + return perf_overall_info_->IsValid();
|
| +}
|
| +
|
| bool GpuBlacklist::GpuBlacklistEntry::SetBlacklistedFeatures(
|
| const std::vector<std::string>& blacklisted_features) {
|
| size_t size = blacklisted_features.size();
|
| @@ -596,6 +695,18 @@
|
| if (gl_renderer_info_.get() != NULL &&
|
| !gl_renderer_info_->Contains(gpu_info.gl_renderer))
|
| return false;
|
| + if (perf_graphics_info_.get() != NULL &&
|
| + (gpu_info.performance_stats.graphics == 0.0 ||
|
| + !perf_graphics_info_->Contains(gpu_info.performance_stats.graphics)))
|
| + return false;
|
| + if (perf_gaming_info_.get() != NULL &&
|
| + (gpu_info.performance_stats.gaming == 0.0 ||
|
| + !perf_gaming_info_->Contains(gpu_info.performance_stats.gaming)))
|
| + return false;
|
| + if (perf_overall_info_.get() != NULL &&
|
| + (gpu_info.performance_stats.overall == 0.0 ||
|
| + !perf_overall_info_->Contains(gpu_info.performance_stats.overall)))
|
| + return false;
|
| for (size_t i = 0; i < exceptions_.size(); ++i) {
|
| if (exceptions_[i]->Contains(os_type, os_version, gpu_info))
|
| return false;
|
| @@ -862,3 +973,23 @@
|
| DCHECK(browser_version_.get() != NULL);
|
| }
|
|
|
| +// static
|
| +GpuBlacklist::NumericOp GpuBlacklist::StringToNumericOp(
|
| + const std::string& op) {
|
| + if (op == "=")
|
| + return kEQ;
|
| + if (op == "<")
|
| + return kLT;
|
| + if (op == "<=")
|
| + return kLE;
|
| + if (op == ">")
|
| + return kGT;
|
| + if (op == ">=")
|
| + return kGE;
|
| + if (op == "any")
|
| + return kAny;
|
| + if (op == "between")
|
| + return kBetween;
|
| + return kUnknown;
|
| +}
|
| +
|
|
|