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

Unified Diff: cc/resources/resource_provider.cc

Issue 1016733002: cc: Free gpu resources when we are invisible or TM is oom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use freegpuresource instead of cache limit maintenance. Created 5 years, 8 months 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 | « cc/resources/resource_provider.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 5428c940150edecf78004c6f99223d5b9b18d474..43f75f3f7417b0349f90183e89a4bbcb29e5c676 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -2151,4 +2151,28 @@ class GrContext* ResourceProvider::GrContext(bool worker_context) const {
return context_provider ? context_provider->GrContext() : NULL;
}
+void ResourceProvider::FreeGrResources() {
+ if (!output_surface_)
+ return;
+
+ ContextProvider* context_provider =
+ output_surface_->worker_context_provider();
+ if (!context_provider)
+ return;
+
+ // The context lock must be held while accessing the context on a
+ // worker thread.
+ base::AutoLock context_lock(*context_provider->GetLock());
+
+ // Allow context to bind to current thread.
+ context_provider->DetachFromThread();
+
+ class GrContext* gr_context = context_provider->GrContext();
+ DCHECK(gr_context);
+ gr_context->freeGpuResources();
+
+ // Allow context to bind to other threads.
+ context_provider->DetachFromThread();
+}
+
} // namespace cc
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698