Commit 7fcbc78b authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Move RenderThreadImpl's GpuChannelHost logic to ui::Gpu

RenderThreadImpl's logic has a fair amount of duplication with ui::Gpu.
In particular, RenderThreadImpl shouldn't need to cache the
GpuChannelHost, since it is available directly from the ui::Gpu.

Bug: 566273
Change-Id: I6cfb9f28b46bce64c4f83aa5f2fcb4263c171018
Reviewed-on: https://chromium-review.googlesource.com/767594Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516328}
parent 9e463e17
......@@ -1986,13 +1986,7 @@ void RenderThreadImpl::RecordPurgeAndSuspendMemoryGrowthMetrics(
}
void RenderThreadImpl::CompositingModeFallbackToSoftware() {
if (gpu_channel_) {
// TODO(danakj): Tell all clients of the compositor. We should send a more
// scoped message than this.
gpu_channel_->DestroyChannel();
gpu_channel_ = nullptr;
}
gpu_->LoseChannel();
is_gpu_compositing_disabled_ = true;
}
......@@ -2000,21 +1994,11 @@ scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync(
bool* connection_error) {
TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync");
if (gpu_channel_) {
// Do nothing if we already have a GPU channel or are already
// establishing one.
if (!gpu_channel_->IsLost())
return gpu_channel_;
// Recreate the channel if it has been lost.
gpu_channel_->DestroyChannel();
gpu_channel_ = nullptr;
}
gpu_channel_ = gpu_->EstablishGpuChannelSync(connection_error);
if (gpu_channel_)
GetContentClient()->SetGpuInfo(gpu_channel_->gpu_info());
return gpu_channel_;
scoped_refptr<gpu::GpuChannelHost> gpu_channel =
gpu_->EstablishGpuChannelSync(connection_error);
if (gpu_channel)
GetContentClient()->SetGpuInfo(gpu_channel->gpu_info());
return gpu_channel;
}
void RenderThreadImpl::RequestNewLayerTreeFrameSink(
......@@ -2234,11 +2218,7 @@ mojom::RenderMessageFilter* RenderThreadImpl::render_message_filter() {
}
gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() {
if (!gpu_channel_)
return nullptr;
if (gpu_channel_->IsLost())
return nullptr;
return gpu_channel_.get();
return gpu_->GetGpuChannel().get();
}
void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) {
......
......@@ -729,9 +729,6 @@ class CONTENT_EXPORT RenderThreadImpl
// software-based.
bool is_gpu_compositing_disabled_ = false;
// The channel from the renderer process to the GPU process.
scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
// The message loop of the renderer main thread.
// This message loop should be destructed before the RenderThreadImpl
// shuts down Blink.
......
......@@ -262,12 +262,18 @@ gpu::GpuMemoryBufferManager* Gpu::GetGpuMemoryBufferManager() {
return gpu_memory_buffer_manager_.get();
}
scoped_refptr<gpu::GpuChannelHost> Gpu::GetGpuChannel() {
void Gpu::LoseChannel() {
DCHECK(main_task_runner_->BelongsToCurrentThread());
if (gpu_channel_ && gpu_channel_->IsLost()) {
if (gpu_channel_) {
gpu_channel_->DestroyChannel();
gpu_channel_ = nullptr;
}
}
scoped_refptr<gpu::GpuChannelHost> Gpu::GetGpuChannel() {
DCHECK(main_task_runner_->BelongsToCurrentThread());
if (gpu_channel_ && gpu_channel_->IsLost())
gpu_channel_ = nullptr;
return gpu_channel_;
}
......
......@@ -53,6 +53,9 @@ class Gpu : public gpu::GpuChannelHostFactory,
bool* connection_error) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
void LoseChannel();
scoped_refptr<gpu::GpuChannelHost> GetGpuChannel();
private:
friend class GpuTest;
......@@ -62,8 +65,6 @@ class Gpu : public gpu::GpuChannelHostFactory,
Gpu(GpuPtrFactory factory,
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
scoped_refptr<gpu::GpuChannelHost> GetGpuChannel();
// Sends a request to establish a gpu channel. If a request is currently
// pending this will do nothing.
void SendEstablishGpuChannelRequest();
......
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