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

Unified Diff: cc/resources/gpu_rasterizer.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: review comments addressed. Created 5 years, 9 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/gpu_rasterizer.h ('k') | cc/resources/rasterizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/gpu_rasterizer.cc
diff --git a/cc/resources/gpu_rasterizer.cc b/cc/resources/gpu_rasterizer.cc
index 6e318edabbe80a2c670eef3baf96abf9dd36d990..ff5b584aed48bd7e6036ad6aee8444e0c7e1bca9 100644
--- a/cc/resources/gpu_rasterizer.cc
+++ b/cc/resources/gpu_rasterizer.cc
@@ -191,4 +191,27 @@ void GpuRasterizer::AddToMultiPictureDraw(const Tile* tile,
multi_picture_draw_.add(sk_surface->getCanvas(), picture.get());
}
+void GpuRasterizer::ClearCache() {
+ ContextProvider* context_provider =
+ resource_provider()->output_surface()->worker_context_provider();
+
+ // 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();
+
+ // Clear resource cache.
+ GrContext* gr_context = context_provider->GrContext();
+ DCHECK(gr_context);
+ gr_context->setResourceCacheLimits(0, 0);
vmiura 2015/03/23 20:34:40 We'll want to not have limits stuck at 0 forever.
sohanjg 2015/03/24 05:42:09 Acknowledged. Also, should we maintain the limits
vmiura 2015/03/24 06:32:52 Sounds like a good solution.
sohanjg 2015/03/24 13:03:36 Done.
+
+ // Barrier to sync worker context output to cc context.
+ context_provider->ContextGL()->OrderingBarrierCHROMIUM();
vmiura 2015/03/23 20:34:40 I think it's not necessary to use an ordering barr
sohanjg 2015/03/24 05:42:09 Acknowledged. And i wonder, ClearCache() will be
vmiura 2015/03/24 06:32:52 Ah, we have to be careful here. Threaded-GPU mode
sohanjg 2015/03/24 13:03:36 Acknowledged.
+
+ // Allow context to bind to other threads.
+ context_provider->DetachFromThread();
+}
+
} // namespace cc
« no previous file with comments | « cc/resources/gpu_rasterizer.h ('k') | cc/resources/rasterizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698