Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1725)

Unified Diff: content/common/gpu/gpu_channel_manager.cc

Issue 800103005: Release GPU resources only after renderer GPU channels are closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/gpu_channel_manager.cc
diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc
index 131c7b52b3c6b0371e6e1a67a5efc23892a8bfb8..dda8957ade25f453782f67eb4dc6f7a5d615d9ab 100644
--- a/content/common/gpu/gpu_channel_manager.cc
+++ b/content/common/gpu/gpu_channel_manager.cc
@@ -101,6 +101,7 @@ GpuChannelManager::GpuChannelManager(MessageRouter* router,
channel_(channel),
filter_(
new GpuChannelManagerMessageFilter(gpu_memory_buffer_factory_.get())),
+ relinquish_resources_pending_(false),
weak_factory_(this) {
DCHECK(router_);
DCHECK(io_message_loop);
@@ -137,6 +138,7 @@ GpuChannelManager::shader_translator_cache() {
void GpuChannelManager::RemoveChannel(int client_id) {
Send(new GpuHostMsg_DestroyChannel(client_id));
gpu_channels_.erase(client_id);
+ CheckRelinquishGpuResources();
}
int GpuChannelManager::GenerateRouteID() {
@@ -224,6 +226,7 @@ void GpuChannelManager::OnCloseChannel(
iter != gpu_channels_.end(); ++iter) {
if (iter->second->GetChannelName() == channel_handle.name) {
gpu_channels_.erase(iter);
+ CheckRelinquishGpuResources();
return;
}
}
@@ -327,6 +330,7 @@ void GpuChannelManager::LoseAllContexts() {
void GpuChannelManager::OnLoseAllContexts() {
gpu_channels_.clear();
+ CheckRelinquishGpuResources();
}
gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
@@ -338,19 +342,27 @@ gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
}
void GpuChannelManager::OnRelinquishResources() {
- if (default_offscreen_surface_.get()) {
- default_offscreen_surface_->DestroyAndTerminateDisplay();
- default_offscreen_surface_ = nullptr;
- }
+ relinquish_resources_pending_ = true;
+ CheckRelinquishGpuResources();
+}
+
+void GpuChannelManager::CheckRelinquishGpuResources() {
+ if (relinquish_resources_pending_ && gpu_channels_.size() <= 1) {
+ relinquish_resources_pending_ = false;
+ if (default_offscreen_surface_.get()) {
+ default_offscreen_surface_->DestroyAndTerminateDisplay();
+ default_offscreen_surface_ = NULL;
+ }
#if defined(USE_OZONE)
- ui::OzonePlatform::GetInstance()
- ->GetGpuPlatformSupport()
- ->RelinquishGpuResources(
- base::Bind(&GpuChannelManager::OnResourcesRelinquished,
- weak_factory_.GetWeakPtr()));
+ ui::OzonePlatform::GetInstance()
+ ->GetGpuPlatformSupport()
+ ->RelinquishGpuResources(
+ base::Bind(&GpuChannelManager::OnResourcesRelinquished,
+ weak_factory_.GetWeakPtr()));
#else
- OnResourcesRelinquished();
+ OnResourcesRelinquished();
#endif
+ }
}
void GpuChannelManager::OnResourcesRelinquished() {
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698