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

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

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

Powered by Google App Engine
This is Rietveld 408576698