Skip to content

Commit

Permalink
Collect GL strings on Cast through CastContentGpuClient.
Browse files Browse the repository at this point in the history
BUG=744658
TEST=bots
R=halliwell@chromium.org,piman@chromium.org,kbr@chromium.org

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ib8e4e5e874025d78c7cdc2cc3b7af6c9e20ca9c4
Reviewed-on: https://chromium-review.googlesource.com/874612
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Stephen Lanham <slan@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Luke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530612}
  • Loading branch information
zhenyao authored and Commit Bot committed Jan 19, 2018
1 parent b57fbfc commit c76e903
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 296 deletions.
5 changes: 2 additions & 3 deletions chromecast/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,12 @@ cast_test_group("cast_tests") {
if (target_os == "linux" && !is_cast_desktop_build) {
# DesktopCaptureDeviceTest.*: No capture device on Eureka
# Disable PepperGamepadHostTest.WaitForReply (pepper not supported on Eureka)
# Disable GpuDataManagerImplPrivateTest.SetGLStrings and
# RenderWidgetHostTest.Background because we disable the blacklist to enable WebGL (b/16142554)
# Disable RenderWidgetHostTest.Background because we disable the
# blacklist to enable WebGL (b/16142554)
gtest_excludes += [
"DOMStorageDatabaseTest.TestCanOpenAndReadWebCoreDatabase",
"DesktopCaptureDeviceTest.Capture",
"GamepadProviderTest.PollingAccess",
"GpuDataManagerImplPrivateTest.SetGLStrings",
"PepperGamepadHostTest.WaitForReply",
"RenderWidgetHostTest.Background",
]
Expand Down
1 change: 1 addition & 0 deletions chromecast/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cast_source_set("app") {
"//chromecast/base",
"//chromecast/browser",
"//chromecast/common",
"//chromecast/gpu",
"//chromecast/renderer",
"//chromecast/utility",
"//components/crash/core/common:crash_key",
Expand Down
1 change: 1 addition & 0 deletions chromecast/app/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include_rules = [
"+chromecast/browser",
"+chromecast/common",
"+chromecast/crash",
"+chromecast/gpu",
"+chromecast/renderer",
"+chromecast/utility",
"+components/crash",
Expand Down
8 changes: 7 additions & 1 deletion chromecast/app/cast_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
#include "base/path_service.h"
#include "base/posix/global_descriptors.h"
#include "build/build_config.h"
#include "chromecast/chromecast_features.h"
#include "chromecast/base/cast_paths.h"
#include "chromecast/browser/cast_content_browser_client.h"
#include "chromecast/chromecast_features.h"
#include "chromecast/common/cast_resource_delegate.h"
#include "chromecast/common/global_descriptors.h"
#include "chromecast/gpu/cast_content_gpu_client.h"
#include "chromecast/renderer/cast_content_renderer_client.h"
#include "chromecast/utility/cast_content_utility_client.h"
#include "components/crash/content/app/crash_reporter_client.h"
Expand Down Expand Up @@ -234,6 +235,11 @@ content::ContentBrowserClient* CastMainDelegate::CreateContentBrowserClient() {
return browser_client_.get();
}

content::ContentGpuClient* CastMainDelegate::CreateContentGpuClient() {
gpu_client_ = CastContentGpuClient::Create();
return gpu_client_.get();
}

content::ContentRendererClient*
CastMainDelegate::CreateContentRendererClient() {
renderer_client_ = CastContentRendererClient::Create();
Expand Down
3 changes: 3 additions & 0 deletions chromecast/app/cast_main_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CastResourceDelegate;
namespace shell {

class CastContentBrowserClient;
class CastContentGpuClient;
class CastContentRendererClient;
class CastContentUtilityClient;

Expand All @@ -41,13 +42,15 @@ class CastMainDelegate : public content::ContentMainDelegate {
void ZygoteForked() override;
#endif // defined(OS_LINUX)
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentGpuClient* CreateContentGpuClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override;

private:
void InitializeResourceBundle();

std::unique_ptr<CastContentBrowserClient> browser_client_;
std::unique_ptr<CastContentGpuClient> gpu_client_;
std::unique_ptr<CastContentRendererClient> renderer_client_;
std::unique_ptr<CastContentUtilityClient> utility_client_;
std::unique_ptr<CastResourceDelegate> resource_delegate_;
Expand Down
18 changes: 3 additions & 15 deletions chromecast/browser/cast_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "chromecast/base/cast_constants.h"
#include "chromecast/base/cast_features.h"
#include "chromecast/base/cast_paths.h"
#include "chromecast/base/cast_sys_info_util.h"
#include "chromecast/base/chromecast_switches.h"
#include "chromecast/base/metrics/cast_metrics_helper.h"
#include "chromecast/base/metrics/grouped_histogram.h"
Expand All @@ -52,13 +51,11 @@
#include "chromecast/media/cma/backend/media_pipeline_backend_manager.h"
#include "chromecast/net/connectivity_checker.h"
#include "chromecast/public/cast_media_shlib.h"
#include "chromecast/public/cast_sys_info.h"
#include "chromecast/service/cast_service.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h"
#include "gpu/command_buffer/service/gpu_switches.h"
Expand Down Expand Up @@ -240,10 +237,9 @@ const DefaultCommandLineSwitch kDefaultSwitches[] = {
#endif
#endif
#endif // defined(OS_LINUX)
// Needed so that our call to GpuDataManager::SetGLStrings doesn't race
// against GPU process creation (which is otherwise triggered from
// BrowserThreadsStarted). The GPU process will be created as soon as a
// renderer needs it, which always happens after main loop starts.
// It's better to start GPU process on demand. For example, for TV platforms
// cast starts in background and can't render until TV switches to cast
// input.
{switches::kDisableGpuEarlyInit, ""},
// Enable navigator.connection API.
// TODO(derekjchow): Remove this switch when enabled by default.
Expand Down Expand Up @@ -420,14 +416,6 @@ int CastBrowserMainParts::PreCreateThreads() {
CHECK(PathService::Get(DIR_CAST_HOME, &home_dir));
if (!base::CreateDirectory(home_dir))
return 1;

// Set GL strings so GPU config code can make correct feature blacklisting/
// whitelisting decisions.
// Note: SetGLStrings can be called before GpuDataManager::Initialize.
std::unique_ptr<CastSysInfo> sys_info = CreateSysInfo();
content::GpuDataManager::GetInstance()->SetGLStrings(
sys_info->GetGlVendor(), sys_info->GetGlRenderer(),
sys_info->GetGlVersion());
#endif

scoped_refptr<PrefRegistrySimple> pref_registry(new PrefRegistrySimple());
Expand Down
21 changes: 21 additions & 0 deletions chromecast/gpu/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2018 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.

import("//chromecast/chromecast.gni")

cast_source_set("gpu") {
sources = [
"cast_content_gpu_client.cc",
"cast_content_gpu_client.h",
]

deps = [
"//base",
"//chromecast/base",
"//chromecast/base:cast_sys_info",
"//chromecast/public",
"//content/public/gpu",
"//gpu/config",
]
}
6 changes: 6 additions & 0 deletions chromecast/gpu/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include_rules = [
"+chromecast/base",
"+chromecast/public",
"+content/public/gpu",
"+gpu/config",
]
44 changes: 44 additions & 0 deletions chromecast/gpu/cast_content_gpu_client.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2018 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 "chromecast/gpu/cast_content_gpu_client.h"

#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "chromecast/base/cast_sys_info_util.h"
#include "chromecast/public/cast_sys_info.h"
#include "gpu/config/gpu_info.h"
#include "gpu/config/gpu_info_collector.h"

namespace chromecast {

namespace shell {

// static
std::unique_ptr<CastContentGpuClient> CastContentGpuClient::Create() {
return base::WrapUnique(new CastContentGpuClient());
}

CastContentGpuClient::CastContentGpuClient() = default;

CastContentGpuClient::~CastContentGpuClient() = default;

const gpu::GPUInfo* CastContentGpuClient::GetGPUInfo() {
#if defined(OS_ANDROID)
return nullptr;
#else
if (!gpu_info_) {
gpu_info_ = base::MakeUnique<gpu::GPUInfo>();
std::unique_ptr<CastSysInfo> sys_info = CreateSysInfo();
gpu_info_->gl_vendor = sys_info->GetGlVendor();
gpu_info_->gl_renderer = sys_info->GetGlRenderer();
gpu_info_->gl_version = sys_info->GetGlVersion();
gpu::CollectDriverInfoGL(gpu_info_.get());
}
return gpu_info_.get();
#endif // OS_ANDROID
}

} // namespace shell
} // namespace chromecast
42 changes: 42 additions & 0 deletions chromecast/gpu/cast_content_gpu_client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2018 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 CHROMECAST_GPU_CAST_CONTENT_GPU_CLIENT_H_
#define CHROMECAST_GPU_CAST_CONTENT_GPU_CLIENT_H_

#include <memory>

#include "base/macros.h"
#include "content/public/gpu/content_gpu_client.h"

namespace gpu {
struct GPUInfo;
}

namespace chromecast {

namespace shell {

class CastContentGpuClient : public content::ContentGpuClient {
public:
~CastContentGpuClient() override;

static std::unique_ptr<CastContentGpuClient> Create();

// ContentGpuClient:
const gpu::GPUInfo* GetGPUInfo() override;

protected:
CastContentGpuClient();

private:
std::unique_ptr<gpu::GPUInfo> gpu_info_;

DISALLOW_COPY_AND_ASSIGN(CastContentGpuClient);
};

} // namespace shell
} // namespace chromecast

#endif // CHROMECAST_GPU_CAST_CONTENT_GPU_CLIENT_H_
7 changes: 0 additions & 7 deletions content/browser/gpu/gpu_data_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ void GpuDataManagerImpl::UnblockDomainFrom3DAPIs(const GURL& url) {
private_->UnblockDomainFrom3DAPIs(url);
}

void GpuDataManagerImpl::SetGLStrings(const std::string& gl_vendor,
const std::string& gl_renderer,
const std::string& gl_version) {
base::AutoLock auto_lock(lock_);
private_->SetGLStrings(gl_vendor, gl_renderer, gl_version);
}

void GpuDataManagerImpl::DisableHardwareAcceleration() {
base::AutoLock auto_lock(lock_);
private_->DisableHardwareAcceleration();
Expand Down
3 changes: 0 additions & 3 deletions content/browser/gpu/gpu_data_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager {
void AddObserver(GpuDataManagerObserver* observer) override;
void RemoveObserver(GpuDataManagerObserver* observer) override;
void UnblockDomainFrom3DAPIs(const GURL& url) override;
void SetGLStrings(const std::string& gl_vendor,
const std::string& gl_renderer,
const std::string& gl_version) override;
void DisableHardwareAcceleration() override;
bool HardwareAccelerationEnabled() const override;
void GetDisabledExtensions(std::string* disabled_extensions) const override;
Expand Down
32 changes: 0 additions & 32 deletions content/browser/gpu/gpu_data_manager_impl_private.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,38 +453,6 @@ void GpuDataManagerImplPrivate::UnblockDomainFrom3DAPIs(const GURL& url) {
timestamps_of_gpu_resets_.clear();
}

void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor,
const std::string& gl_renderer,
const std::string& gl_version) {
if (gl_vendor.empty() && gl_renderer.empty() && gl_version.empty())
return;

if (!is_initialized_) {
post_init_tasks_.push_back(
base::Bind(&GpuDataManagerImplPrivate::SetGLStrings,
base::Unretained(this), gl_vendor, gl_renderer, gl_version));
return;
}

// If GPUInfo already got GL strings, do nothing. This is for the rare
// situation where GPU process collected GL strings before this call.
if (!gpu_info_.gl_vendor.empty() ||
!gpu_info_.gl_renderer.empty() ||
!gpu_info_.gl_version.empty())
return;

gpu::GPUInfo gpu_info = gpu_info_;

gpu_info.gl_vendor = gl_vendor;
gpu_info.gl_renderer = gl_renderer;
gpu_info.gl_version = gl_version;

gpu::IdentifyActiveGPU(&gpu_info);
gpu::CollectDriverInfoGL(&gpu_info);

UpdateGpuInfo(gpu_info);
}

void GpuDataManagerImplPrivate::Initialize() {
TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize");
if (finalized_) {
Expand Down
3 changes: 0 additions & 3 deletions content/browser/gpu/gpu_data_manager_impl_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
void AddObserver(GpuDataManagerObserver* observer);
void RemoveObserver(GpuDataManagerObserver* observer);
void UnblockDomainFrom3DAPIs(const GURL& url);
void SetGLStrings(const std::string& gl_vendor,
const std::string& gl_renderer,
const std::string& gl_version);
void DisableHardwareAcceleration();
bool HardwareAccelerationEnabled() const;
void DisableSwiftShader();
Expand Down
47 changes: 2 additions & 45 deletions content/browser/gpu/gpu_data_manager_testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,56 +47,13 @@
},
{
"id": 6,
"description": "GpuDataManagerImplPrivateTest.SetGLStrings",
"vendor_id": "0x8086",
"exceptions": [
{
"device_id": ["0x0042"],
"driver_version": {
"op": ">=",
"value": "8.0.2"
}
}
],
"features": [
"accelerated_webgl"
]
},
{
"id": 7,
"description": "GpuDataManagerImplPrivateTest.SetGLStringsNoEffects",
"vendor_id": "0x8086",
"exceptions": [
{
"device_id": ["0x0042"],
"driver_version": {
"op": ">=",
"value": "8.0.2"
}
}
],
"features": [
"accelerated_webgl"
]
},
{
"id" : 8,
"description": "GpuDataManagerImplPrivateTest.SetGLStringsDefered",
"vendor_id" : "0x8086",
"device_id" : ["0x0042"],
"driver_vendor" : "Mesa",
"driver_version" : {"op" : ">=", "value" : "8.0.0"},
"features" : ["accelerated_webgl"]
},
{
"id": 9,
"description": "GpuDataManagerImplPrivateTest.BlacklistAllFeatures",
"description": "GpuDataManagerImplPrivateTest.BlacklistAllFeatures",
"features": [
"all"
]
},
{
"id": 10,
"id": 7,
"description": "GpuDataManagerImplPrivateTest.UpdateActiveGpu",
"vendor_id": "0x8086",
"multi_gpu_category": "active",
Expand Down
Loading

0 comments on commit c76e903

Please sign in to comment.