Skip to content

Commit

Permalink
Some cleanup to GpuHost implementation
Browse files Browse the repository at this point in the history
This a a follow-up to introducing viz::GpuHostImpl (crrev/c/1180658).
This includes:
 - Removing an expired CHECK;
 - Limiting GpuHost::SetChildSurface() to Windows;
 - Removing unused GpuProcessHost::OnDestroyingVideoSurfaceAck().

BUG=709332

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: Ida7488d887ff5d511b53e8e6997835486572b648
Reviewed-on: https://chromium-review.googlesource.com/1195545
Commit-Queue: Mohsen Izadi <mohsen@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589381}
  • Loading branch information
Mohsen Izadi authored and Commit Bot committed Sep 7, 2018
1 parent b62781d commit 50c2805
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 36 deletions.
9 changes: 2 additions & 7 deletions components/viz/host/gpu_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,6 @@ std::string GpuHostImpl::GetShaderPrefixKey() {
#if defined(OS_ANDROID)
std::string build_fp =
base::android::BuildInfo::GetInstance()->android_build_fp();
// TODO(ericrk): Remove this after it's up for a few days.
// https://crbug.com/699122.
CHECK(!build_fp.empty());
shader_prefix_key_ += "-" + build_fp;
#endif
}
Expand Down Expand Up @@ -529,9 +526,9 @@ void GpuHostImpl::DisableGpuCompositing() {
delegate_->DisableGpuCompositing();
}

#if defined(OS_WIN)
void GpuHostImpl::SetChildSurface(gpu::SurfaceHandle parent,
gpu::SurfaceHandle child) {
#if defined(OS_WIN)
constexpr char kBadMessageError[] = "Bad parenting request from gpu process.";
if (!params_.in_process) {
DWORD parent_process_id = 0;
Expand All @@ -555,10 +552,8 @@ void GpuHostImpl::SetChildSurface(gpu::SurfaceHandle parent,
child)) {
LOG(ERROR) << kBadMessageError;
}
#else
NOTREACHED();
#endif
}
#endif // defined(OS_WIN)

void GpuHostImpl::StoreShaderToDisk(int32_t client_id,
const std::string& key,
Expand Down
6 changes: 4 additions & 2 deletions components/viz/host/gpu_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost {
bool in_process = false;

// Whether caching GPU shader on disk is disabled or not.
bool disable_gpu_shader_disk_cache;
bool disable_gpu_shader_disk_cache = false;

// A string representing the product name and version; used to build a
// prefix for shader keys.
std::string product;

// Number of frames to CompositorFrame activation deadline.
base::Optional<uint32_t> deadline_to_synchronize_surfaces = base::nullopt;
base::Optional<uint32_t> deadline_to_synchronize_surfaces;

// Task runner corresponding to the main thread.
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner;
Expand Down Expand Up @@ -203,8 +203,10 @@ class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost {
gpu::error::ContextLostReason reason,
const GURL& active_url) override;
void DisableGpuCompositing() override;
#if defined(OS_WIN)
void SetChildSurface(gpu::SurfaceHandle parent,
gpu::SurfaceHandle child) override;
#endif
void StoreShaderToDisk(int32_t client_id,
const std::string& key,
const std::string& shader) override;
Expand Down
17 changes: 3 additions & 14 deletions content/browser/gpu/gpu_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -872,13 +872,6 @@ void GpuProcessHost::OnChannelConnected(int32_t peer_pid) {
}
}

#if defined(OS_ANDROID)
void GpuProcessHost::OnDestroyingVideoSurfaceAck() {
TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyingVideoSurfaceAck");
if (!send_destroying_video_surface_done_cb_.is_null())
base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run();
}
#endif

void GpuProcessHost::OnProcessLaunched() {
UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime",
Expand Down Expand Up @@ -952,14 +945,13 @@ void GpuProcessHost::DidCreateContextSuccessfully() {
#endif
}

void GpuProcessHost::BlockDomainFrom3DAPIs(const GURL& url,
Delegate::DomainGuilt guilt) {
void GpuProcessHost::BlockDomainFrom3DAPIs(const GURL& url, DomainGuilt guilt) {
GpuDataManagerImpl::DomainGuilt gpu_data_manager_guilt;
switch (guilt) {
case Delegate::DomainGuilt::kKnown:
case DomainGuilt::kKnown:
gpu_data_manager_guilt = GpuDataManagerImpl::DOMAIN_GUILT_KNOWN;
break;
case Delegate::DomainGuilt::kUnknown:
case DomainGuilt::kUnknown:
gpu_data_manager_guilt = GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN;
}
GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(
Expand Down Expand Up @@ -1118,9 +1110,6 @@ void GpuProcessHost::SendOutstandingReplies() {

if (gpu_host_)
gpu_host_->SendOutstandingReplies();

if (!send_destroying_video_surface_done_cb_.is_null())
base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run();
}

void GpuProcessHost::RecordProcessCrash() {
Expand Down
11 changes: 2 additions & 9 deletions content/browser/gpu/gpu_process_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
gpu_feature_info_for_hardware_gpu) override;
void DidFailInitialize() override;
void DidCreateContextSuccessfully() override;
void BlockDomainFrom3DAPIs(const GURL& url,
Delegate::DomainGuilt guilt) override;
void BlockDomainFrom3DAPIs(const GURL& url, DomainGuilt guilt) override;
void DisableGpuCompositing() override;
bool GpuAccessAllowed() const override;
gpu::ShaderCacheFactory* GetShaderCacheFactory() override;
Expand All @@ -162,10 +161,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
void SendGpuProcessMessage(IPC::Message* message) override;
#endif

// Message handlers.
#if defined(OS_ANDROID)
void OnDestroyingVideoSurfaceAck();
#endif
// Message handlers.
void OnFieldTrialActivated(const std::string& trial_name);

bool LaunchGpuProcess();
Expand All @@ -183,9 +179,6 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// GPU process id in case GPU is not in-process.
base::ProcessId process_id_ = base::kNullProcessId;

// A callback to signal the completion of a SendDestroyingVideoSurface call.
base::Closure send_destroying_video_surface_done_cb_;

// Qeueud messages to send when the process launches.
base::queue<IPC::Message*> queued_messages_;

Expand Down
2 changes: 2 additions & 0 deletions services/viz/privileged/interfaces/gl/gpu_host.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ interface GpuHost {
// track of this decision in case the GPU process crashes.
DisableGpuCompositing();

[EnableIf=is_win]
SetChildSurface(gpu.mojom.SurfaceHandle parent,
gpu.mojom.SurfaceHandle child);

StoreShaderToDisk(int32 client_id, string key, string shader);

RecordLogMessage(int32 severity, string header, string message);
Expand Down
6 changes: 2 additions & 4 deletions services/ws/gpu_host/gpu_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ void DefaultGpuHost::DidLoseContext(bool offscreen,

void DefaultGpuHost::DisableGpuCompositing() {}

#if defined(OS_WIN)
void DefaultGpuHost::SetChildSurface(gpu::SurfaceHandle parent,
gpu::SurfaceHandle child) {
#if defined(OS_WIN)
// Verify that |parent| was created by the window server.
DWORD process_id = 0;
DWORD thread_id = GetWindowThreadProcessId(parent, &process_id);
Expand All @@ -210,10 +210,8 @@ void DefaultGpuHost::SetChildSurface(gpu::SurfaceHandle parent,
child)) {
OnBadMessageFromGpu();
}
#else
NOTREACHED();
#endif
}
#endif // defined(OS_WIN)

void DefaultGpuHost::StoreShaderToDisk(int32_t client_id,
const std::string& key,
Expand Down
2 changes: 2 additions & 0 deletions services/ws/gpu_host/gpu_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ class DefaultGpuHost : public GpuHost, public viz::mojom::GpuHost {
gpu::error::ContextLostReason reason,
const GURL& active_url) override;
void DisableGpuCompositing() override;
#if defined(OS_WIN)
void SetChildSurface(gpu::SurfaceHandle parent,
gpu::SurfaceHandle child) override;
#endif
void StoreShaderToDisk(int32_t client_id,
const std::string& key,
const std::string& shader) override;
Expand Down

0 comments on commit 50c2805

Please sign in to comment.