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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « cc/resources/gpu_rasterizer.h ('k') | cc/resources/rasterizer.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/gpu_rasterizer.h" 5 #include "cc/resources/gpu_rasterizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 canvas->save(); 184 canvas->save();
185 tile->raster_source()->PlaybackToCanvas(canvas.get(), tile->content_rect(), 185 tile->raster_source()->PlaybackToCanvas(canvas.get(), tile->content_rect(),
186 tile->contents_scale()); 186 tile->contents_scale());
187 canvas->restore(); 187 canvas->restore();
188 188
189 // Add the canvas and recorded picture to |multi_picture_draw_|. 189 // Add the canvas and recorded picture to |multi_picture_draw_|.
190 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); 190 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
191 multi_picture_draw_.add(sk_surface->getCanvas(), picture.get()); 191 multi_picture_draw_.add(sk_surface->getCanvas(), picture.get());
192 } 192 }
193 193
194 void GpuRasterizer::ClearCache() {
195 ContextProvider* context_provider =
196 resource_provider()->output_surface()->worker_context_provider();
197
198 // The context lock must be held while accessing the context on a
199 // worker thread.
200 base::AutoLock context_lock(*context_provider->GetLock());
201
202 // Allow context to bind to current thread.
203 context_provider->DetachFromThread();
204
205 // Clear resource cache.
206 GrContext* gr_context = context_provider->GrContext();
207 DCHECK(gr_context);
208 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.
209
210 // Barrier to sync worker context output to cc context.
211 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.
212
213 // Allow context to bind to other threads.
214 context_provider->DetachFromThread();
215 }
216
194 } // namespace cc 217 } // namespace cc
OLDNEW
« 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