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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 return context_provider ? context_provider->ContextGL() : NULL; 2144 return context_provider ? context_provider->ContextGL() : NULL;
2145 } 2145 }
2146 2146
2147 class GrContext* ResourceProvider::GrContext(bool worker_context) const { 2147 class GrContext* ResourceProvider::GrContext(bool worker_context) const {
2148 ContextProvider* context_provider = 2148 ContextProvider* context_provider =
2149 worker_context ? output_surface_->worker_context_provider() 2149 worker_context ? output_surface_->worker_context_provider()
2150 : output_surface_->context_provider(); 2150 : output_surface_->context_provider();
2151 return context_provider ? context_provider->GrContext() : NULL; 2151 return context_provider ? context_provider->GrContext() : NULL;
2152 } 2152 }
2153 2153
2154 void ResourceProvider::FreeGrResources() {
2155 if (!output_surface_)
2156 return;
2157
2158 ContextProvider* context_provider =
2159 output_surface_->worker_context_provider();
2160 if (!context_provider)
2161 return;
2162
2163 // The context lock must be held while accessing the context on a
2164 // worker thread.
2165 base::AutoLock context_lock(*context_provider->GetLock());
2166
2167 // Allow context to bind to current thread.
2168 context_provider->DetachFromThread();
2169
2170 class GrContext* gr_context = context_provider->GrContext();
2171 DCHECK(gr_context);
2172 gr_context->freeGpuResources();
2173
2174 // Allow context to bind to other threads.
2175 context_provider->DetachFromThread();
2176 }
2177
2154 } // namespace cc 2178 } // namespace cc
OLDNEW
« 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