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( ...@@ -1986,13 +1986,7 @@ void RenderThreadImpl::RecordPurgeAndSuspendMemoryGrowthMetrics(
} }
void RenderThreadImpl::CompositingModeFallbackToSoftware() { void RenderThreadImpl::CompositingModeFallbackToSoftware() {
if (gpu_channel_) { gpu_->LoseChannel();
// TODO(danakj): Tell all clients of the compositor. We should send a more
// scoped message than this.
gpu_channel_->DestroyChannel();
gpu_channel_ = nullptr;
}
is_gpu_compositing_disabled_ = true; is_gpu_compositing_disabled_ = true;
} }
...@@ -2000,21 +1994,11 @@ scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync( ...@@ -2000,21 +1994,11 @@ scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync(
bool* connection_error) { bool* connection_error) {
TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync");
if (gpu_channel_) { scoped_refptr<gpu::GpuChannelHost> gpu_channel =
// Do nothing if we already have a GPU channel or are already gpu_->EstablishGpuChannelSync(connection_error);
// establishing one. if (gpu_channel)
if (!gpu_channel_->IsLost()) GetContentClient()->SetGpuInfo(gpu_channel->gpu_info());
return gpu_channel_; 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_;
} }
void RenderThreadImpl::RequestNewLayerTreeFrameSink( void RenderThreadImpl::RequestNewLayerTreeFrameSink(
...@@ -2234,11 +2218,7 @@ mojom::RenderMessageFilter* RenderThreadImpl::render_message_filter() { ...@@ -2234,11 +2218,7 @@ mojom::RenderMessageFilter* RenderThreadImpl::render_message_filter() {
} }
gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() { gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() {
if (!gpu_channel_) return gpu_->GetGpuChannel().get();
return nullptr;
if (gpu_channel_->IsLost())
return nullptr;
return gpu_channel_.get();
} }
void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) { void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) {
......
...@@ -729,9 +729,6 @@ class CONTENT_EXPORT RenderThreadImpl ...@@ -729,9 +729,6 @@ class CONTENT_EXPORT RenderThreadImpl
// software-based. // software-based.
bool is_gpu_compositing_disabled_ = false; 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. // The message loop of the renderer main thread.
// This message loop should be destructed before the RenderThreadImpl // This message loop should be destructed before the RenderThreadImpl
// shuts down Blink. // shuts down Blink.
......
...@@ -262,12 +262,18 @@ gpu::GpuMemoryBufferManager* Gpu::GetGpuMemoryBufferManager() { ...@@ -262,12 +262,18 @@ gpu::GpuMemoryBufferManager* Gpu::GetGpuMemoryBufferManager() {
return gpu_memory_buffer_manager_.get(); return gpu_memory_buffer_manager_.get();
} }
scoped_refptr<gpu::GpuChannelHost> Gpu::GetGpuChannel() { void Gpu::LoseChannel() {
DCHECK(main_task_runner_->BelongsToCurrentThread()); DCHECK(main_task_runner_->BelongsToCurrentThread());
if (gpu_channel_ && gpu_channel_->IsLost()) { if (gpu_channel_) {
gpu_channel_->DestroyChannel(); gpu_channel_->DestroyChannel();
gpu_channel_ = nullptr; 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_; return gpu_channel_;
} }
......
...@@ -53,6 +53,9 @@ class Gpu : public gpu::GpuChannelHostFactory, ...@@ -53,6 +53,9 @@ class Gpu : public gpu::GpuChannelHostFactory,
bool* connection_error) override; bool* connection_error) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
void LoseChannel();
scoped_refptr<gpu::GpuChannelHost> GetGpuChannel();
private: private:
friend class GpuTest; friend class GpuTest;
...@@ -62,8 +65,6 @@ class Gpu : public gpu::GpuChannelHostFactory, ...@@ -62,8 +65,6 @@ class Gpu : public gpu::GpuChannelHostFactory,
Gpu(GpuPtrFactory factory, Gpu(GpuPtrFactory factory,
scoped_refptr<base::SingleThreadTaskRunner> task_runner); scoped_refptr<base::SingleThreadTaskRunner> task_runner);
scoped_refptr<gpu::GpuChannelHost> GetGpuChannel();
// Sends a request to establish a gpu channel. If a request is currently // Sends a request to establish a gpu channel. If a request is currently
// pending this will do nothing. // pending this will do nothing.
void SendEstablishGpuChannelRequest(); 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