Commit f3e1b503 authored by zmo@google.com's avatar zmo@google.com

Add a "disabled" field for GPU Blacklist entries.

BUG=97258
TEST=unittest
Review URL: http://codereview.chromium.org/7982034

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102410 0039d316-1c4b-4281-b951-d872f2087c98
parent be5f0078
......@@ -40,6 +40,8 @@
// 16. "browser_channels" is a list of browser channel strings, valid values
// include "stable", "beta", "dev", and "canary". If the browser_channels
// list is not present, the entry matches all channels.
// 17. "disabled" is a boolean. If it is present, the entry will be skipped.
// This can not be used in exceptions.
//
// VERSION includes "op" "number", and "number2". "op" can be any of the
// following values: "=", "<", "<=", ">", ">=", "any", "between". "number2" is
......
......@@ -223,6 +223,12 @@ GpuBlacklist::GpuBlacklistEntry::GetGpuBlacklistEntryFromValue(
return NULL;
}
dictionary_entry_count++;
bool disabled;
if (value->GetBoolean("disabled", &disabled)) {
entry->SetDisabled(disabled);
dictionary_entry_count++;
}
}
std::string description;
......@@ -456,6 +462,7 @@ GpuBlacklist::GpuBlacklistEntry::GetGpuBlacklistEntryFromValue(
GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry()
: id_(0),
disabled_(false),
vendor_id_(0),
contains_unknown_fields_(false),
contains_unknown_features_(false) {
......@@ -469,6 +476,10 @@ bool GpuBlacklist::GpuBlacklistEntry::SetId(uint32 id) {
return false;
}
void GpuBlacklist::GpuBlacklistEntry::SetDisabled(bool disabled) {
disabled_ = disabled;
}
bool GpuBlacklist::GpuBlacklistEntry::SetOsInfo(
const std::string& os,
const std::string& version_op,
......@@ -644,6 +655,10 @@ uint32 GpuBlacklist::GpuBlacklistEntry::id() const {
return id_;
}
bool GpuBlacklist::GpuBlacklistEntry::disabled() const {
return disabled_;
}
GpuFeatureFlags GpuBlacklist::GpuBlacklistEntry::GetGpuFeatureFlags() const {
return *feature_flags_;
}
......@@ -752,7 +767,8 @@ GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags(
for (size_t i = 0; i < blacklist_.size(); ++i) {
if (blacklist_[i]->Contains(os, *os_version, browser_channel_, gpu_info)) {
flags.Combine(blacklist_[i]->GetGpuFeatureFlags());
if (!blacklist_[i]->disabled())
flags.Combine(blacklist_[i]->GetGpuFeatureFlags());
active_entries_.push_back(blacklist_[i]);
}
}
......@@ -761,10 +777,12 @@ GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags(
void GpuBlacklist::GetGpuFeatureFlagEntries(
GpuFeatureFlags::GpuFeatureType feature,
std::vector<uint32>& entry_ids) const {
std::vector<uint32>& entry_ids,
bool disabled) const {
entry_ids.clear();
for (size_t i = 0; i < active_entries_.size(); ++i) {
if ((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0)
if (((feature & active_entries_[i]->GetGpuFeatureFlags().flags()) != 0) &&
disabled == active_entries_[i]->disabled())
entry_ids.push_back(active_entries_[i]->id());
}
}
......
......@@ -59,15 +59,18 @@ class CONTENT_EXPORT GpuBlacklist {
Version* os_version,
const GPUInfo& gpu_info);
// Collects the entries that set the "feature" flag from the last
// Collects the active entries that set the "feature" flag from the last
// DetermineGpuFeatureFlags() call. This tells which entries are responsible
// for raising a certain flag, i.e, for blacklisting a certain feature.
// Examples of "feature":
// kGpuFeatureAll - any of the supported features;
// kGpuFeatureWebgl - a single feature;
// kGpuFeatureWebgl | kGpuFeatureAcceleratedCompositing - two features.
// If disabled set to true, return entries that are disabled; otherwise,
// return enabled entries.
void GetGpuFeatureFlagEntries(GpuFeatureFlags::GpuFeatureType feature,
std::vector<uint32>& entry_ids) const;
std::vector<uint32>& entry_ids,
bool disabled) const;
// Returns status information on the blacklist. This is two parted:
// {
......@@ -238,6 +241,9 @@ class CONTENT_EXPORT GpuBlacklist {
// Returns the entry's unique id. 0 is reserved.
uint32 id() const;
// Returns whether the entry is disabled.
bool disabled() const;
// Returns the description of the entry
const std::string& description() const { return description_; }
......@@ -265,6 +271,8 @@ class CONTENT_EXPORT GpuBlacklist {
bool SetId(uint32 id);
void SetDisabled(bool disabled);
bool SetOsInfo(const std::string& os,
const std::string& version_op,
const std::string& version_string,
......@@ -299,6 +307,7 @@ class CONTENT_EXPORT GpuBlacklist {
void AddBrowserChannel(BrowserChannel channel);
uint32 id_;
bool disabled_;
std::string description_;
std::vector<int> cr_bugs_;
std::vector<int> webkit_bugs_;
......
......@@ -144,12 +144,13 @@ TEST_F(GpuBlacklistTest, DetailedEntryAndInvalidJson) {
flags.flags(),
static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing));
std::vector<uint32> entries;
bool disabled = false;
blacklist.GetGpuFeatureFlagEntries(
GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, entries);
GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, entries, disabled);
EXPECT_EQ(entries.size(), 1u);
EXPECT_EQ(entries[0], 5u);
blacklist.GetGpuFeatureFlagEntries(
GpuFeatureFlags::kGpuFeatureAll, entries);
GpuFeatureFlags::kGpuFeatureAll, entries, disabled);
EXPECT_EQ(entries.size(), 1u);
EXPECT_EQ(entries[0], 5u);
EXPECT_EQ(blacklist.max_entry_id(), 5u);
......@@ -725,3 +726,37 @@ TEST_F(GpuBlacklistTest, GlRenderer) {
static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
}
TEST_F(GpuBlacklistTest, DisabledEntry) {
const std::string disabled_json =
"{\n"
" \"name\": \"gpu blacklist\",\n"
" \"version\": \"0.1\",\n"
" \"entries\": [\n"
" {\n"
" \"id\": 1,\n"
" \"disabled\": true,\n"
" \"blacklist\": [\n"
" \"webgl\"\n"
" ]\n"
" }\n"
" ]\n"
"}";
scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4"));
GpuBlacklist blacklist("1.0 unknown");
EXPECT_TRUE(
blacklist.LoadGpuBlacklist(disabled_json, GpuBlacklist::kAllOs));
GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags(
GpuBlacklist::kOsWin, os_version.get(), gpu_info());
EXPECT_EQ(flags.flags(), 0u);
std::vector<uint32> flag_entries;
bool disabled = false;
blacklist.GetGpuFeatureFlagEntries(
GpuFeatureFlags::kGpuFeatureAll, flag_entries, disabled);
EXPECT_EQ(flag_entries.size(), 0u);
disabled = true;
blacklist.GetGpuFeatureFlagEntries(
GpuFeatureFlags::kGpuFeatureAll, flag_entries, disabled);
EXPECT_EQ(flag_entries.size(), 1u);
}
......@@ -408,13 +408,14 @@ void GpuDataManager::UpdateGpuFeatureFlags() {
uint32 flags = gpu_feature_flags_.flags();
uint32 max_entry_id = gpu_blacklist->max_entry_id();
bool disabled = false;
if (flags == 0) {
UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
0, max_entry_id + 1);
} else {
std::vector<uint32> flag_entries;
gpu_blacklist->GetGpuFeatureFlagEntries(
GpuFeatureFlags::kGpuFeatureAll, flag_entries);
GpuFeatureFlags::kGpuFeatureAll, flag_entries, disabled);
DCHECK_GT(flag_entries.size(), 0u);
for (size_t i = 0; i < flag_entries.size(); ++i) {
UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry",
......@@ -422,6 +423,17 @@ void GpuDataManager::UpdateGpuFeatureFlags() {
}
}
// This counts how many users are affected by a disabled entry - this allows
// us to understand the impact of an entry before enable it.
std::vector<uint32> flag_disabled_entries;
disabled = true;
gpu_blacklist->GetGpuFeatureFlagEntries(
GpuFeatureFlags::kGpuFeatureAll, flag_disabled_entries, disabled);
for (size_t i = 0; i < flag_disabled_entries.size(); ++i) {
UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerDisabledEntry",
flag_disabled_entries[i], max_entry_id + 1);
}
const GpuFeatureFlags::GpuFeatureType kGpuFeatures[] = {
GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas,
GpuFeatureFlags::kGpuFeatureAcceleratedCompositing,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment