diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-15 16:03:11 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-15 16:03:11 +0000 |
commit | d56ecf9292deaa737f7523589e95437f16d92c6b (patch) | |
tree | defe392fb763429cd65c0bbbaf4c39a232f956ad /content | |
parent | 6aae28d4394aa30785f31530e20c6a259ef39e01 (diff) | |
download | chromium_src-d56ecf9292deaa737f7523589e95437f16d92c6b.zip chromium_src-d56ecf9292deaa737f7523589e95437f16d92c6b.tar.gz chromium_src-d56ecf9292deaa737f7523589e95437f16d92c6b.tar.bz2 |
Move GpuBlacklist out of content and into chrome. All content needs to know is which features are enabled.
-moved GputFeatureFlags into the public API. The to/from string functions are only used by chrome now, so they moved to chrome\brower\gpu_util. I made the public API just an enum to match the rest of the Content API.
-moved the stats related code to chrome, since content doesn't need to know about it, and the callers were chrome code (i.e. GPUInterals and TracingUI)
-removed the UserData caching struct since it was now called by code in both content and chrome. I switched to modifying the current process's command line instead which I think also makes things simpler
In a followup change, I'll create a minimal interface around GpuDataManager that is exposed to embedders.
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9360035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122090 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/gpu/gpu_blacklist.cc | 864 | ||||
-rw-r--r-- | content/browser/gpu/gpu_blacklist.h | 335 | ||||
-rw-r--r-- | content/browser/gpu/gpu_blacklist_unittest.cc | 690 | ||||
-rw-r--r-- | content/browser/gpu/gpu_data_manager.cc | 543 | ||||
-rw-r--r-- | content/browser/gpu/gpu_data_manager.h | 125 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.cc | 8 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 10 | ||||
-rw-r--r-- | content/common/gpu/gpu_feature_flags.cc | 72 | ||||
-rw-r--r-- | content/common/gpu/gpu_feature_flags.h | 68 | ||||
-rw-r--r-- | content/common/gpu/gpu_feature_flags_unittest.cc | 94 | ||||
-rw-r--r-- | content/content_browser.gypi | 2 | ||||
-rw-r--r-- | content/content_common.gypi | 3 | ||||
-rw-r--r-- | content/content_tests.gypi | 2 | ||||
-rw-r--r-- | content/public/common/content_switches.cc | 3 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 1 | ||||
-rw-r--r-- | content/public/common/gpu_feature_type.h | 29 |
16 files changed, 99 insertions, 2750 deletions
diff --git a/content/browser/gpu/gpu_blacklist.cc b/content/browser/gpu/gpu_blacklist.cc deleted file mode 100644 index e594826..0000000 --- a/content/browser/gpu/gpu_blacklist.cc +++ /dev/null @@ -1,864 +0,0 @@ -// Copyright (c) 2011 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. - -#include "content/browser/gpu/gpu_blacklist.h" - -#include "base/json/json_reader.h" -#include "base/logging.h" -#include "base/string_number_conversions.h" -#include "base/string_piece.h" -#include "base/string_split.h" -#include "base/string_util.h" -#include "base/stringprintf.h" -#include "base/sys_info.h" -#include "base/values.h" -#include "base/version.h" -#include "content/public/common/gpu_info.h" - -namespace { - -// Encode a date as Version, where [0] is year, [1] is month, and [2] is day. -Version* GetDateFromString(const std::string& date_string) { - // TODO(zmo): verify if in Windows registry, driver dates are always in the - // format of "mm-dd-yyyy". - std::vector<std::string> pieces; - base::SplitString(date_string, '-', &pieces); - if (pieces.size() != 3) - return NULL; - std::string date_as_version_string = pieces[2]; - for (size_t i = 0; i < 2; ++i) { - date_as_version_string += "."; - date_as_version_string += pieces[i]; - } - return Version::GetVersionFromString(date_as_version_string); -} - -} // namespace anonymous - -GpuBlacklist::VersionInfo::VersionInfo(const std::string& version_op, - const std::string& version_string, - const std::string& version_string2) { - op_ = StringToOp(version_op); - if (op_ == kUnknown || op_ == kAny) - return; - version_.reset(Version::GetVersionFromString(version_string)); - if (version_.get() == NULL) { - op_ = kUnknown; - return; - } - if (op_ == kBetween) { - version2_.reset(Version::GetVersionFromString(version_string2)); - if (version2_.get() == NULL) - op_ = kUnknown; - } -} - -GpuBlacklist::VersionInfo::~VersionInfo() { -} - -bool GpuBlacklist::VersionInfo::Contains(const Version& version) const { - if (op_ == kUnknown) - return false; - if (op_ == kAny) - return true; - if (op_ == kEQ) { - // Handles cases where 10.6 is considered as containing 10.6.*. - const std::vector<uint16>& components_reference = version_->components(); - const std::vector<uint16>& components = version.components(); - for (size_t i = 0; i < components_reference.size(); ++i) { - if (i >= components.size() && components_reference[i] != 0) - return false; - if (components[i] != components_reference[i]) - return false; - } - return true; - } - int relation = version.CompareTo(*version_); - if (op_ == kEQ) - return (relation == 0); - else if (op_ == kLT) - return (relation < 0); - else if (op_ == kLE) - return (relation <= 0); - else if (op_ == kGT) - return (relation > 0); - else if (op_ == kGE) - return (relation >= 0); - // op_ == kBetween - if (relation < 0) - return false; - return version.CompareTo(*version2_) <= 0; -} - -bool GpuBlacklist::VersionInfo::IsValid() const { - 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, - const std::string& version_string2) { - type_ = StringToOsType(os); - if (type_ != kOsUnknown) { - version_info_.reset( - new VersionInfo(version_op, version_string, version_string2)); - } -} - -GpuBlacklist::OsInfo::~OsInfo() {} - -bool GpuBlacklist::OsInfo::Contains(OsType type, - const Version& version) const { - if (!IsValid()) - return false; - if (type_ != type && type_ != kOsAny) - return false; - return version_info_->Contains(version); -} - -bool GpuBlacklist::OsInfo::IsValid() const { - return type_ != kOsUnknown && version_info_->IsValid(); -} - -GpuBlacklist::OsType GpuBlacklist::OsInfo::type() const { - return type_; -} - -GpuBlacklist::OsType GpuBlacklist::OsInfo::StringToOsType( - const std::string& os) { - if (os == "win") - return kOsWin; - else if (os == "macosx") - return kOsMacosx; - else if (os == "linux") - return kOsLinux; - else if (os == "chromeos") - return kOsChromeOS; - else if (os == "any") - return kOsAny; - return kOsUnknown; -} - -GpuBlacklist::StringInfo::StringInfo(const std::string& string_op, - const std::string& string_value) { - op_ = StringToOp(string_op); - value_ = StringToLowerASCII(string_value); -} - -bool GpuBlacklist::StringInfo::Contains(const std::string& value) const { - std::string my_value = StringToLowerASCII(value); - switch (op_) { - case kContains: - return strstr(my_value.c_str(), value_.c_str()) != NULL; - case kBeginWith: - return StartsWithASCII(my_value, value_, false); - case kEndWith: - return EndsWith(my_value, value_, false); - case kEQ: - return value_ == my_value; - default: - return false; - } -} - -bool GpuBlacklist::StringInfo::IsValid() const { - return op_ != kUnknown; -} - -GpuBlacklist::StringInfo::Op GpuBlacklist::StringInfo::StringToOp( - const std::string& string_op) { - if (string_op == "=") - return kEQ; - else if (string_op == "contains") - return kContains; - else if (string_op == "beginwith") - return kBeginWith; - else if (string_op == "endwith") - return kEndWith; - return kUnknown; -} - -// static -GpuBlacklist::ScopedGpuBlacklistEntry -GpuBlacklist::GpuBlacklistEntry::GetGpuBlacklistEntryFromValue( - DictionaryValue* value, bool top_level) { - DCHECK(value); - ScopedGpuBlacklistEntry entry(new GpuBlacklistEntry()); - - size_t dictionary_entry_count = 0; - - if (top_level) { - uint32 id; - if (!value->GetInteger("id", reinterpret_cast<int*>(&id)) || - !entry->SetId(id)) { - LOG(WARNING) << "Malformed id entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - - bool disabled; - if (value->GetBoolean("disabled", &disabled)) { - entry->SetDisabled(disabled); - dictionary_entry_count++; - } - } - - std::string description; - if (value->GetString("description", &description)) { - entry->description_ = description; - dictionary_entry_count++; - } else { - entry->description_ = "The GPU is unavailable for an unexplained reason."; - } - - ListValue* cr_bugs; - if (value->GetList("cr_bugs", &cr_bugs)) { - for (size_t i = 0; i < cr_bugs->GetSize(); ++i) { - int bug_id; - if (cr_bugs->GetInteger(i, &bug_id)) { - entry->cr_bugs_.push_back(bug_id); - } else { - LOG(WARNING) << "Malformed cr_bugs entry " << entry->id(); - return NULL; - } - } - dictionary_entry_count++; - } - - ListValue* webkit_bugs; - if (value->GetList("webkit_bugs", &webkit_bugs)) { - for (size_t i = 0; i < webkit_bugs->GetSize(); ++i) { - int bug_id; - if (webkit_bugs->GetInteger(i, &bug_id)) { - entry->webkit_bugs_.push_back(bug_id); - } else { - LOG(WARNING) << "Malformed webkit_bugs entry " << entry->id(); - return NULL; - } - } - dictionary_entry_count++; - } - - DictionaryValue* os_value = NULL; - if (value->GetDictionary("os", &os_value)) { - std::string os_type; - std::string os_version_op = "any"; - std::string os_version_string; - std::string os_version_string2; - os_value->GetString("type", &os_type); - DictionaryValue* os_version_value = NULL; - if (os_value->GetDictionary("version", &os_version_value)) { - os_version_value->GetString("op", &os_version_op); - os_version_value->GetString("number", &os_version_string); - os_version_value->GetString("number2", &os_version_string2); - } - if (!entry->SetOsInfo(os_type, os_version_op, os_version_string, - os_version_string2)) { - LOG(WARNING) << "Malformed os entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - } - - std::string vendor_id; - if (value->GetString("vendor_id", &vendor_id)) { - if (!entry->SetVendorId(vendor_id)) { - LOG(WARNING) << "Malformed vendor_id entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - } - - ListValue* device_id_list; - if (value->GetList("device_id", &device_id_list)) { - for (size_t i = 0; i < device_id_list->GetSize(); ++i) { - std::string device_id; - if (!device_id_list->GetString(i, &device_id) || - !entry->AddDeviceId(device_id)) { - LOG(WARNING) << "Malformed device_id entry " << entry->id(); - return NULL; - } - } - dictionary_entry_count++; - } - - DictionaryValue* driver_vendor_value = NULL; - if (value->GetDictionary("driver_vendor", &driver_vendor_value)) { - std::string vendor_op; - std::string vendor_value; - driver_vendor_value->GetString("op", &vendor_op); - driver_vendor_value->GetString("value", &vendor_value); - if (!entry->SetDriverVendorInfo(vendor_op, vendor_value)) { - LOG(WARNING) << "Malformed driver_vendor entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - } - - DictionaryValue* driver_version_value = NULL; - if (value->GetDictionary("driver_version", &driver_version_value)) { - std::string driver_version_op = "any"; - std::string driver_version_string; - std::string driver_version_string2; - driver_version_value->GetString("op", &driver_version_op); - driver_version_value->GetString("number", &driver_version_string); - driver_version_value->GetString("number2", &driver_version_string2); - if (!entry->SetDriverVersionInfo(driver_version_op, driver_version_string, - driver_version_string2)) { - LOG(WARNING) << "Malformed driver_version entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - } - - DictionaryValue* driver_date_value = NULL; - if (value->GetDictionary("driver_date", &driver_date_value)) { - std::string driver_date_op = "any"; - std::string driver_date_string; - std::string driver_date_string2; - driver_date_value->GetString("op", &driver_date_op); - driver_date_value->GetString("number", &driver_date_string); - driver_date_value->GetString("number2", &driver_date_string2); - if (!entry->SetDriverDateInfo(driver_date_op, driver_date_string, - driver_date_string2)) { - LOG(WARNING) << "Malformed driver_date entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - } - - DictionaryValue* gl_vendor_value = NULL; - if (value->GetDictionary("gl_vendor", &gl_vendor_value)) { - std::string vendor_op; - std::string vendor_value; - gl_vendor_value->GetString("op", &vendor_op); - gl_vendor_value->GetString("value", &vendor_value); - if (!entry->SetGLVendorInfo(vendor_op, vendor_value)) { - LOG(WARNING) << "Malformed gl_vendor entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - } - - DictionaryValue* gl_renderer_value = NULL; - if (value->GetDictionary("gl_renderer", &gl_renderer_value)) { - std::string renderer_op; - std::string renderer_value; - gl_renderer_value->GetString("op", &renderer_op); - gl_renderer_value->GetString("value", &renderer_value); - if (!entry->SetGLRendererInfo(renderer_op, renderer_value)) { - LOG(WARNING) << "Malformed gl_renderer entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - } - - if (top_level) { - ListValue* blacklist_value = NULL; - if (!value->GetList("blacklist", &blacklist_value)) { - LOG(WARNING) << "Malformed blacklist entry " << entry->id(); - return NULL; - } - std::vector<std::string> blacklist; - for (size_t i = 0; i < blacklist_value->GetSize(); ++i) { - std::string feature; - if (blacklist_value->GetString(i, &feature)) { - blacklist.push_back(feature); - } else { - LOG(WARNING) << "Malformed blacklist entry " << entry->id(); - return NULL; - } - } - if (!entry->SetBlacklistedFeatures(blacklist)) { - LOG(WARNING) << "Malformed blacklist entry " << entry->id(); - return NULL; - } - dictionary_entry_count++; - } - - if (top_level) { - ListValue* exception_list_value = NULL; - if (value->GetList("exceptions", &exception_list_value)) { - for (size_t i = 0; i < exception_list_value->GetSize(); ++i) { - DictionaryValue* exception_value = NULL; - if (!exception_list_value->GetDictionary(i, &exception_value)) { - LOG(WARNING) << "Malformed exceptions entry " << entry->id(); - return NULL; - } - ScopedGpuBlacklistEntry exception( - GetGpuBlacklistEntryFromValue(exception_value, false)); - if (exception == NULL) { - LOG(WARNING) << "Malformed exceptions entry " << entry->id(); - return NULL; - } - if (exception->contains_unknown_fields_) { - LOG(WARNING) << "Exception with unknown fields " << entry->id(); - entry->contains_unknown_fields_ = true; - } else { - entry->AddException(exception); - } - } - dictionary_entry_count++; - } - - DictionaryValue* browser_version_value = NULL; - // browser_version is processed in LoadGpuBlacklist(). - if (value->GetDictionary("browser_version", &browser_version_value)) - dictionary_entry_count++; - } - - if (value->size() != dictionary_entry_count) { - LOG(WARNING) << "Entry with unknown fields " << entry->id(); - entry->contains_unknown_fields_ = true; - } - return entry; -} - -GpuBlacklist::GpuBlacklistEntry::GpuBlacklistEntry() - : id_(0), - disabled_(false), - vendor_id_(0), - contains_unknown_fields_(false), - contains_unknown_features_(false) { -} - -bool GpuBlacklist::GpuBlacklistEntry::SetId(uint32 id) { - if (id != 0) { - id_ = id; - return true; - } - return false; -} - -void GpuBlacklist::GpuBlacklistEntry::SetDisabled(bool disabled) { - disabled_ = disabled; -} - -bool GpuBlacklist::GpuBlacklistEntry::SetOsInfo( - const std::string& os, - const std::string& version_op, - const std::string& version_string, - const std::string& version_string2) { - os_info_.reset(new OsInfo(os, version_op, version_string, version_string2)); - return os_info_->IsValid(); -} - -bool GpuBlacklist::GpuBlacklistEntry::SetVendorId( - const std::string& vendor_id_string) { - vendor_id_ = 0; - return base::HexStringToInt(vendor_id_string, - reinterpret_cast<int*>(&vendor_id_)); -} - -bool GpuBlacklist::GpuBlacklistEntry::AddDeviceId( - const std::string& device_id_string) { - uint32 device_id = 0; - if (base::HexStringToInt(device_id_string, - reinterpret_cast<int*>(&device_id))) { - device_id_list_.push_back(device_id); - return true; - } - return false; -} - -bool GpuBlacklist::GpuBlacklistEntry::SetDriverVendorInfo( - const std::string& vendor_op, - const std::string& vendor_value) { - driver_vendor_info_.reset( - new StringInfo(vendor_op, vendor_value)); - return driver_vendor_info_->IsValid(); -} - -bool GpuBlacklist::GpuBlacklistEntry::SetDriverVersionInfo( - const std::string& version_op, - const std::string& version_string, - const std::string& version_string2) { - driver_version_info_.reset( - new VersionInfo(version_op, version_string, version_string2)); - return driver_version_info_->IsValid(); -} - -bool GpuBlacklist::GpuBlacklistEntry::SetDriverDateInfo( - const std::string& date_op, - const std::string& date_string, - const std::string& date_string2) { - driver_date_info_.reset( - new VersionInfo(date_op, date_string, date_string2)); - return driver_date_info_->IsValid(); -} - -bool GpuBlacklist::GpuBlacklistEntry::SetGLVendorInfo( - const std::string& vendor_op, - const std::string& vendor_value) { - gl_vendor_info_.reset( - new StringInfo(vendor_op, vendor_value)); - return gl_vendor_info_->IsValid(); -} - -bool GpuBlacklist::GpuBlacklistEntry::SetGLRendererInfo( - const std::string& renderer_op, - const std::string& renderer_value) { - gl_renderer_info_.reset( - new StringInfo(renderer_op, renderer_value)); - return gl_renderer_info_->IsValid(); -} - -bool GpuBlacklist::GpuBlacklistEntry::SetBlacklistedFeatures( - const std::vector<std::string>& blacklisted_features) { - size_t size = blacklisted_features.size(); - if (size == 0) - return false; - uint32 flags = 0; - for (size_t i = 0; i < size; ++i) { - GpuFeatureFlags::GpuFeatureType type = - GpuFeatureFlags::StringToGpuFeatureType(blacklisted_features[i]); - switch (type) { - case GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas: - case GpuFeatureFlags::kGpuFeatureAcceleratedCompositing: - case GpuFeatureFlags::kGpuFeatureWebgl: - case GpuFeatureFlags::kGpuFeatureMultisampling: - case GpuFeatureFlags::kGpuFeatureAll: - flags |= type; - break; - case GpuFeatureFlags::kGpuFeatureUnknown: - contains_unknown_features_ = true; - break; - } - } - feature_flags_.reset(new GpuFeatureFlags()); - feature_flags_->set_flags(flags); - return true; -} - -void GpuBlacklist::GpuBlacklistEntry::AddException( - ScopedGpuBlacklistEntry exception) { - exceptions_.push_back(exception); -} - -bool GpuBlacklist::GpuBlacklistEntry::Contains( - OsType os_type, const Version& os_version, - const content::GPUInfo& gpu_info) const { - DCHECK(os_type != kOsAny); - if (os_info_.get() != NULL && !os_info_->Contains(os_type, os_version)) - return false; - if (vendor_id_ != 0 && vendor_id_ != gpu_info.vendor_id) - return false; - if (device_id_list_.size() > 0) { - bool found = false; - for (size_t i = 0; i < device_id_list_.size(); ++i) { - if (device_id_list_[i] == gpu_info.device_id) { - found = true; - break; - } - } - if (!found) - return false; - } - if (driver_vendor_info_.get() != NULL && - !driver_vendor_info_->Contains(gpu_info.driver_vendor)) - return false; - if (driver_version_info_.get() != NULL) { - scoped_ptr<Version> driver_version( - Version::GetVersionFromString(gpu_info.driver_version)); - if (driver_version.get() == NULL || - !driver_version_info_->Contains(*driver_version)) - return false; - } - if (driver_date_info_.get() != NULL) { - scoped_ptr<Version> driver_date(GetDateFromString(gpu_info.driver_date)); - if (driver_date.get() == NULL || - !driver_date_info_->Contains(*driver_date)) - return false; - } - if (gl_vendor_info_.get() != NULL && - !gl_vendor_info_->Contains(gpu_info.gl_vendor)) - return false; - if (gl_renderer_info_.get() != NULL && - !gl_renderer_info_->Contains(gpu_info.gl_renderer)) - return false; - for (size_t i = 0; i < exceptions_.size(); ++i) { - if (exceptions_[i]->Contains(os_type, os_version, gpu_info)) - return false; - } - return true; -} - -GpuBlacklist::OsType GpuBlacklist::GpuBlacklistEntry::GetOsType() const { - if (os_info_.get() == NULL) - return kOsAny; - return os_info_->type(); -} - -uint32 GpuBlacklist::GpuBlacklistEntry::id() const { - return id_; -} - -bool GpuBlacklist::GpuBlacklistEntry::disabled() const { - return disabled_; -} - -GpuFeatureFlags GpuBlacklist::GpuBlacklistEntry::GetGpuFeatureFlags() const { - return *feature_flags_; -} - -GpuBlacklist::GpuBlacklist(const std::string& browser_version_string) - : max_entry_id_(0), - contains_unknown_fields_(false) { - SetBrowserVersion(browser_version_string); -} - -GpuBlacklist::~GpuBlacklist() { - Clear(); -} - -bool GpuBlacklist::LoadGpuBlacklist( - const std::string& json_context, GpuBlacklist::OsFilter os_filter) { - scoped_ptr<Value> root; - root.reset(base::JSONReader::Read(json_context, false)); - if (root.get() == NULL || !root->IsType(Value::TYPE_DICTIONARY)) - return false; - - DictionaryValue* root_dictionary = static_cast<DictionaryValue*>(root.get()); - DCHECK(root_dictionary); - return LoadGpuBlacklist(*root_dictionary, os_filter); -} - -bool GpuBlacklist::LoadGpuBlacklist( - const DictionaryValue& parsed_json, GpuBlacklist::OsFilter os_filter) { - std::vector<ScopedGpuBlacklistEntry> entries; - - std::string version_string; - parsed_json.GetString("version", &version_string); - version_.reset(Version::GetVersionFromString(version_string)); - if (version_.get() == NULL) - return false; - - ListValue* list = NULL; - if (!parsed_json.GetList("entries", &list)) - return false; - - uint32 max_entry_id = 0; - bool contains_unknown_fields = false; - for (size_t i = 0; i < list->GetSize(); ++i) { - DictionaryValue* list_item = NULL; - bool valid = list->GetDictionary(i, &list_item); - if (!valid || list_item == NULL) - return false; - // Check browser version compatibility: if the entry is not for the - // current browser version, don't process it. - BrowserVersionSupport browser_version_support = - IsEntrySupportedByCurrentBrowserVersion(list_item); - if (browser_version_support == kMalformed) - return false; - if (browser_version_support == kUnsupported) - continue; - DCHECK(browser_version_support == kSupported); - ScopedGpuBlacklistEntry entry( - GpuBlacklistEntry::GetGpuBlacklistEntryFromValue(list_item, true)); - if (entry == NULL) - return false; - if (entry->id() > max_entry_id) - max_entry_id = entry->id(); - // If an unknown field is encountered, skip the entry; if an unknown - // feature is encountered, ignore the feature, but keep the entry. - if (entry->contains_unknown_fields()) { - contains_unknown_fields = true; - continue; - } - if (entry->contains_unknown_features()) - contains_unknown_fields = true; - entries.push_back(entry); - } - - Clear(); - OsType my_os = GetOsType(); - for (size_t i = 0; i < entries.size(); ++i) { - OsType entry_os = entries[i]->GetOsType(); - if (os_filter == GpuBlacklist::kAllOs || - entry_os == kOsAny || entry_os == my_os) - blacklist_.push_back(entries[i]); - } - max_entry_id_ = max_entry_id; - contains_unknown_fields_ = contains_unknown_fields; - return true; -} - -GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags( - GpuBlacklist::OsType os, - Version* os_version, - const content::GPUInfo& gpu_info) { - active_entries_.clear(); - GpuFeatureFlags flags; - - if (os == kOsAny) - os = GetOsType(); - scoped_ptr<Version> my_os_version; - if (os_version == NULL) { - std::string version_string = base::SysInfo::OperatingSystemVersion(); - size_t pos = version_string.find_first_not_of("0123456789."); - if (pos != std::string::npos) - version_string = version_string.substr(0, pos); - my_os_version.reset(Version::GetVersionFromString(version_string)); - os_version = my_os_version.get(); - } - DCHECK(os_version != NULL); - - for (size_t i = 0; i < blacklist_.size(); ++i) { - if (blacklist_[i]->Contains(os, *os_version, gpu_info)) { - if (!blacklist_[i]->disabled()) - flags.Combine(blacklist_[i]->GetGpuFeatureFlags()); - active_entries_.push_back(blacklist_[i]); - } - } - return flags; -} - -void GpuBlacklist::GetGpuFeatureFlagEntries( - GpuFeatureFlags::GpuFeatureType feature, - 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) && - disabled == active_entries_[i]->disabled()) - entry_ids.push_back(active_entries_[i]->id()); - } -} - -void GpuBlacklist::GetBlacklistReasons(ListValue* problem_list) const { - DCHECK(problem_list); - for (size_t i = 0; i < active_entries_.size(); ++i) { - GpuBlacklistEntry* entry = active_entries_[i]; - if (entry->disabled()) - continue; - DictionaryValue* problem = new DictionaryValue(); - - problem->SetString("description", entry->description()); - - ListValue* cr_bugs = new ListValue(); - for (size_t j = 0; j < entry->cr_bugs().size(); ++j) - cr_bugs->Append(Value::CreateIntegerValue(entry->cr_bugs()[j])); - problem->Set("crBugs", cr_bugs); - - ListValue* webkit_bugs = new ListValue(); - for (size_t j = 0; j < entry->webkit_bugs().size(); ++j) { - webkit_bugs->Append(Value::CreateIntegerValue( - entry->webkit_bugs()[j])); - } - problem->Set("webkitBugs", webkit_bugs); - - problem_list->Append(problem); - } -} - -size_t GpuBlacklist::num_entries() const { - return blacklist_.size(); -} - -uint32 GpuBlacklist::max_entry_id() const { - return max_entry_id_; -} - -bool GpuBlacklist::GetVersion(uint16* major, uint16* minor) const { - DCHECK(major && minor); - *major = 0; - *minor = 0; - if (version_.get() == NULL) - return false; - const std::vector<uint16>& components_reference = version_->components(); - if (components_reference.size() != 2) - return false; - *major = components_reference[0]; - *minor = components_reference[1]; - return true; -} - -bool GpuBlacklist::GetVersion( - const DictionaryValue& parsed_json, uint16* major, uint16* minor) { - DCHECK(major && minor); - *major = 0; - *minor = 0; - std::string version_string; - if (!parsed_json.GetString("version", &version_string)) - return false; - scoped_ptr<Version> version(Version::GetVersionFromString(version_string)); - if (version.get() == NULL) - return false; - const std::vector<uint16>& components_reference = version->components(); - if (components_reference.size() != 2) - return false; - *major = components_reference[0]; - *minor = components_reference[1]; - return true; -} - -GpuBlacklist::OsType GpuBlacklist::GetOsType() { -#if defined(OS_CHROMEOS) - return kOsChromeOS; -#elif defined(OS_WIN) - return kOsWin; -#elif defined(OS_LINUX) || defined(OS_OPENBSD) - return kOsLinux; -#elif defined(OS_MACOSX) - return kOsMacosx; -#else - return kOsUnknown; -#endif -} - -void GpuBlacklist::Clear() { - blacklist_.clear(); - active_entries_.clear(); - max_entry_id_ = 0; - contains_unknown_fields_ = false; -} - -GpuBlacklist::BrowserVersionSupport -GpuBlacklist::IsEntrySupportedByCurrentBrowserVersion( - DictionaryValue* value) { - DCHECK(value); - DictionaryValue* browser_version_value = NULL; - if (value->GetDictionary("browser_version", &browser_version_value)) { - std::string version_op = "any"; - std::string version_string; - std::string version_string2; - browser_version_value->GetString("op", &version_op); - browser_version_value->GetString("number", &version_string); - browser_version_value->GetString("number2", &version_string2); - scoped_ptr<VersionInfo> browser_version_info; - browser_version_info.reset( - new VersionInfo(version_op, version_string, version_string2)); - if (!browser_version_info->IsValid()) - return kMalformed; - if (browser_version_info->Contains(*browser_version_)) - return kSupported; - return kUnsupported; - } - return kSupported; -} - -void GpuBlacklist::SetBrowserVersion(const std::string& version_string) { - browser_version_.reset(Version::GetVersionFromString(version_string)); - DCHECK(browser_version_.get() != NULL); -} - diff --git a/content/browser/gpu/gpu_blacklist.h b/content/browser/gpu/gpu_blacklist.h deleted file mode 100644 index 73661a8..0000000 --- a/content/browser/gpu/gpu_blacklist.h +++ /dev/null @@ -1,335 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ -#define CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ -#pragma once - -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/gtest_prod_util.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "base/values.h" -#include "content/common/content_export.h" -#include "content/common/gpu/gpu_feature_flags.h" - -class Version; - -namespace base { -class DictionaryValue; -} - -namespace content { -struct GPUInfo; -} - -class CONTENT_EXPORT GpuBlacklist { - public: - enum OsType { - kOsLinux, - kOsMacosx, - kOsWin, - kOsChromeOS, - kOsAny, - kOsUnknown - }; - - enum OsFilter { - // In loading, ignore all entries that belong to other OS. - kCurrentOsOnly, - // In loading, keep all entries. This is for testing only. - kAllOs - }; - - explicit GpuBlacklist(const std::string& browser_version_string); - ~GpuBlacklist(); - - // Loads blacklist information from a json file. - // If failed, the current GpuBlacklist is un-touched. - bool LoadGpuBlacklist(const std::string& json_context, OsFilter os_filter); - bool LoadGpuBlacklist(const base::DictionaryValue& parsed_json, - OsFilter os_filter); - - // Collects system information and combines them with gpu_info and blacklist - // information to determine gpu feature flags. - // If os is kOsAny, use the current OS; if os_version is null, use the - // current OS version. - GpuFeatureFlags DetermineGpuFeatureFlags(OsType os, - Version* os_version, - const content::GPUInfo& gpu_info); - - // 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, - bool disabled) const; - - // Returns the description and bugs from active entries from the last - // DetermineGpuFeatureFlags() call. - // - // Each problems has: - // { - // "description": "Your GPU is too old", - // "crBugs": [1234], - // "webkitBugs": [] - // } - void GetBlacklistReasons(ListValue* problem_list) const; - - // Return the largest entry id. This is used for histogramming. - uint32 max_entry_id() const; - - // Collects the version of the current blacklist. Returns false and sets - // major and minor to 0 on failure. - bool GetVersion(uint16* major, uint16* monir) const; - - // Collects the version of the current blacklist from a parsed json file. - // Returns false and sets major and minor to 0 on failure. - static bool GetVersion( - const base::DictionaryValue& parsed_json, uint16* major, uint16* minor); - - private: - FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, CurrentBlacklistValidation); - FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownField); - FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownExceptionField); - FRIEND_TEST_ALL_PREFIXES(GpuBlacklistTest, UnknownFeature); - - enum BrowserVersionSupport { - kSupported, - kUnsupported, - kMalformed - }; - - class VersionInfo { - public: - VersionInfo(const std::string& version_op, - const std::string& version_string, - const std::string& version_string2); - ~VersionInfo(); - - // Determines if a given version is included in the VersionInfo range. - bool Contains(const Version& version) const; - - // Determines if the VersionInfo contains valid information. - bool IsValid() const; - - private: - enum Op { - kBetween, // <= * <= - kEQ, // = - kLT, // < - kLE, // <= - kGT, // > - kGE, // >= - kAny, - kUnknown // Indicates VersionInfo data is invalid. - }; - - // Maps string to Op; returns kUnknown if it's not a valid Op. - static Op StringToOp(const std::string& version_op); - - Op op_; - scoped_ptr<Version> version_; - scoped_ptr<Version> version2_; - }; - - class OsInfo { - public: - OsInfo(const std::string& os, - const std::string& version_op, - const std::string& version_string, - const std::string& version_string2); - ~OsInfo(); - - // Determines if a given os/version is included in the OsInfo set. - bool Contains(OsType type, const Version& version) const; - - // Determines if the VersionInfo contains valid information. - bool IsValid() const; - - OsType type() const; - - // Maps string to OsType; returns kOsUnknown if it's not a valid os. - static OsType StringToOsType(const std::string& os); - - private: - OsType type_; - scoped_ptr<VersionInfo> version_info_; - }; - - class StringInfo { - public: - StringInfo(const std::string& string_op, const std::string& string_value); - - // Determines if a given string is included in the StringInfo. - bool Contains(const std::string& value) const; - - // Determines if the StringInfo contains valid information. - bool IsValid() const; - - private: - enum Op { - kContains, - kBeginWith, - kEndWith, - kEQ, // = - kUnknown // Indicates StringInfo data is invalid. - }; - - // Maps string to Op; returns kUnknown if it's not a valid Op. - static Op StringToOp(const std::string& string_op); - - Op op_; - std::string value_; - }; - - class GpuBlacklistEntry; - typedef scoped_refptr<GpuBlacklistEntry> ScopedGpuBlacklistEntry; - - class GpuBlacklistEntry : public base::RefCounted<GpuBlacklistEntry> { - public: - // Constructs GpuBlacklistEntry from DictionaryValue loaded from json. - // Top-level entry must have an id number. Others are exceptions. - static ScopedGpuBlacklistEntry GetGpuBlacklistEntryFromValue( - base::DictionaryValue* value, bool top_level); - - // Determines if a given os/gc/driver is included in the Entry set. - bool Contains(OsType os_type, - const Version& os_version, - const content::GPUInfo& gpu_info) const; - - // Returns the OsType. - OsType GetOsType() const; - - // 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_; } - - // Returns a list of Chromium and Webkit bugs applicable to this entry - const std::vector<int>& cr_bugs() const { return cr_bugs_; } - const std::vector<int>& webkit_bugs() const { return webkit_bugs_; } - - // Returns the GpuFeatureFlags. - GpuFeatureFlags GetGpuFeatureFlags() const; - - // Returns true if an unknown field is encountered. - bool contains_unknown_fields() const { - return contains_unknown_fields_; - } - // Returns true if an unknown blacklist feature is encountered. - bool contains_unknown_features() const { - return contains_unknown_features_; - } - - private: - friend class base::RefCounted<GpuBlacklistEntry>; - - GpuBlacklistEntry(); - ~GpuBlacklistEntry() { } - - bool SetId(uint32 id); - - void SetDisabled(bool disabled); - - bool SetOsInfo(const std::string& os, - const std::string& version_op, - const std::string& version_string, - const std::string& version_string2); - - bool SetVendorId(const std::string& vendor_id_string); - - bool AddDeviceId(const std::string& device_id_string); - - bool SetDriverVendorInfo(const std::string& vendor_op, - const std::string& vendor_value); - - bool SetDriverVersionInfo(const std::string& version_op, - const std::string& version_string, - const std::string& version_string2); - - bool SetDriverDateInfo(const std::string& date_op, - const std::string& date_string, - const std::string& date_string2); - - bool SetGLVendorInfo(const std::string& vendor_op, - const std::string& vendor_value); - - bool SetGLRendererInfo(const std::string& renderer_op, - const std::string& renderer_value); - - bool SetBlacklistedFeatures( - const std::vector<std::string>& blacklisted_features); - - void AddException(ScopedGpuBlacklistEntry exception); - - uint32 id_; - bool disabled_; - std::string description_; - std::vector<int> cr_bugs_; - std::vector<int> webkit_bugs_; - scoped_ptr<OsInfo> os_info_; - uint32 vendor_id_; - std::vector<uint32> device_id_list_; - scoped_ptr<StringInfo> driver_vendor_info_; - scoped_ptr<VersionInfo> driver_version_info_; - scoped_ptr<VersionInfo> driver_date_info_; - scoped_ptr<StringInfo> gl_vendor_info_; - scoped_ptr<StringInfo> gl_renderer_info_; - scoped_ptr<GpuFeatureFlags> feature_flags_; - std::vector<ScopedGpuBlacklistEntry> exceptions_; - bool contains_unknown_fields_; - bool contains_unknown_features_; - }; - - // Gets the current OS type. - static OsType GetOsType(); - - void Clear(); - - // Check if the entry is supported by the current version of browser. - // By default, if there is no browser version information in the entry, - // return kSupported; - BrowserVersionSupport IsEntrySupportedByCurrentBrowserVersion( - base::DictionaryValue* value); - - // Returns the number of entries. This is only for tests. - size_t num_entries() const; - - // Check if any entries contain unknown fields. This is only for tests. - bool contains_unknown_fields() const { return contains_unknown_fields_; } - - void SetBrowserVersion(const std::string& version_string); - - scoped_ptr<Version> version_; - std::vector<ScopedGpuBlacklistEntry> blacklist_; - - scoped_ptr<Version> browser_version_; - - // This records all the blacklist entries that are appliable to the current - // user machine. It is updated everytime DetermineGpuFeatureFlags() is - // called and is used later by GetGpuFeatureFlagEntries(). - std::vector<ScopedGpuBlacklistEntry> active_entries_; - - uint32 max_entry_id_; - - bool contains_unknown_fields_; - - DISALLOW_COPY_AND_ASSIGN(GpuBlacklist); -}; - -#endif // CONTENT_BROWSER_GPU_GPU_BLACKLIST_H_ diff --git a/content/browser/gpu/gpu_blacklist_unittest.cc b/content/browser/gpu/gpu_blacklist_unittest.cc deleted file mode 100644 index cfcdd75..0000000 --- a/content/browser/gpu/gpu_blacklist_unittest.cc +++ /dev/null @@ -1,690 +0,0 @@ -// Copyright (c) 2011 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. - -#include <vector> - -#include "base/base_paths.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/memory/scoped_ptr.h" -#include "base/path_service.h" -#include "base/version.h" -#include "content/browser/gpu/gpu_blacklist.h" -#include "content/public/common/gpu_info.h" -#include "testing/gtest/include/gtest/gtest.h" - -class GpuBlacklistTest : public testing::Test { - public: - GpuBlacklistTest() { } - - virtual ~GpuBlacklistTest() { } - - const content::GPUInfo& gpu_info() const { - return gpu_info_; - } - - protected: - void SetUp() { - gpu_info_.vendor_id = 0x10de; - gpu_info_.device_id = 0x0640; - gpu_info_.driver_vendor = "NVIDIA"; - gpu_info_.driver_version = "1.6.18"; - gpu_info_.driver_date = "7-14-2009"; - gpu_info_.gl_vendor = "NVIDIA Corporation"; - gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; - } - - void TearDown() { - } - - private: - content::GPUInfo gpu_info_; -}; - -TEST_F(GpuBlacklistTest, CurrentBlacklistValidation) { - FilePath data_file; - ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_file)); - data_file = - data_file.Append(FILE_PATH_LITERAL("chrome")) - .Append(FILE_PATH_LITERAL("browser")) - .Append(FILE_PATH_LITERAL("resources")) - .Append(FILE_PATH_LITERAL("software_rendering_list")) - .Append(FILE_PATH_LITERAL("software_rendering_list.json")); - ASSERT_TRUE(file_util::PathExists(data_file)); - int64 data_file_size64 = 0; - ASSERT_TRUE(file_util::GetFileSize(data_file, &data_file_size64)); - int data_file_size = static_cast<int>(data_file_size64); - scoped_array<char> data(new char[data_file_size]); - ASSERT_EQ(file_util::ReadFile(data_file, data.get(), data_file_size), - data_file_size); - std::string json_string(data.get(), data_file_size); - GpuBlacklist blacklist("1.0"); - EXPECT_TRUE(blacklist.LoadGpuBlacklist(json_string, GpuBlacklist::kAllOs)); - EXPECT_FALSE(blacklist.contains_unknown_fields()); -} - -TEST_F(GpuBlacklistTest, DefaultBlacklistSettings) { - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - // Default blacklist settings: all feature are allowed. - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); -} - -TEST_F(GpuBlacklistTest, EmptyBlacklist) { - // Empty list: all features are allowed. - const std::string empty_list_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"2.5\",\n" - " \"entries\": [\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(empty_list_json, GpuBlacklist::kAllOs)); - uint16 major, minor; - EXPECT_TRUE(blacklist.GetVersion(&major, &minor)); - EXPECT_EQ(major, 2u); - EXPECT_EQ(minor, 5u); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); -} - -TEST_F(GpuBlacklistTest, DetailedEntryAndInvalidJson) { - // Blacklist accelerated_compositing with exact setting. - const std::string exact_list_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 5,\n" - " \"os\": {\n" - " \"type\": \"macosx\",\n" - " \"version\": {\n" - " \"op\": \"=\",\n" - " \"number\": \"10.6.4\"\n" - " }\n" - " },\n" - " \"vendor_id\": \"0x10de\",\n" - " \"device_id\": [\"0x0640\"],\n" - " \"driver_version\": {\n" - " \"op\": \"=\",\n" - " \"number\": \"1.6.18\"\n" - " },\n" - " \"blacklist\": [\n" - " \"accelerated_compositing\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(exact_list_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ( - flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing)); - - // Invalid json input should not change the current blacklist settings. - const std::string invalid_json = "invalid"; - - EXPECT_FALSE(blacklist.LoadGpuBlacklist(invalid_json, GpuBlacklist::kAllOs)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ( - flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing)); - std::vector<uint32> entries; - bool disabled = false; - blacklist.GetGpuFeatureFlagEntries( - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, entries, disabled); - EXPECT_EQ(entries.size(), 1u); - EXPECT_EQ(entries[0], 5u); - blacklist.GetGpuFeatureFlagEntries( - GpuFeatureFlags::kGpuFeatureAll, entries, disabled); - EXPECT_EQ(entries.size(), 1u); - EXPECT_EQ(entries[0], 5u); - EXPECT_EQ(blacklist.max_entry_id(), 5u); -} - -TEST_F(GpuBlacklistTest, VendorOnAllOsEntry) { - // Blacklist a vendor on all OS. - const std::string vendor_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"vendor_id\": \"0x10de\",\n" - " \"blacklist\": [\n" - " \"webgl\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - // Blacklist entries won't be filtered to the current OS only upon loading. - EXPECT_TRUE(blacklist.LoadGpuBlacklist(vendor_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsLinux, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) || \ - defined(OS_OPENBSD) - // Blacklist entries will be filtered to the current OS only upon loading. - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(vendor_json, GpuBlacklist::kCurrentOsOnly)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsLinux, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); -#endif -} - -TEST_F(GpuBlacklistTest, VendorOnLinuxEntry) { - // Blacklist a vendor on Linux only. - const std::string vendor_linux_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"os\": {\n" - " \"type\": \"linux\"\n" - " },\n" - " \"vendor_id\": \"0x10de\",\n" - " \"blacklist\": [\n" - " \"accelerated_2d_canvas\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(vendor_linux_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsLinux, os_version.get(), gpu_info()); - EXPECT_EQ( - flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)); -} - -TEST_F(GpuBlacklistTest, AllExceptNVidiaOnLinuxEntry) { - // Blacklist all cards in Linux except NVIDIA. - const std::string linux_except_nvidia_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"os\": {\n" - " \"type\": \"linux\"\n" - " },\n" - " \"exceptions\": [\n" - " {\n" - " \"vendor_id\": \"0x10de\"\n" - " }\n" - " ],\n" - " \"blacklist\": [\n" - " \"accelerated_2d_canvas\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE(blacklist.LoadGpuBlacklist(linux_except_nvidia_json, - GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsLinux, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); -} - -TEST_F(GpuBlacklistTest, AllExceptIntelOnLinuxEntry) { - // Blacklist all cards in Linux except Intel. - const std::string linux_except_intel_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"os\": {\n" - " \"type\": \"linux\"\n" - " },\n" - " \"exceptions\": [\n" - " {\n" - " \"vendor_id\": \"0x8086\"\n" - " }\n" - " ],\n" - " \"blacklist\": [\n" - " \"accelerated_2d_canvas\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE(blacklist.LoadGpuBlacklist(linux_except_intel_json, - GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsLinux, os_version.get(), gpu_info()); - EXPECT_EQ( - flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)); -} - -TEST_F(GpuBlacklistTest, DateOnWindowsEntry) { - // Blacklist all drivers earlier than 2010-01 in Windows. - const std::string date_windows_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"os\": {\n" - " \"type\": \"win\"\n" - " },\n" - " \"driver_date\": {\n" - " \"op\": \"<\",\n" - " \"number\": \"2010.1\"\n" - " },\n" - " \"blacklist\": [\n" - " \"accelerated_2d_canvas\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(date_windows_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsLinux, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ( - flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)); -} - -TEST_F(GpuBlacklistTest, MultipleDevicesEntry) { - const std::string devices_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"vendor_id\": \"0x10de\",\n" - " \"device_id\": [\"0x1023\", \"0x0640\"],\n" - " \"blacklist\": [\n" - " \"multisampling\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE(blacklist.LoadGpuBlacklist(devices_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsMacosx, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureMultisampling)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureMultisampling)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsLinux, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureMultisampling)); -} - -TEST_F(GpuBlacklistTest, ChromeOSEntry) { - const std::string devices_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"os\": {\n" - " \"type\": \"chromeos\"\n" - " },\n" - " \"blacklist\": [\n" - " \"webgl\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE(blacklist.LoadGpuBlacklist(devices_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsChromeOS, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); - flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsLinux, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); -} - -TEST_F(GpuBlacklistTest, ChromeVersionEntry) { - const std::string browser_version_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"browser_version\": {\n" - " \"op\": \">=\",\n" - " \"number\": \"10\"\n" - " },\n" - " \"blacklist\": [\n" - " \"webgl\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - - GpuBlacklist blacklist9("9.0"); - EXPECT_TRUE( - blacklist9.LoadGpuBlacklist(browser_version_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist9.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), 0u); - - GpuBlacklist blacklist10("10.0"); - EXPECT_TRUE( - blacklist10.LoadGpuBlacklist(browser_version_json, GpuBlacklist::kAllOs)); - flags = blacklist10.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); -} - -TEST_F(GpuBlacklistTest, MalformedVendor) { - // vendor_id is defined as list instead of string. - const std::string malformed_vendor_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"vendor_id\": \"[0x10de]\",\n" - " \"blacklist\": [\n" - " \"accelerated_2d_canvas\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - GpuBlacklist blacklist("1.0"); - - EXPECT_FALSE( - blacklist.LoadGpuBlacklist(malformed_vendor_json, GpuBlacklist::kAllOs)); -} - -TEST_F(GpuBlacklistTest, UnknownField) { - const std::string unknown_field_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"unknown_field\": 0,\n" - " \"blacklist\": [\n" - " \"accelerated_2d_canvas\"\n" - " ]\n" - " },\n" - " {\n" - " \"id\": 2,\n" - " \"blacklist\": [\n" - " \"webgl\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(unknown_field_json, GpuBlacklist::kAllOs)); - EXPECT_EQ(1u, blacklist.num_entries()); - EXPECT_TRUE(blacklist.contains_unknown_fields()); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); -} - -TEST_F(GpuBlacklistTest, UnknownExceptionField) { - const std::string unknown_exception_field_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"unknown_field\": 0,\n" - " \"blacklist\": [\n" - " \"accelerated_compositing\"\n" - " ]\n" - " },\n" - " {\n" - " \"id\": 2,\n" - " \"exceptions\": [\n" - " {\n" - " \"unknown_field\": 0\n" - " }\n" - " ],\n" - " \"blacklist\": [\n" - " \"accelerated_2d_canvas\"\n" - " ]\n" - " },\n" - " {\n" - " \"id\": 3,\n" - " \"blacklist\": [\n" - " \"webgl\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE(blacklist.LoadGpuBlacklist(unknown_exception_field_json, - GpuBlacklist::kAllOs)); - EXPECT_EQ(1u, blacklist.num_entries()); - EXPECT_TRUE(blacklist.contains_unknown_fields()); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); -} - -TEST_F(GpuBlacklistTest, UnknownFeature) { - const std::string unknown_feature_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"blacklist\": [\n" - " \"accelerated_something\",\n" - " \"webgl\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - GpuBlacklist blacklist("1.0"); - - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(unknown_feature_json, GpuBlacklist::kAllOs)); - EXPECT_EQ(1u, blacklist.num_entries()); - EXPECT_TRUE(blacklist.contains_unknown_fields()); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); -} - -TEST_F(GpuBlacklistTest, GlVendor) { - const std::string gl_vendor_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"gl_vendor\": {\n" - " \"op\": \"beginwith\",\n" - " \"value\": \"NVIDIA\"\n" - " },\n" - " \"blacklist\": [\n" - " \"webgl\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - - GpuBlacklist blacklist("1.0"); - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(gl_vendor_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); -} - -TEST_F(GpuBlacklistTest, GlRenderer) { - const std::string gl_renderer_json = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"0.1\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"gl_renderer\": {\n" - " \"op\": \"contains\",\n" - " \"value\": \"GeForce\"\n" - " },\n" - " \"blacklist\": [\n" - " \"webgl\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4")); - - GpuBlacklist blacklist("1.0"); - EXPECT_TRUE( - blacklist.LoadGpuBlacklist(gl_renderer_json, GpuBlacklist::kAllOs)); - GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags( - GpuBlacklist::kOsWin, os_version.get(), gpu_info()); - EXPECT_EQ(flags.flags(), - 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"); - 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); -} - diff --git a/content/browser/gpu/gpu_data_manager.cc b/content/browser/gpu/gpu_data_manager.cc index e2f4246..c175b67 100644 --- a/content/browser/gpu/gpu_data_manager.cc +++ b/content/browser/gpu/gpu_data_manager.cc @@ -12,13 +12,11 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/metrics/histogram.h" #include "base/string_number_conversions.h" #include "base/stringprintf.h" #include "base/sys_info.h" #include "base/values.h" #include "base/version.h" -#include "content/browser/gpu/gpu_blacklist.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/common/gpu/gpu_messages.h" #include "content/gpu/gpu_info_collector.h" @@ -30,24 +28,10 @@ #include "webkit/plugins/plugin_switches.h" using content::BrowserThread; +using content::GpuFeatureType; namespace { -enum GpuFeatureStatus { - kGpuFeatureEnabled = 0, - kGpuFeatureBlacklisted = 1, - kGpuFeatureDisabled = 2, // disabled by user but not blacklisted - kGpuFeatureNumStatus -}; - -struct GpuFeatureInfo { - std::string name; - uint32 blocked; - bool disabled; - std::string disabled_description; - bool fallback_to_software; -}; - #if defined(OS_MACOSX) void DisplayReconfigCallback(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, @@ -64,149 +48,13 @@ void DisplayReconfigCallback(CGDirectDisplayID display, } #endif -DictionaryValue* NewDescriptionValuePair(const std::string& desc, - const std::string& value) { - DictionaryValue* dict = new DictionaryValue(); - dict->SetString("description", desc); - dict->SetString("value", value); - return dict; -} - -DictionaryValue* NewDescriptionValuePair(const std::string& desc, - Value* value) { - DictionaryValue* dict = new DictionaryValue(); - dict->SetString("description", desc); - dict->Set("value", value); - return dict; -} - -Value* NewStatusValue(const char* name, const char* status) { - DictionaryValue* value = new DictionaryValue(); - value->SetString("name", name); - value->SetString("status", status); - return value; -} - -#if defined(OS_WIN) -enum WinSubVersion { - kWinOthers = 0, - kWinXP, - kWinVista, - kWin7, - kNumWinSubVersions -}; - -// Output DxDiagNode tree as nested array of {description,value} pairs -ListValue* DxDiagNodeToList(const content::DxDiagNode& node) { - ListValue* list = new ListValue(); - for (std::map<std::string, std::string>::const_iterator it = - node.values.begin(); - it != node.values.end(); - ++it) { - list->Append(NewDescriptionValuePair(it->first, it->second)); - } - - for (std::map<std::string, content::DxDiagNode>::const_iterator it = - node.children.begin(); - it != node.children.end(); - ++it) { - ListValue* sublist = DxDiagNodeToList(it->second); - list->Append(NewDescriptionValuePair(it->first, sublist)); - } - return list; -} - -int GetGpuBlacklistHistogramValueWin(GpuFeatureStatus status) { - static WinSubVersion sub_version = kNumWinSubVersions; - if (sub_version == kNumWinSubVersions) { - sub_version = kWinOthers; - std::string version_str = base::SysInfo::OperatingSystemVersion(); - size_t pos = version_str.find_first_not_of("0123456789."); - if (pos != std::string::npos) - version_str = version_str.substr(0, pos); - scoped_ptr<Version> os_version(Version::GetVersionFromString(version_str)); - if (os_version.get() && os_version->components().size() >= 2) { - const std::vector<uint16>& version_numbers = os_version->components(); - if (version_numbers[0] == 5) - sub_version = kWinXP; - else if (version_numbers[0] == 6 && version_numbers[1] == 0) - sub_version = kWinVista; - else if (version_numbers[0] == 6 && version_numbers[1] == 1) - sub_version = kWin7; - } - } - int entry_index = static_cast<int>(sub_version) * kGpuFeatureNumStatus; - switch (status) { - case kGpuFeatureEnabled: - break; - case kGpuFeatureBlacklisted: - entry_index++; - break; - case kGpuFeatureDisabled: - entry_index += 2; - break; - } - return entry_index; -} -#endif // OS_WIN - } // namespace anonymous -GpuDataManager::UserFlags::UserFlags() - : disable_accelerated_2d_canvas_(false), - disable_accelerated_compositing_(false), - disable_accelerated_layers_(false), - disable_experimental_webgl_(false), - disable_gl_multisampling_(false), - disable_software_rasterizer_(false), - ignore_gpu_blacklist_(false), - skip_gpu_data_loading_(false), - blacklist_accelerated_compositing_(false), - blacklist_webgl_(false) { -} - -void GpuDataManager::UserFlags::Initialize() { - const CommandLine& browser_command_line = - *CommandLine::ForCurrentProcess(); - - disable_accelerated_2d_canvas_ = browser_command_line.HasSwitch( - switches::kDisableAccelerated2dCanvas); - disable_accelerated_compositing_ = browser_command_line.HasSwitch( - switches::kDisableAcceleratedCompositing); - disable_accelerated_layers_ = browser_command_line.HasSwitch( - switches::kDisableAcceleratedLayers); - disable_experimental_webgl_ = browser_command_line.HasSwitch( - switches::kDisableExperimentalWebGL); - disable_gl_multisampling_ = browser_command_line.HasSwitch( - switches::kDisableGLMultisampling); - disable_software_rasterizer_ = browser_command_line.HasSwitch( - switches::kDisableSoftwareRasterizer); - - ignore_gpu_blacklist_ = browser_command_line.HasSwitch( - switches::kIgnoreGpuBlacklist); - skip_gpu_data_loading_ = browser_command_line.HasSwitch( - switches::kSkipGpuDataLoading); - - blacklist_accelerated_compositing_ = browser_command_line.HasSwitch( - switches::kBlacklistAcceleratedCompositing); - blacklist_webgl_ = browser_command_line.HasSwitch( - switches::kBlacklistWebGL); - - use_gl_ = browser_command_line.GetSwitchValueASCII(switches::kUseGL); - - ApplyPolicies(); -} - -void GpuDataManager::UserFlags::ApplyPolicies() { - if (disable_accelerated_compositing_) { - disable_accelerated_2d_canvas_ = true; - disable_accelerated_layers_ = true; - } -} - GpuDataManager::GpuDataManager() : complete_gpu_info_already_requested_(false), complete_gpu_info_available_(false), + gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), + preliminary_gpu_feature_type_(content::GPU_FEATURE_TYPE_UNKNOWN), observer_list_(new GpuDataManagerObserverList), software_rendering_(false), card_blacklisted_(false) { @@ -214,10 +62,13 @@ GpuDataManager::GpuDataManager() } void GpuDataManager::Initialize() { - // User flags need to be collected before any further initialization. - user_flags_.Initialize(); + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { + command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); + command_line->AppendSwitch(switches::kDisableAcceleratedLayers); + } - if (!user_flags_.skip_gpu_data_loading()) { + if (!command_line->HasSwitch(switches::kSkipGpuDataLoading)) { content::GPUInfo gpu_info; gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); { @@ -269,8 +120,7 @@ void GpuDataManager::UpdateGpuInfo(const content::GPUInfo& gpu_info) { content::GetContentClient()->SetGpuInfo(gpu_info_); } - UpdateGpuFeatureFlags(); - // We have to update GpuFeatureFlags before notify all the observers. + // We have to update GpuFeatureType before notify all the observers. NotifyGpuInfoUpdate(); } @@ -279,144 +129,10 @@ const content::GPUInfo& GpuDataManager::gpu_info() const { return gpu_info_; } -Value* GpuDataManager::GetFeatureStatus() { - bool gpu_access_blocked = !GpuAccessAllowed(); - - uint32 flags = GetGpuFeatureFlags().flags(); - DictionaryValue* status = new DictionaryValue(); - - const GpuFeatureInfo kGpuFeatureInfo[] = { - { - "2d_canvas", - flags & GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas, - user_flags_.disable_accelerated_2d_canvas() || - !supportsAccelerated2dCanvas(), - "Accelerated 2D canvas is unavailable: either disabled at the command" - " line or not supported by the current system.", - true - }, - { - "compositing", - flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, - user_flags_.disable_accelerated_compositing(), - "Accelerated compositing has been disabled, either via about:flags or" - " command line. This adversely affects performance of all hardware" - " accelerated features.", - true - }, - { - "3d_css", - flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, - user_flags_.disable_accelerated_layers(), - "Accelerated layers have been disabled at the command line.", - false - }, - { - "webgl", - flags & GpuFeatureFlags::kGpuFeatureWebgl, - user_flags_.disable_experimental_webgl(), - "WebGL has been disabled, either via about:flags or command line.", - false - }, - { - "multisampling", - flags & GpuFeatureFlags::kGpuFeatureMultisampling, - user_flags_.disable_gl_multisampling(), - "Multisampling has been disabled, either via about:flags or command" - " line.", - false - } - }; - const size_t kNumFeatures = sizeof(kGpuFeatureInfo) / sizeof(GpuFeatureInfo); - - // Build the feature_status field. - { - ListValue* feature_status_list = new ListValue(); - - for (size_t i = 0; i < kNumFeatures; ++i) { - std::string status; - if (kGpuFeatureInfo[i].disabled) { - status = "disabled"; - if (kGpuFeatureInfo[i].fallback_to_software) - status += "_software"; - else - status += "_off"; - } else if (software_rendering()) { - status = "unavailable_software"; - } else if (kGpuFeatureInfo[i].blocked || - gpu_access_blocked) { - status = "unavailable"; - if (kGpuFeatureInfo[i].fallback_to_software) - status += "_software"; - else - status += "_off"; - } else { - status = "enabled"; - if (kGpuFeatureInfo[i].name == "webgl" && - (user_flags_.disable_accelerated_compositing() || - (flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing))) - status += "_readback"; - } - feature_status_list->Append( - NewStatusValue(kGpuFeatureInfo[i].name.c_str(), status.c_str())); - } - - status->Set("featureStatus", feature_status_list); - } - - // Build the problems list. - { - ListValue* problem_list = new ListValue(); - - if (gpu_access_blocked) { - DictionaryValue* problem = new DictionaryValue(); - problem->SetString("description", - "GPU process was unable to boot. Access to GPU disallowed."); - problem->Set("crBugs", new ListValue()); - problem->Set("webkitBugs", new ListValue()); - problem_list->Append(problem); - } - - for (size_t i = 0; i < kNumFeatures; ++i) { - if (kGpuFeatureInfo[i].disabled) { - DictionaryValue* problem = new DictionaryValue(); - problem->SetString( - "description", kGpuFeatureInfo[i].disabled_description); - problem->Set("crBugs", new ListValue()); - problem->Set("webkitBugs", new ListValue()); - problem_list->Append(problem); - } - } - - GpuBlacklist* blacklist = GetGpuBlacklist(); - if (blacklist) - blacklist->GetBlacklistReasons(problem_list); - - status->Set("problems", problem_list); - } - - return status; -} - GpuPerformanceStats GpuDataManager::GetPerformanceStats() const { return GpuPerformanceStats::RetrieveGpuPerformanceStats(); } -std::string GpuDataManager::GetBlacklistVersion() const { - GpuBlacklist* blacklist = GetGpuBlacklist(); - if (blacklist != NULL) { - uint16 version_major, version_minor; - if (blacklist->GetVersion(&version_major, &version_minor)) { - std::string version_string = - base::UintToString(static_cast<unsigned>(version_major)) + - "." + - base::UintToString(static_cast<unsigned>(version_minor)); - return version_string; - } - } - return ""; -} - void GpuDataManager::AddLogMessage(Value* msg) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); log_messages_.Append(msg); @@ -427,17 +143,17 @@ const ListValue& GpuDataManager::log_messages() const { return log_messages_; } -GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { +GpuFeatureType GpuDataManager::GetGpuFeatureType() { if (software_rendering_) { - GpuFeatureFlags flags; + GpuFeatureType flags; // Skia's software rendering is probably more efficient than going through // software emulation of the GPU, so use that. - flags.set_flags(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas); + flags = content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS; return flags; } - return gpu_feature_flags_; + return gpu_feature_type_; } bool GpuDataManager::GpuAccessAllowed() { @@ -447,8 +163,8 @@ bool GpuDataManager::GpuAccessAllowed() { // We only need to block GPU process if more features are disallowed other // than those in the preliminary gpu feature flags because the latter work // through renderer commandline switches. - uint32 mask = (~(preliminary_gpu_feature_flags_.flags())); - return (gpu_feature_flags_.flags() & mask) == 0; + uint32 mask = ~(preliminary_gpu_feature_type_); + return (gpu_feature_type_ & mask) == 0; } void GpuDataManager::AddObserver(Observer* observer) { @@ -464,20 +180,20 @@ void GpuDataManager::AppendRendererCommandLine( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(command_line); - uint32 flags = GpuFeatureFlags().flags(); - if ((flags & GpuFeatureFlags::kGpuFeatureWebgl)) { + uint32 flags = GetGpuFeatureType(); + if ((flags & content::GPU_FEATURE_TYPE_WEBGL)) { if (!command_line->HasSwitch(switches::kDisableExperimentalWebGL)) command_line->AppendSwitch(switches::kDisableExperimentalWebGL); if (!command_line->HasSwitch(switches::kDisablePepper3dForUntrustedUse)) command_line->AppendSwitch(switches::kDisablePepper3dForUntrustedUse); } - if ((flags & GpuFeatureFlags::kGpuFeatureMultisampling) && + if ((flags & content::GPU_FEATURE_TYPE_MULTISAMPLING) && !command_line->HasSwitch(switches::kDisableGLMultisampling)) command_line->AppendSwitch(switches::kDisableGLMultisampling); - if ((flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing) && + if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) && !command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); - if ((flags & GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas) && + if ((flags & content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) && !command_line->HasSwitch(switches::kDisableAccelerated2dCanvas)) command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); } @@ -487,8 +203,10 @@ void GpuDataManager::AppendGpuCommandLine( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(command_line); - uint32 flags = GpuFeatureFlags().flags(); - if ((flags & GpuFeatureFlags::kGpuFeatureMultisampling) && + std::string use_gl = + CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); + uint32 flags = GetGpuFeatureType(); + if ((flags & content::GPU_FEATURE_TYPE_MULTISAMPLING) && !command_line->HasSwitch(switches::kDisableGLMultisampling)) command_line->AppendSwitch(switches::kDisableGLMultisampling); @@ -496,26 +214,24 @@ void GpuDataManager::AppendGpuCommandLine( command_line->AppendSwitchASCII(switches::kUseGL, "swiftshader"); command_line->AppendSwitchPath(switches::kSwiftShaderPath, swiftshader_path_); - } else if ((flags & (GpuFeatureFlags::kGpuFeatureWebgl | - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing | - GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)) && - (user_flags_.use_gl() == "any")) { + } else if ((flags & (content::GPU_FEATURE_TYPE_WEBGL | + content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | + content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) && + (use_gl == "any")) { command_line->AppendSwitchASCII( switches::kUseGL, gfx::kGLImplementationOSMesaName); - } else if (!user_flags_.use_gl().empty()) { - command_line->AppendSwitchASCII(switches::kUseGL, user_flags_.use_gl()); + } else if (!use_gl.empty()) { + command_line->AppendSwitchASCII(switches::kUseGL, use_gl); } if (gpu_info().optimus) command_line->AppendSwitch(switches::kReduceGpuSandbox); } -void GpuDataManager::SetGpuBlacklist(GpuBlacklist* gpu_blacklist) { +void GpuDataManager::SetGpuFeatureType(GpuFeatureType feature_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(gpu_blacklist); - gpu_blacklist_.reset(gpu_blacklist); - UpdateGpuFeatureFlags(); - preliminary_gpu_feature_flags_ = gpu_feature_flags_; + UpdateGpuFeatureType(feature_type); + preliminary_gpu_feature_type_ = gpu_feature_type_; } void GpuDataManager::HandleGpuSwitch() { @@ -530,158 +246,28 @@ void GpuDataManager::HandleGpuSwitch() { // relaunch GPU process. } -DictionaryValue* GpuDataManager::GpuInfoAsDictionaryValue() const { - ListValue* basic_info = new ListValue(); - basic_info->Append(NewDescriptionValuePair( - "Initialization time", - base::Int64ToString(gpu_info().initialization_time.InMilliseconds()))); - basic_info->Append(NewDescriptionValuePair( - "Vendor Id", base::StringPrintf("0x%04x", gpu_info().vendor_id))); - basic_info->Append(NewDescriptionValuePair( - "Device Id", base::StringPrintf("0x%04x", gpu_info().device_id))); - basic_info->Append(NewDescriptionValuePair( - "Optimus", Value::CreateBooleanValue(gpu_info().optimus))); - basic_info->Append(NewDescriptionValuePair("Driver vendor", - gpu_info().driver_vendor)); - basic_info->Append(NewDescriptionValuePair("Driver version", - gpu_info().driver_version)); - basic_info->Append(NewDescriptionValuePair("Driver date", - gpu_info().driver_date)); - basic_info->Append(NewDescriptionValuePair("Pixel shader version", - gpu_info().pixel_shader_version)); - basic_info->Append(NewDescriptionValuePair("Vertex shader version", - gpu_info().vertex_shader_version)); - basic_info->Append(NewDescriptionValuePair("GL version", - gpu_info().gl_version)); - basic_info->Append(NewDescriptionValuePair("GL_VENDOR", - gpu_info().gl_vendor)); - basic_info->Append(NewDescriptionValuePair("GL_RENDERER", - gpu_info().gl_renderer)); - basic_info->Append(NewDescriptionValuePair("GL_VERSION", - gpu_info().gl_version_string)); - basic_info->Append(NewDescriptionValuePair("GL_EXTENSIONS", - gpu_info().gl_extensions)); - - DictionaryValue* info = new DictionaryValue(); - info->Set("basic_info", basic_info); - -#if defined(OS_WIN) - Value* dx_info; - if (gpu_info().dx_diagnostics.children.size()) - dx_info = DxDiagNodeToList(gpu_info().dx_diagnostics); - else - dx_info = Value::CreateNullValue(); - info->Set("diagnostics", dx_info); -#endif - - return info; -} - void GpuDataManager::NotifyGpuInfoUpdate() { observer_list_->Notify(&GpuDataManager::Observer::OnGpuInfoUpdate); } -void GpuDataManager::UpdateGpuFeatureFlags() { +void GpuDataManager::UpdateGpuFeatureType( + GpuFeatureType embedder_feature_type) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - GpuBlacklist* gpu_blacklist = GetGpuBlacklist(); - // We don't set a lock around modifying gpu_feature_flags_ since it's just an - // int. - if (!gpu_blacklist) { - gpu_feature_flags_.set_flags(0); - return; - } + CommandLine* command_line = CommandLine::ForCurrentProcess(); + int flags = embedder_feature_type; - { - base::AutoLock auto_lock(gpu_info_lock_); - GpuFeatureFlags flags = gpu_blacklist->DetermineGpuFeatureFlags( - GpuBlacklist::kOsAny, NULL, gpu_info_); - - // Force disable using the GPU for these features, even if they would - // otherwise be allowed. - if (card_blacklisted_ || user_flags_.blacklist_accelerated_compositing()) - flags.set_flags(flags.flags() | - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing); - if (card_blacklisted_ || user_flags_.blacklist_webgl()) - flags.set_flags(flags.flags() | GpuFeatureFlags::kGpuFeatureWebgl); - gpu_feature_flags_ = flags; + // Force disable using the GPU for these features, even if they would + // otherwise be allowed. + if (card_blacklisted_ || + command_line->HasSwitch(switches::kBlacklistAcceleratedCompositing)) { + flags |= content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING; } - - - 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, disabled); - DCHECK_GT(flag_entries.size(), 0u); - for (size_t i = 0; i < flag_entries.size(); ++i) { - UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", - flag_entries[i], max_entry_id + 1); - } - } - - // 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, - GpuFeatureFlags::kGpuFeatureWebgl - }; - const std::string kGpuBlacklistFeatureHistogramNames[] = { - "GPU.BlacklistFeatureTestResults.Accelerated2dCanvas", - "GPU.BlacklistFeatureTestResults.AcceleratedCompositing", - "GPU.BlacklistFeatureTestResults.Webgl" - }; - const bool kGpuFeatureUserFlags[] = { - user_flags_.disable_accelerated_2d_canvas(), - user_flags_.disable_accelerated_compositing(), - user_flags_.disable_experimental_webgl() - }; -#if defined(OS_WIN) - const std::string kGpuBlacklistFeatureHistogramNamesWin[] = { - "GPU.BlacklistFeatureTestResultsWindows.Accelerated2dCanvas", - "GPU.BlacklistFeatureTestResultsWindows.AcceleratedCompositing", - "GPU.BlacklistFeatureTestResultsWindows.Webgl" - }; -#endif - const size_t kNumFeatures = - sizeof(kGpuFeatures) / sizeof(GpuFeatureFlags::GpuFeatureType); - for (size_t i = 0; i < kNumFeatures; ++i) { - // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is - // expected if the macro is used within a loop. - GpuFeatureStatus value = kGpuFeatureEnabled; - if (flags & kGpuFeatures[i]) - value = kGpuFeatureBlacklisted; - else if (kGpuFeatureUserFlags[i]) - value = kGpuFeatureDisabled; - base::Histogram* histogram_pointer = base::LinearHistogram::FactoryGet( - kGpuBlacklistFeatureHistogramNames[i], - 1, kGpuFeatureNumStatus, kGpuFeatureNumStatus + 1, - base::Histogram::kUmaTargetedHistogramFlag); - histogram_pointer->Add(value); -#if defined(OS_WIN) - histogram_pointer = base::LinearHistogram::FactoryGet( - kGpuBlacklistFeatureHistogramNamesWin[i], - 1, kNumWinSubVersions * kGpuFeatureNumStatus, - kNumWinSubVersions * kGpuFeatureNumStatus + 1, - base::Histogram::kUmaTargetedHistogramFlag); - histogram_pointer->Add(GetGpuBlacklistHistogramValueWin(value)); -#endif + if (card_blacklisted_ || + command_line->HasSwitch(switches::kBlacklistWebGL)) { + flags |= content::GPU_FEATURE_TYPE_WEBGL; } + gpu_feature_type_ = static_cast<GpuFeatureType>(flags); EnableSoftwareRenderingIfNecessary(); } @@ -693,10 +279,11 @@ void GpuDataManager::RegisterSwiftShaderPath(FilePath path) { void GpuDataManager::EnableSoftwareRenderingIfNecessary() { if (!GpuAccessAllowed() || - (gpu_feature_flags_.flags() & GpuFeatureFlags::kGpuFeatureWebgl)) { + (gpu_feature_type_ & content::GPU_FEATURE_TYPE_WEBGL)) { #if defined(ENABLE_SWIFTSHADER) if (!swiftshader_path_.empty() && - !user_flags_.disable_software_rasterizer()) + !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableSoftwareRasterizer)) software_rendering_ = true; #endif } @@ -711,27 +298,16 @@ void GpuDataManager::BlacklistCard() { { base::AutoLock auto_lock(gpu_info_lock_); - GpuFeatureFlags flags = gpu_feature_flags_; - flags.set_flags(flags.flags() | - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing | - GpuFeatureFlags::kGpuFeatureWebgl); - gpu_feature_flags_ = flags; + int flags = gpu_feature_type_; + flags |= content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | + content::GPU_FEATURE_TYPE_WEBGL; + gpu_feature_type_ = static_cast<GpuFeatureType>(flags); } EnableSoftwareRenderingIfNecessary(); NotifyGpuInfoUpdate(); } -GpuBlacklist* GpuDataManager::GetGpuBlacklist() const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (user_flags_.ignore_gpu_blacklist()) - return NULL; - // No need to return an empty blacklist. - if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) - return NULL; - return gpu_blacklist_.get(); -} - bool GpuDataManager::Merge(content::GPUInfo* object, const content::GPUInfo& other) { if (object->device_id != other.device_id || @@ -797,14 +373,3 @@ bool GpuDataManager::Merge(content::GPUInfo* object, } return changed; } - -bool GpuDataManager::supportsAccelerated2dCanvas() const { - if (gpu_info_.can_lose_context) - return false; -#if defined(USE_SKIA) - return true; -#else - return false; -#endif -} - diff --git a/content/browser/gpu/gpu_data_manager.h b/content/browser/gpu/gpu_data_manager.h index 331eaca..76977bf 100644 --- a/content/browser/gpu/gpu_data_manager.h +++ b/content/browser/gpu/gpu_data_manager.h @@ -17,11 +17,10 @@ #include "base/values.h" #include "content/browser/gpu/gpu_performance_stats.h" #include "content/common/content_export.h" -#include "content/common/gpu/gpu_feature_flags.h" +#include "content/public/common/gpu_feature_type.h" #include "content/public/common/gpu_info.h" class CommandLine; -class GpuBlacklist; class CONTENT_EXPORT GpuDataManager { public: @@ -51,46 +50,14 @@ class CONTENT_EXPORT GpuDataManager { return complete_gpu_info_available_; } - // Returns status of various GPU features. This is two parted: - // { - // featureStatus: [] - // problems: [] - // } - // - // Each entry in feature_status has: - // { - // name: "name of feature" - // status: "enabled" | "unavailable_software" | "unavailable_off" | - // "software" | "disabled_off" | "disabled_softare"; - // } - // - // The features reported are not 1:1 with GpuFeatureType. Rather, they are: - // '2d_canvas' - // '3d_css' - // 'composting', - // 'webgl', - // 'multisampling' - // - // Each problems has: - // { - // "description": "Your GPU is too old", - // "crBugs": [1234], - // "webkitBugs": [] - // } - // - // Caller is responsible for deleting the returned value. - Value* GetFeatureStatus(); - GpuPerformanceStats GetPerformanceStats() const; - std::string GetBlacklistVersion() const; - void AddLogMessage(Value* msg); const ListValue& log_messages() const; // Can be called on any thread. - GpuFeatureFlags GetGpuFeatureFlags(); + content::GpuFeatureType GetGpuFeatureType(); // This indicator might change because we could collect more GPU info or // because the GPU blacklist could be updated. @@ -118,16 +85,12 @@ class CONTENT_EXPORT GpuDataManager { // kDisableGLMultisampling. void AppendGpuCommandLine(CommandLine* command_line); - // Gives ownership of the built-in blacklist. This is always called on the - // UI thread. - void SetGpuBlacklist(GpuBlacklist* gpu_blacklist); + // Gives the new feature flags. This is always called on the UI thread. + void SetGpuFeatureType(content::GpuFeatureType feature_type); // This gets called when switching GPU might have happened. void HandleGpuSwitch(); - // Returns the Gpu Info as a DictionaryValue. - DictionaryValue* GpuInfoAsDictionaryValue() const; - // Returns true if the software rendering should currently be used. bool software_rendering(); @@ -139,68 +102,6 @@ class CONTENT_EXPORT GpuDataManager { void BlacklistCard(); private: - class UserFlags { - public: - UserFlags(); - - void Initialize(); - - bool disable_accelerated_2d_canvas() const { - return disable_accelerated_2d_canvas_; - } - - bool disable_accelerated_compositing() const { - return disable_accelerated_compositing_; - } - - bool disable_accelerated_layers() const { - return disable_accelerated_layers_; - } - - bool disable_experimental_webgl() const { - return disable_experimental_webgl_; - } - - bool disable_gl_multisampling() const { return disable_gl_multisampling_; } - - bool disable_software_rasterizer() const { - return disable_software_rasterizer_; - } - - bool ignore_gpu_blacklist() const { return ignore_gpu_blacklist_; } - - bool skip_gpu_data_loading() const { return skip_gpu_data_loading_; } - - const std::string& use_gl() const { return use_gl_; } - - bool blacklist_accelerated_compositing() const { - return blacklist_accelerated_compositing_; - } - - bool blacklist_webgl() const { return blacklist_webgl_; } - - private: - // Manage the correlations between switches. - void ApplyPolicies(); - - bool disable_accelerated_2d_canvas_; - bool disable_accelerated_compositing_; - bool disable_accelerated_layers_; - bool disable_experimental_webgl_; - bool disable_gl_multisampling_; - bool disable_software_rasterizer_; - - bool ignore_gpu_blacklist_; - bool skip_gpu_data_loading_; - - std::string use_gl_; - - // Flags to disallow running accelerated compositing or webgl on the GPU. - // Software rendering is still allowed. - bool blacklist_accelerated_compositing_; - bool blacklist_webgl_; - }; - typedef ObserverListThreadSafe<GpuDataManager::Observer> GpuDataManagerObserverList; @@ -211,13 +112,9 @@ class CONTENT_EXPORT GpuDataManager { void Initialize(); - // Check if we should go ahead and use gpu blacklist. - // If not, return NULL; otherwise, update and return the current list. - GpuBlacklist* GetGpuBlacklist() const; - // If flags hasn't been set and GPUInfo is available, run through blacklist // and compute the flags. - void UpdateGpuFeatureFlags(); + void UpdateGpuFeatureType(content::GpuFeatureType embedder_feature_type); // Notify all observers whenever there is a GPU info update. void NotifyGpuInfoUpdate(); @@ -234,26 +131,18 @@ class CONTENT_EXPORT GpuDataManager { // and gl_renderer. static bool Merge(content::GPUInfo* object, const content::GPUInfo& other); - // Determin if accelerated-2d-canvas is supported, which depends on whether - // lose_context could happen and whether skia is the backend. - bool supportsAccelerated2dCanvas() const; - // Try to switch to software rendering, if possible and necessary. void EnableSoftwareRenderingIfNecessary(); bool complete_gpu_info_already_requested_; bool complete_gpu_info_available_; - GpuFeatureFlags gpu_feature_flags_; - GpuFeatureFlags preliminary_gpu_feature_flags_; - - UserFlags user_flags_; + content::GpuFeatureType gpu_feature_type_; + content::GpuFeatureType preliminary_gpu_feature_type_; content::GPUInfo gpu_info_; mutable base::Lock gpu_info_lock_; - scoped_ptr<GpuBlacklist> gpu_blacklist_; - // Observers. const scoped_refptr<GpuDataManagerObserverList> observer_list_; diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index bd0f553..4308cbc 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -25,6 +25,7 @@ #include "content/gpu/gpu_child_thread.h" #include "content/gpu/gpu_process.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/content_browser_client.h" #include "content/public/common/content_switches.h" #include "content/public/common/result_codes.h" #include "ipc/ipc_channel_handle.h" @@ -605,11 +606,8 @@ bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) { cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, arraysize(kSwitchNames)); - // If --ignore-gpu-blacklist is passed in, don't send in crash reports - // because GPU is expected to be unreliable. - if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) && - !cmd_line->HasSwitch(switches::kDisableBreakpad)) - cmd_line->AppendSwitch(switches::kDisableBreakpad); + content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( + cmd_line, process_->GetData().id); GpuDataManager::GetInstance()->AppendGpuCommandLine(cmd_line); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 126019a..9ab8f1b 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -414,14 +414,14 @@ WebPreferences TabContents::GetWebkitPrefs(RenderViewHost* rvh, { // Certain GPU features might have been blacklisted. GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance(); DCHECK(gpu_data_manager); - uint32 blacklist_flags = gpu_data_manager->GetGpuFeatureFlags().flags(); - if (blacklist_flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing) + uint32 blacklist_type = gpu_data_manager->GetGpuFeatureType(); + if (blacklist_type & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) prefs.accelerated_compositing_enabled = false; - if (blacklist_flags & GpuFeatureFlags::kGpuFeatureWebgl) + if (blacklist_type & content::GPU_FEATURE_TYPE_WEBGL) prefs.experimental_webgl_enabled = false; - if (blacklist_flags & GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas) + if (blacklist_type & content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) prefs.accelerated_2d_canvas_enabled = false; - if (blacklist_flags & GpuFeatureFlags::kGpuFeatureMultisampling) + if (blacklist_type & content::GPU_FEATURE_TYPE_MULTISAMPLING) prefs.gl_multisampling_enabled = false; // Accelerated video and animation are slower than regular when using a diff --git a/content/common/gpu/gpu_feature_flags.cc b/content/common/gpu/gpu_feature_flags.cc deleted file mode 100644 index 437a5b3..0000000 --- a/content/common/gpu/gpu_feature_flags.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2011 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. - -#include "content/common/gpu/gpu_feature_flags.h" - -#include "base/logging.h" -#include "base/string_util.h" -#include <vector> - -const char GpuFeatureFlags::kGpuFeatureNameAccelerated2dCanvas[] = - "accelerated_2d_canvas"; -const char GpuFeatureFlags::kGpuFeatureNameAcceleratedCompositing[] = - "accelerated_compositing"; -const char GpuFeatureFlags::kGpuFeatureNameWebgl[] = "webgl"; -const char GpuFeatureFlags::kGpuFeatureNameMultisampling[] = "multisampling"; -const char GpuFeatureFlags::kGpuFeatureNameAll[] = "all"; -const char GpuFeatureFlags::kGpuFeatureNameUnknown[] = "unknown"; - -GpuFeatureFlags::GpuFeatureFlags() - : flags_(0) { -} - -void GpuFeatureFlags::set_flags(uint32 flags) { - DCHECK_EQ(flags & (~kGpuFeatureAll), 0u); - flags_ = flags; -} - -uint32 GpuFeatureFlags::flags() const { - return flags_; -} - -void GpuFeatureFlags::Combine(const GpuFeatureFlags& other) { - flags_ |= other.flags_; -} - -// static -GpuFeatureFlags::GpuFeatureType GpuFeatureFlags::StringToGpuFeatureType( - const std::string& feature_string) { - if (feature_string == kGpuFeatureNameAccelerated2dCanvas) - return kGpuFeatureAccelerated2dCanvas; - else if (feature_string == kGpuFeatureNameAcceleratedCompositing) - return kGpuFeatureAcceleratedCompositing; - else if (feature_string == kGpuFeatureNameWebgl) - return kGpuFeatureWebgl; - else if (feature_string == kGpuFeatureNameMultisampling) - return kGpuFeatureMultisampling; - else if (feature_string == kGpuFeatureNameAll) - return kGpuFeatureAll; - return kGpuFeatureUnknown; -} - -// static -std::string GpuFeatureFlags::GpuFeatureTypeToString( - GpuFeatureFlags::GpuFeatureType type) { - std::vector<std::string> matches; - if (type == kGpuFeatureAll) { - matches.push_back(kGpuFeatureNameAll); - } else { - if (kGpuFeatureAccelerated2dCanvas & type) - matches.push_back(kGpuFeatureNameAccelerated2dCanvas); - if (kGpuFeatureAcceleratedCompositing & type) - matches.push_back(kGpuFeatureNameAcceleratedCompositing); - if (kGpuFeatureWebgl & type) - matches.push_back(kGpuFeatureNameWebgl); - if (kGpuFeatureMultisampling & type) - matches.push_back(kGpuFeatureNameMultisampling); - if (!matches.size()) - matches.push_back(kGpuFeatureNameUnknown); - } - return JoinString(matches, ','); -} diff --git a/content/common/gpu/gpu_feature_flags.h b/content/common/gpu/gpu_feature_flags.h deleted file mode 100644 index b48ec97..0000000 --- a/content/common/gpu/gpu_feature_flags.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef CONTENT_COMMON_GPU_GPU_FEATURE_FLAGS_H_ -#define CONTENT_COMMON_GPU_GPU_FEATURE_FLAGS_H_ -#pragma once - -// Provides flags indicating which gpu features are blacklisted for the system -// on which chrome is currently running. - -#include <string> - -#include "base/basictypes.h" -#include "content/common/content_export.h" - -class CONTENT_EXPORT GpuFeatureFlags { - public: - enum GpuFeatureType { - kGpuFeatureAccelerated2dCanvas = 1 << 0, - kGpuFeatureAcceleratedCompositing = 1 << 1, - kGpuFeatureWebgl = 1 << 2, - kGpuFeatureMultisampling = 1 << 3, - kGpuFeatureAll = kGpuFeatureAccelerated2dCanvas | - kGpuFeatureAcceleratedCompositing | - kGpuFeatureWebgl | - kGpuFeatureMultisampling, - kGpuFeatureUnknown = 0 - }; - - // All flags initialized to false, i.e., no feature is blacklisted. - GpuFeatureFlags(); - - // flags are OR combination of GpuFeatureType. - void set_flags(uint32 flags); - - uint32 flags() const; - - // Resets each flag by OR with the corresponding flag in "other". - void Combine(const GpuFeatureFlags& other); - - // Maps string to GpuFeatureType; returns kGpuFeatureUnknown if none of the - // following is input (case-sensitive): - // "accelerated_2d_canvas" - // "accelerated_compositing" - // "webgl" - // "multisampling" - static GpuFeatureType StringToGpuFeatureType( - const std::string& feature_string); - - // Gets a string version of a feature type for use in about:gpu. Will yield - // strings from StringToGpuFeatureType, e.g. kGpuFeatureAccelerated2dCanvas - // becomes "accelerated_2d_canvas" - static std::string GpuFeatureTypeToString(GpuFeatureType feature); - - private: - static const char kGpuFeatureNameAccelerated2dCanvas[]; - static const char kGpuFeatureNameAcceleratedCompositing[]; - static const char kGpuFeatureNameWebgl[]; - static const char kGpuFeatureNameMultisampling[]; - static const char kGpuFeatureNameAll[]; - static const char kGpuFeatureNameUnknown[]; - - // If a bit is set to 1, corresponding feature is blacklisted. - uint32 flags_; -}; - -#endif // CONTENT_COMMON_GPU_GPU_FEATURE_FLAGS_H_ diff --git a/content/common/gpu/gpu_feature_flags_unittest.cc b/content/common/gpu/gpu_feature_flags_unittest.cc deleted file mode 100644 index 550af23..0000000 --- a/content/common/gpu/gpu_feature_flags_unittest.cc +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2011 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. - -#include "content/common/gpu/gpu_feature_flags.h" -#include "testing/gtest/include/gtest/gtest.h" - -TEST(GpuFeatureFlagsTest, GpuFeatureFlagsBasic) { - // Test that by default all flags are set to false. - GpuFeatureFlags flags; - EXPECT_EQ(flags.flags(), 0u); - - // Test SetFlags(). - GpuFeatureFlags flags2; - flags2.set_flags(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing | - GpuFeatureFlags::kGpuFeatureWebgl); - EXPECT_EQ(flags2.flags(), - static_cast<uint32>( - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing | - GpuFeatureFlags::kGpuFeatureWebgl)); - - // Test Combine() is basically OR operation per flag. - flags.set_flags(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas); - flags.Combine(flags2); - EXPECT_EQ(flags.flags(), - static_cast<uint32>( - GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas | - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing | - GpuFeatureFlags::kGpuFeatureWebgl)); - - // Test the currently supported feature set. - flags.set_flags(GpuFeatureFlags::kGpuFeatureAll); - EXPECT_EQ(flags.flags(), - static_cast<uint32>( - GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas | - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing | - GpuFeatureFlags::kGpuFeatureWebgl | - GpuFeatureFlags::kGpuFeatureMultisampling)); - - // Test StringToGpuFeatureType. - EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("accelerated_2d_canvas"), - GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas); - EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("accelerated_compositing"), - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing); - EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("webgl"), - GpuFeatureFlags::kGpuFeatureWebgl); - EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("multisampling"), - GpuFeatureFlags::kGpuFeatureMultisampling); - EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("all"), - GpuFeatureFlags::kGpuFeatureAll); - EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("xxx"), - GpuFeatureFlags::kGpuFeatureUnknown); -} - -TEST(GpuFeatureFlagsTest, GpuFeatureTypeToString) { - - // Test GpuFeatureTypeToString for single-bit enums using the all enum - EXPECT_STREQ( - GpuFeatureFlags::GpuFeatureTypeToString( - GpuFeatureFlags::kGpuFeatureAcceleratedCompositing).c_str(), - "accelerated_compositing"); - EXPECT_STREQ( - GpuFeatureFlags::GpuFeatureTypeToString( - GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas).c_str(), - "accelerated_2d_canvas"); - EXPECT_STREQ( - GpuFeatureFlags::GpuFeatureTypeToString( - GpuFeatureFlags::kGpuFeatureWebgl).c_str(), - "webgl"); - EXPECT_STREQ( - GpuFeatureFlags::GpuFeatureTypeToString( - GpuFeatureFlags::kGpuFeatureMultisampling).c_str(), - "multisampling"); - EXPECT_STREQ( - GpuFeatureFlags::GpuFeatureTypeToString( - GpuFeatureFlags::kGpuFeatureAll).c_str(), - "all"); - EXPECT_STREQ(GpuFeatureFlags::GpuFeatureTypeToString( - GpuFeatureFlags::kGpuFeatureUnknown).c_str(), - "unknown"); - EXPECT_STREQ( - GpuFeatureFlags::GpuFeatureTypeToString( - static_cast<GpuFeatureFlags::GpuFeatureType>( - GpuFeatureFlags::kGpuFeatureWebgl | - GpuFeatureFlags::kGpuFeatureMultisampling)).c_str(), - "webgl,multisampling"); - - std::string tmp; - tmp = GpuFeatureFlags::GpuFeatureTypeToString( - static_cast<GpuFeatureFlags::GpuFeatureType>( - GpuFeatureFlags::kGpuFeatureWebgl | - GpuFeatureFlags::kGpuFeatureAll)); - EXPECT_STREQ(tmp.c_str(), "all"); -} diff --git a/content/content_browser.gypi b/content/content_browser.gypi index d9c32bf..b9b9346 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -318,8 +318,6 @@ 'browser/geolocation/win7_location_provider_win.h', 'browser/gpu/browser_gpu_channel_host_factory.cc', 'browser/gpu/browser_gpu_channel_host_factory.h', - 'browser/gpu/gpu_blacklist.cc', - 'browser/gpu/gpu_blacklist.h', 'browser/gpu/gpu_data_manager.cc', 'browser/gpu/gpu_data_manager.h', 'browser/gpu/gpu_performance_stats.cc', diff --git a/content/content_common.gypi b/content/content_common.gypi index 7f87360..d860215 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -48,6 +48,7 @@ 'public/common/file_chooser_params.h', 'public/common/frame_navigate_params.cc', 'public/common/frame_navigate_params.h', + 'public/common/gpu_feature_type.h', 'public/common/gpu_info.cc', 'public/common/gpu_info.h', 'public/common/main_function_params.h', @@ -168,8 +169,6 @@ 'common/gpu/gpu_command_buffer_stub.cc', 'common/gpu/gpu_command_buffer_stub.h', 'common/gpu/gpu_config.h', - 'common/gpu/gpu_feature_flags.cc', - 'common/gpu/gpu_feature_flags.h', 'common/gpu/gpu_memory_allocation.h', 'common/gpu/gpu_memory_manager.cc', 'common/gpu/gpu_memory_manager.h', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 19077ca..90be605 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -215,7 +215,6 @@ 'browser/geolocation/wifi_data_provider_unittest_win.cc', 'browser/geolocation/win7_location_api_unittest_win.cc', 'browser/geolocation/win7_location_provider_unittest_win.cc', - 'browser/gpu/gpu_blacklist_unittest.cc', 'browser/host_zoom_map_impl_unittest.cc', 'browser/in_process_webkit/dom_storage_unittest.cc', 'browser/in_process_webkit/indexed_db_quota_client_unittest.cc', @@ -256,7 +255,6 @@ 'browser/trace_subscriber_stdio_unittest.cc', 'common/mac/attributed_string_coder_unittest.mm', 'common/mac/font_descriptor_unittest.mm', - 'common/gpu/gpu_feature_flags_unittest.cc', 'common/gpu/gpu_info_unittest.cc', 'common/gpu/gpu_memory_manager_unittest.cc', 'common/hi_res_timer_manager_unittest.cc', diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index bcbdf11..708fdd6 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -361,9 +361,6 @@ const char kGpuProcess[] = "gpu-process"; // Causes the GPU process to display a dialog on launch. const char kGpuStartupDialog[] = "gpu-startup-dialog"; -// Ignores GPU blacklist. -const char kIgnoreGpuBlacklist[] = "ignore-gpu-blacklist"; - // Run the GPU process as a thread in the browser process. const char kInProcessGPU[] = "in-process-gpu"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 0937325..1c05a199 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -113,7 +113,6 @@ CONTENT_EXPORT extern const char kForceRendererAccessibility[]; extern const char kGpuLauncher[]; CONTENT_EXPORT extern const char kGpuProcess[]; extern const char kGpuStartupDialog[]; -CONTENT_EXPORT extern const char kIgnoreGpuBlacklist[]; extern const char kInProcessGPU[]; extern const char kInProcessPlugins[]; CONTENT_EXPORT extern const char kInProcessWebGL[]; diff --git a/content/public/common/gpu_feature_type.h b/content/public/common/gpu_feature_type.h new file mode 100644 index 0000000..259d911 --- /dev/null +++ b/content/public/common/gpu_feature_type.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 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. + +#ifndef CONTENT_PUBLIC_COMMON_GPU_FEATURE_TYPE_H_ +#define CONTENT_PUBLIC_COMMON_GPU_FEATURE_TYPE_H_ +#pragma once + +namespace content { + +// Provides flags indicating which gpu features are blacklisted for the system +// on which chrome is currently running. +// If a bit is set to 1, corresponding feature is blacklisted. +enum GpuFeatureType { + GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS = 1 << 0, + GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING = 1 << 1, + GPU_FEATURE_TYPE_WEBGL = 1 << 2, + GPU_FEATURE_TYPE_MULTISAMPLING = 1 << 3, + GPU_FEATURE_TYPE_ALL = GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS | + GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING | + GPU_FEATURE_TYPE_WEBGL | + GPU_FEATURE_TYPE_MULTISAMPLING, + // All flags initialized to false, i.e., no feature is blacklisted. + GPU_FEATURE_TYPE_UNKNOWN = 0 +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_GPU_FEATURE_TYPE_H_ |