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

Side by Side Diff: src/gpu/GrResourceCache2.cpp

Issue 481443002: Add GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix leaks Created 6 years, 4 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 | « src/gpu/GrResourceCache2.h ('k') | src/gpu/gl/GrGpuGL.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2014 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10 #include "GrResourceCache2.h"
11 #include "GrGpuResource.h"
12
13 GrResourceCache2::~GrResourceCache2() {
14 this->releaseAll();
15 }
16
17 void GrResourceCache2::insertResource(GrGpuResource* resource) {
18 SkASSERT(NULL != resource);
19 SkASSERT(!resource->wasDestroyed());
20 fResources.addToHead(resource);
21 ++fCount;
22 }
23
24 void GrResourceCache2::removeResource(GrGpuResource* resource) {
25 fResources.remove(resource);
26 --fCount;
27 }
28
29 void GrResourceCache2::abandonAll() {
30 while (GrGpuResource* head = fResources.head()) {
31 SkASSERT(!head->wasDestroyed());
32 head->abandon();
33 // abandon should have already removed this from the list.
34 SkASSERT(head != fResources.head());
35 }
36 SkASSERT(!fCount);
37 }
38
39 void GrResourceCache2::releaseAll() {
40 while (GrGpuResource* head = fResources.head()) {
41 SkASSERT(!head->wasDestroyed());
42 head->release();
43 // release should have already removed this from the list.
44 SkASSERT(head != fResources.head());
45 }
46 SkASSERT(!fCount);
47 }
OLDNEW
« no previous file with comments | « src/gpu/GrResourceCache2.h ('k') | src/gpu/gl/GrGpuGL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698