Chromium Code Reviews| Index: cc/resources/gpu_rasterizer.cc |
| diff --git a/cc/resources/gpu_rasterizer.cc b/cc/resources/gpu_rasterizer.cc |
| index 6e318edabbe80a2c670eef3baf96abf9dd36d990..5a7a64b32e3c077421f219f671f257ff66241cda 100644 |
| --- a/cc/resources/gpu_rasterizer.cc |
| +++ b/cc/resources/gpu_rasterizer.cc |
| @@ -46,7 +46,10 @@ GpuRasterizer::GpuRasterizer(ContextProvider* context_provider, |
| : resource_provider_(resource_provider), |
| use_distance_field_text_(use_distance_field_text), |
| threaded_gpu_rasterization_enabled_(threaded_gpu_rasterization_enabled), |
| - msaa_sample_count_(msaa_sample_count) { |
| + msaa_sample_count_(msaa_sample_count), |
| + maxTextures_(0), |
| + maxTextureBytes_(0), |
| + cache_cleared_(false) { |
| } |
| GpuRasterizer::~GpuRasterizer() { |
| @@ -191,4 +194,49 @@ 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(); |
| + |
| + // Save old limits and clear resource cache. |
| + GrContext* gr_context = context_provider->GrContext(); |
| + DCHECK(gr_context); |
| + gr_context->getResourceCacheLimits(&maxTextures_, &maxTextureBytes_); |
|
enne (OOO)
2015/03/31 18:43:05
Who sets these limits in the first place? It's wei
|
| + gr_context->setResourceCacheLimits(0, 0); |
| + |
| + // Allow context to bind to other threads. |
| + context_provider->DetachFromThread(); |
| + cache_cleared_ = true; |
| +} |
| + |
| +void GpuRasterizer::RestoreCacheLimits() { |
| + if (!cache_cleared_) |
| + return; |
| + |
| + 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(); |
| + |
| + // Restore resource cache. |
| + GrContext* gr_context = context_provider->GrContext(); |
| + DCHECK(gr_context); |
| + gr_context->setResourceCacheLimits(maxTextures_, maxTextureBytes_); |
| + |
| + // Allow context to bind to other threads. |
| + context_provider->DetachFromThread(); |
| +} |
| + |
| } // namespace cc |