Commit e0a06a4c authored by Zhenyao Mo's avatar Zhenyao Mo Committed by Commit Bot

Move more status checking to GpuFeatureInfo.

And delete functions that become obsolete.

BUG=744658
TEST=bots
R=piman@chromium.org,kbr@chromium.org
TBR=asargent@chromium.org

Change-Id: Ib840edfb89b904a8972cbdd441ed3a4fc1d39e48
Reviewed-on: https://chromium-review.googlesource.com/835272
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525354}
parent 6dff98f0
...@@ -427,8 +427,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstoreGetWebGLStatusTest, Allowed) { ...@@ -427,8 +427,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstoreGetWebGLStatusTest, Allowed) {
// Tests getWebGLStatus function when WebGL is blacklisted. // Tests getWebGLStatus function when WebGL is blacklisted.
IN_PROC_BROWSER_TEST_F(ExtensionWebstoreGetWebGLStatusTest, Blocked) { IN_PROC_BROWSER_TEST_F(ExtensionWebstoreGetWebGLStatusTest, Blocked) {
content::GpuDataManager::GetInstance()->BlacklistWebGLForTesting(); content::GpuDataManager::GetInstance()->BlacklistWebGLForTesting();
EXPECT_TRUE(content::GpuDataManager::GetInstance()->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
bool webgl_allowed = false; bool webgl_allowed = false;
RunTest(webgl_allowed); RunTest(webgl_allowed);
......
...@@ -57,6 +57,15 @@ void GpuDataManagerImpl::BlacklistWebGLForTesting() { ...@@ -57,6 +57,15 @@ void GpuDataManagerImpl::BlacklistWebGLForTesting() {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
private_->InitializeForTesting(kData, gpu_info); private_->InitializeForTesting(kData, gpu_info);
gpu::GpuFeatureInfo gpu_feature_info;
for (int ii = 0; ii < gpu::NUMBER_OF_GPU_FEATURE_TYPES; ++ii) {
if (ii == static_cast<int>(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL))
gpu_feature_info.status_values[ii] = gpu::kGpuFeatureStatusBlacklisted;
else
gpu_feature_info.status_values[ii] = gpu::kGpuFeatureStatusEnabled;
}
private_->UpdateGpuFeatureInfo(gpu_feature_info);
} }
void GpuDataManagerImpl::InitializeForTesting( void GpuDataManagerImpl::InitializeForTesting(
...@@ -66,26 +75,6 @@ void GpuDataManagerImpl::InitializeForTesting( ...@@ -66,26 +75,6 @@ void GpuDataManagerImpl::InitializeForTesting(
private_->InitializeForTesting(gpu_blacklist_data, gpu_info); private_->InitializeForTesting(gpu_blacklist_data, gpu_info);
} }
bool GpuDataManagerImpl::IsFeatureBlacklisted(int feature) const {
base::AutoLock auto_lock(lock_);
return private_->IsFeatureBlacklisted(feature);
}
bool GpuDataManagerImpl::IsFeatureEnabled(int feature) const {
base::AutoLock auto_lock(lock_);
return private_->IsFeatureEnabled(feature);
}
bool GpuDataManagerImpl::IsWebGLEnabled() const {
base::AutoLock auto_lock(lock_);
return private_->IsWebGLEnabled();
}
bool GpuDataManagerImpl::IsWebGL2Enabled() const {
base::AutoLock auto_lock(lock_);
return private_->IsWebGL2Enabled();
}
gpu::GPUInfo GpuDataManagerImpl::GetGPUInfo() const { gpu::GPUInfo GpuDataManagerImpl::GetGPUInfo() const {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
return private_->GetGPUInfo(); return private_->GetGPUInfo();
......
...@@ -65,10 +65,6 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager { ...@@ -65,10 +65,6 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager {
// GpuDataManager implementation. // GpuDataManager implementation.
void BlacklistWebGLForTesting() override; void BlacklistWebGLForTesting() override;
bool IsFeatureBlacklisted(int feature) const override;
bool IsFeatureEnabled(int feature) const override;
bool IsWebGLEnabled() const override;
bool IsWebGL2Enabled() const override;
gpu::GPUInfo GetGPUInfo() const override; gpu::GPUInfo GetGPUInfo() const override;
bool GpuAccessAllowed(std::string* reason) const override; bool GpuAccessAllowed(std::string* reason) const override;
void RequestCompleteGpuInfoIfNeeded() override; void RequestCompleteGpuInfoIfNeeded() override;
......
...@@ -333,28 +333,14 @@ void GpuDataManagerImplPrivate::InitializeForTesting( ...@@ -333,28 +333,14 @@ void GpuDataManagerImplPrivate::InitializeForTesting(
finalized_ = true; finalized_ = true;
InitializeImpl(gpu_blacklist_data, gpu_info); InitializeImpl(gpu_blacklist_data, gpu_info);
}
bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { // TODO(zmo): Find a better mechanism to blacklist features for testing.
// SwiftShader blacklists all features base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
return use_swiftshader_ || (blacklisted_features_.count(feature) == 1); if (gpu_feature_info_
} .status_values[gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL] ==
gpu::kGpuFeatureStatusBlacklisted) {
bool GpuDataManagerImplPrivate::IsFeatureEnabled(int feature) const { cmd_line->AppendSwitch(switches::kDisableWebGL);
DCHECK_EQ(feature, gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION); }
return gpu_feature_info_
.status_values[gpu::GPU_FEATURE_TYPE_GPU_RASTERIZATION] ==
gpu::kGpuFeatureStatusEnabled;
}
bool GpuDataManagerImplPrivate::IsWebGLEnabled() const {
return use_swiftshader_ ||
!blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL);
}
bool GpuDataManagerImplPrivate::IsWebGL2Enabled() const {
return /*use_swiftshader_ ||*/ // Uncomment to enable WebGL 2 with SwiftShader
!blacklisted_features_.count(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL2);
} }
size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const {
...@@ -455,6 +441,7 @@ bool GpuDataManagerImplPrivate::IsGpuFeatureInfoAvailable() const { ...@@ -455,6 +441,7 @@ bool GpuDataManagerImplPrivate::IsGpuFeatureInfoAvailable() const {
gpu::GpuFeatureStatus GpuDataManagerImplPrivate::GetFeatureStatus( gpu::GpuFeatureStatus GpuDataManagerImplPrivate::GetFeatureStatus(
gpu::GpuFeatureType feature) const { gpu::GpuFeatureType feature) const {
DCHECK(feature >= 0 && feature < gpu::NUMBER_OF_GPU_FEATURE_TYPES); DCHECK(feature >= 0 && feature < gpu::NUMBER_OF_GPU_FEATURE_TYPES);
DCHECK(gpu_feature_info_.IsValid());
return gpu_feature_info_.status_values[feature]; return gpu_feature_info_.status_values[feature];
} }
...@@ -677,8 +664,13 @@ void GpuDataManagerImplPrivate::AppendRendererCommandLine( ...@@ -677,8 +664,13 @@ void GpuDataManagerImplPrivate::AppendRendererCommandLine(
base::CommandLine* command_line) const { base::CommandLine* command_line) const {
DCHECK(command_line); DCHECK(command_line);
if (ShouldDisableAcceleratedVideoDecode(command_line)) #if defined(OS_ANDROID)
// TODO(zmo): Move this to renderer side checking with GPU channel.
if (blacklisted_features_.count(
gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) == 1) {
command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode); command_line->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
}
#endif
} }
void GpuDataManagerImplPrivate::AppendGpuCommandLine( void GpuDataManagerImplPrivate::AppendGpuCommandLine(
...@@ -696,14 +688,6 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine( ...@@ -696,14 +688,6 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
if (use_swiftshader_) { if (use_swiftshader_) {
command_line->AppendSwitchASCII( command_line->AppendSwitchASCII(
switches::kUseGL, gl::kGLImplementationSwiftShaderForWebGLName); switches::kUseGL, gl::kGLImplementationSwiftShaderForWebGLName);
} else if ((IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL) ||
IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING) ||
IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)) &&
(use_gl == "any")) {
command_line->AppendSwitchASCII(
switches::kUseGL,
gl::GetGLImplementationName(gl::GetSoftwareGLImplementation()));
} else if (!use_gl.empty()) { } else if (!use_gl.empty()) {
command_line->AppendSwitchASCII(switches::kUseGL, use_gl); command_line->AppendSwitchASCII(switches::kUseGL, use_gl);
} }
...@@ -911,19 +895,6 @@ bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id, ...@@ -911,19 +895,6 @@ bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id,
return true; return true;
} }
bool GpuDataManagerImplPrivate::ShouldDisableAcceleratedVideoDecode(
const base::CommandLine* command_line) const {
if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) {
// It was already disabled on the command line.
return false;
}
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE))
return true;
// Accelerated decode is never available with --disable-gpu.
return ShouldDisableHardwareAcceleration();
}
void GpuDataManagerImplPrivate::GetDisabledExtensions( void GpuDataManagerImplPrivate::GetDisabledExtensions(
std::string* disabled_extensions) const { std::string* disabled_extensions) const {
DCHECK(disabled_extensions); DCHECK(disabled_extensions);
......
...@@ -42,10 +42,6 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { ...@@ -42,10 +42,6 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
void InitializeForTesting(const gpu::GpuControlListData& gpu_blacklist_data, void InitializeForTesting(const gpu::GpuControlListData& gpu_blacklist_data,
const gpu::GPUInfo& gpu_info); const gpu::GPUInfo& gpu_info);
bool IsFeatureBlacklisted(int feature) const;
bool IsFeatureEnabled(int feature) const;
bool IsWebGLEnabled() const;
bool IsWebGL2Enabled() const;
gpu::GPUInfo GetGPUInfo() const; gpu::GPUInfo GetGPUInfo() const;
bool GpuAccessAllowed(std::string* reason) const; bool GpuAccessAllowed(std::string* reason) const;
void RequestCompleteGpuInfoIfNeeded(); void RequestCompleteGpuInfoIfNeeded();
...@@ -92,9 +88,6 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { ...@@ -92,9 +88,6 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
void HandleGpuSwitch(); void HandleGpuSwitch();
bool ShouldDisableAcceleratedVideoDecode(
const base::CommandLine* command_line) const;
void GetDisabledExtensions(std::string* disabled_extensions) const; void GetDisabledExtensions(std::string* disabled_extensions) const;
void BlockDomainFrom3DAPIs( void BlockDomainFrom3DAPIs(
......
...@@ -127,152 +127,6 @@ class GpuDataManagerImplPrivateTest : public testing::Test { ...@@ -127,152 +127,6 @@ class GpuDataManagerImplPrivateTest : public testing::Test {
// We use new method instead of GetInstance() method because we want // We use new method instead of GetInstance() method because we want
// each test to be independent of each other. // each test to be independent of each other.
TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklisting) {
// If a feature is allowed in preliminary step (browser side), but
// disabled when GPU process launches and collects full GPU info,
// it's too late to let renderer know, so we basically block all GPU
// access, to be on the safe side.
ScopedGpuDataManagerImplPrivate manager;
EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
std::string reason;
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
const gpu::GpuControlList::Entry kEntries[] = {
gpu::kGpuDataManagerTestingEntries
[gpu::kGpuDataManagerImplPrivateTest_GpuSideBlacklisting_0],
gpu::kGpuDataManagerTestingEntries
[gpu::kGpuDataManagerImplPrivateTest_GpuSideBlacklisting_1],
};
const gpu::GpuControlListData kData(2, kEntries);
gpu::GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x10de;
gpu_info.gpu.device_id = 0x0640;
manager->InitializeForTesting(kData, gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
if (manager->ShouldUseSwiftShader()) {
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
} else {
EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
}
EXPECT_TRUE(
manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
gpu_info.gl_vendor = "NVIDIA";
gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
manager->UpdateGpuInfo(gpu_info);
if (manager->ShouldUseSwiftShader()) {
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL2));
} else {
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
EXPECT_FALSE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL2));
}
EXPECT_TRUE(
manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
}
TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) {
// If a feature is allowed in preliminary step (browser side), but
// disabled when GPU process launches and collects full GPU info,
// it's too late to let renderer know, so we basically block all GPU
// access, to be on the safe side.
ScopedGpuDataManagerImplPrivate manager;
EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
std::string reason;
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
const gpu::GpuControlList::Entry kEntries[] = {
gpu::kGpuDataManagerTestingEntries
[gpu::kGpuDataManagerImplPrivateTest_GpuSideBlacklistingWebGL_0],
gpu::kGpuDataManagerTestingEntries
[gpu::kGpuDataManagerImplPrivateTest_GpuSideBlacklistingWebGL_1],
};
const gpu::GpuControlListData kData(2, kEntries);
gpu::GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x10de;
gpu_info.gpu.device_id = 0x0640;
manager->InitializeForTesting(kData, gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
if (manager->ShouldUseSwiftShader()) {
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
} else {
EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
}
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
gpu_info.gl_vendor = "NVIDIA";
gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
manager->UpdateGpuInfo(gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
if (manager->ShouldUseSwiftShader()) {
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
} else {
EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount());
}
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
EXPECT_TRUE(
manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
EXPECT_TRUE(
manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL2));
}
TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) {
ScopedGpuDataManagerImplPrivate manager;
EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
EXPECT_TRUE(manager->GpuAccessAllowed(nullptr));
const gpu::GpuControlList::Entry kEntries[] = {
gpu::kGpuDataManagerTestingEntries
[gpu::kGpuDataManagerImplPrivateTest_GpuSideException],
};
const gpu::GpuControlListData kData(1, kEntries);
gpu::GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x10de;
gpu_info.gpu.device_id = 0x0640;
manager->InitializeForTesting(kData, gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed(nullptr));
EXPECT_EQ(manager->ShouldUseSwiftShader()
? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES)
: 1u,
manager->GetBlacklistedFeatureCount());
// Now assume gpu process launches and full GPU info is collected.
gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
manager->UpdateGpuInfo(gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed(nullptr));
// Since SwiftShader was enabled by first gpu_info, UpdateGpuInfo
// should have failed and SwiftShader should still be active
EXPECT_EQ(manager->ShouldUseSwiftShader()
? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES)
: 0u,
manager->GetBlacklistedFeatureCount());
}
TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) { TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) {
ScopedGpuDataManagerImplPrivate manager; ScopedGpuDataManagerImplPrivate manager;
const gpu::GpuControlListData kData; const gpu::GpuControlListData kData;
...@@ -294,49 +148,6 @@ TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) { ...@@ -294,49 +148,6 @@ TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) {
manager->GetBlacklistedFeatureCount()); manager->GetBlacklistedFeatureCount());
} }
TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) {
// Blacklist, then register SwiftShader.
ScopedGpuDataManagerImplPrivate manager;
const gpu::GpuControlListData kData;
manager->InitializeForTesting(kData, gpu::GPUInfo());
EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
EXPECT_TRUE(manager->GpuAccessAllowed(nullptr));
EXPECT_FALSE(manager->ShouldUseSwiftShader());
manager->DisableHardwareAcceleration();
EXPECT_EQ(manager->ShouldUseSwiftShader(),
manager->GpuAccessAllowed(nullptr));
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
EXPECT_TRUE(
manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL2));
}
TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) {
// Register SwiftShader, then blacklist.
ScopedGpuDataManagerImplPrivate manager;
const gpu::GpuControlListData kData;
manager->InitializeForTesting(kData, gpu::GPUInfo());
EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
EXPECT_TRUE(manager->GpuAccessAllowed(nullptr));
EXPECT_FALSE(manager->ShouldUseSwiftShader());
manager->DisableHardwareAcceleration();
if (manager->ShouldUseSwiftShader()) {
EXPECT_TRUE(manager->GpuAccessAllowed(nullptr));
} else {
EXPECT_FALSE(manager->GpuAccessAllowed(nullptr));
}
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
EXPECT_TRUE(
manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL2));
}
TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) { TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) {
ScopedGpuDataManagerImpl manager; ScopedGpuDataManagerImpl manager;
...@@ -358,45 +169,6 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) { ...@@ -358,45 +169,6 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) {
EXPECT_TRUE(observer.gpu_info_updated()); EXPECT_TRUE(observer.gpu_info_updated());
} }
TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) {
ScopedGpuDataManagerImpl manager;
const gpu::GpuControlListData kData;
manager->InitializeForTesting(kData, gpu::GPUInfo());
manager->DisableHardwareAcceleration();
if (manager->ShouldUseSwiftShader()) {
EXPECT_TRUE(manager->GpuAccessAllowed(nullptr));
} else {
EXPECT_FALSE(manager->GpuAccessAllowed(nullptr));
}
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
TestObserver observer;
manager->AddObserver(&observer);
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
EXPECT_FALSE(observer.gpu_info_updated());
gpu::GPUInfo gpu_info;
manager->UpdateGpuInfo(gpu_info);
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
if (manager->ShouldUseSwiftShader()) {
// Once SwiftShader is enabled, the gpu info can no longer be updated
EXPECT_FALSE(observer.gpu_info_updated());
} else {
EXPECT_TRUE(observer.gpu_info_updated());
}
}
base::Time GpuDataManagerImplPrivateTest::JustBeforeExpiration( base::Time GpuDataManagerImplPrivateTest::JustBeforeExpiration(
const GpuDataManagerImplPrivate* manager) { const GpuDataManagerImplPrivate* manager) {
return GetTimeForTesting() + base::TimeDelta::FromMilliseconds( return GetTimeForTesting() + base::TimeDelta::FromMilliseconds(
......
...@@ -6,22 +6,11 @@ ...@@ -6,22 +6,11 @@
#include "base/logging.h" #include "base/logging.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_data_manager.h"
namespace content { namespace content {
namespace {
// A false return value is always valid, but a true one is only valid if full
// GPU info has been collected in a GPU process.
bool IsFeatureAllowed(GpuDataManager* manager, gpu::GpuFeatureType feature) {
return (manager->GpuAccessAllowed(nullptr) &&
!manager->IsFeatureBlacklisted(feature));
}
} // namespace
// static // static
scoped_refptr<GpuFeatureChecker> GpuFeatureChecker::Create( scoped_refptr<GpuFeatureChecker> GpuFeatureChecker::Create(
gpu::GpuFeatureType feature, gpu::GpuFeatureType feature,
...@@ -37,42 +26,21 @@ GpuFeatureCheckerImpl::~GpuFeatureCheckerImpl() {} ...@@ -37,42 +26,21 @@ GpuFeatureCheckerImpl::~GpuFeatureCheckerImpl() {}
void GpuFeatureCheckerImpl::CheckGpuFeatureAvailability() { void GpuFeatureCheckerImpl::CheckGpuFeatureAvailability() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
AddRef(); // Matched with a Release in OnGpuInfoUpdate.
bool finalized = true; GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance();
#if defined(OS_LINUX) manager->AddObserver(this);
// On Windows and Mac, so far we can always make the final WebGL blacklisting OnGpuInfoUpdate();
// decision based on partial GPU info; on Linux, we need to launch the GPU
// process to collect full GPU info and make the final decision.
finalized = false;
#endif
GpuDataManager* manager = GpuDataManager::GetInstance();
if (manager->IsEssentialGpuInfoAvailable())
finalized = true;
bool feature_allowed = IsFeatureAllowed(manager, feature_);
if (!feature_allowed)
finalized = true;
if (finalized) {
callback_.Run(feature_allowed);
} else {
// Matched with a Release in OnGpuInfoUpdate.
AddRef();
manager->AddObserver(this);
manager->RequestCompleteGpuInfoIfNeeded();
}
} }
void GpuFeatureCheckerImpl::OnGpuInfoUpdate() { void GpuFeatureCheckerImpl::OnGpuInfoUpdate() {
GpuDataManager* manager = GpuDataManager::GetInstance(); GpuDataManagerImpl* manager = GpuDataManagerImpl::GetInstance();
manager->RemoveObserver(this); if (manager->IsGpuFeatureInfoAvailable()) {
bool feature_allowed = IsFeatureAllowed(manager, feature_); manager->RemoveObserver(this);
callback_.Run(feature_allowed); bool feature_allowed =
manager->GetFeatureStatus(feature_) == gpu::kGpuFeatureStatusEnabled;
// Matches the AddRef in CheckGpuFeatureAvailability(). callback_.Run(feature_allowed);
Release(); Release(); // Matches the AddRef in CheckGpuFeatureAvailability().
}
} }
} // namespace content } // namespace content
...@@ -32,11 +32,6 @@ class GpuDataManager { ...@@ -32,11 +32,6 @@ class GpuDataManager {
// This is only called by extensions testing. // This is only called by extensions testing.
virtual void BlacklistWebGLForTesting() = 0; virtual void BlacklistWebGLForTesting() = 0;
virtual bool IsFeatureBlacklisted(int feature) const = 0;
virtual bool IsFeatureEnabled(int feature) const = 0;
virtual bool IsWebGLEnabled() const = 0;
virtual bool IsWebGL2Enabled() const = 0;
virtual gpu::GPUInfo GetGPUInfo() const = 0; virtual gpu::GPUInfo GetGPUInfo() const = 0;
// This indicator might change because we could collect more GPU info or // This indicator might change because we could collect more GPU info or
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment