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

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

Issue 639873002: Use presence of a content key as non-scratch indicator (Closed) Base URL: https://skia.googlesource.com/skia.git@pp
Patch Set: rebase again Created 6 years, 2 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/GrGpuResource.cpp ('k') | src/gpu/GrResourceCache2.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 2010 Google Inc. 3 * Copyright 2010 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
10
11 #include "GrResourceCache.h" 9 #include "GrResourceCache.h"
12 #include "GrGpuResource.h" 10 #include "GrGpuResource.h"
13 #include "GrTexturePriv.h" 11 #include "GrTexturePriv.h"
14 12
15
16 DECLARE_SKMESSAGEBUS_MESSAGE(GrResourceInvalidatedMessage); 13 DECLARE_SKMESSAGEBUS_MESSAGE(GrResourceInvalidatedMessage);
17 14
18 /////////////////////////////////////////////////////////////////////////////// 15 ///////////////////////////////////////////////////////////////////////////////
19 16
20 void GrGpuResource::didChangeGpuMemorySize() const { 17 void GrGpuResource::didChangeGpuMemorySize() const {
21 if (this->isInCache()) { 18 if (this->isInCache()) {
22 fCacheEntry->didChangeResourceSize(); 19 fCacheEntry->didChangeResourceSize();
23 } 20 }
24 } 21 }
25 22
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 this->internalDetach(entry); 171 this->internalDetach(entry);
175 this->attachToHead(entry); 172 this->attachToHead(entry);
176 } 173 }
177 } 174 }
178 175
179 void GrResourceCache::notifyPurgable(const GrGpuResource* resource) { 176 void GrResourceCache::notifyPurgable(const GrGpuResource* resource) {
180 // Remove scratch textures from the cache the moment they become purgeable i f 177 // Remove scratch textures from the cache the moment they become purgeable i f
181 // scratch texture reuse is turned off. 178 // scratch texture reuse is turned off.
182 SkASSERT(resource->getCacheEntry()); 179 SkASSERT(resource->getCacheEntry());
183 if (resource->getCacheEntry()->key().getResourceType() == GrTexturePriv::Res ourceType() && 180 if (resource->getCacheEntry()->key().getResourceType() == GrTexturePriv::Res ourceType() &&
184 resource->fIsScratch && 181 resource->getCacheEntry()->key().isScratch() &&
185 !fCaps->reuseScratchTextures() && 182 !fCaps->reuseScratchTextures() &&
186 !(static_cast<const GrTexture*>(resource)->desc().fFlags & 183 !(static_cast<const GrTexture*>(resource)->desc().fFlags &
187 kRenderTarget_GrTextureFlagBit)) { 184 kRenderTarget_GrTextureFlagBit)) {
188 this->deleteResource(resource->getCacheEntry()); 185 this->deleteResource(resource->getCacheEntry());
189 } 186 }
190 } 187 }
191 188
192 GrGpuResource* GrResourceCache::find(const GrResourceKey& key) { 189 GrGpuResource* GrResourceCache::find(const GrResourceKey& key) {
190 // GrResourceCache2 is responsible for scratch resources.
191 SkASSERT(!key.isScratch());
192
193 GrAutoResourceCacheValidate atcv(this); 193 GrAutoResourceCacheValidate atcv(this);
194 194
195 GrResourceCacheEntry* entry = NULL; 195 GrResourceCacheEntry* entry = fCache.find(key);
196
197 entry = fCache.find(key);
198
199 if (NULL == entry) { 196 if (NULL == entry) {
200 return NULL; 197 return NULL;
201 } 198 }
202 199
203 // Make this resource MRU 200 // Make this resource MRU
204 this->internalDetach(entry); 201 this->internalDetach(entry);
205 this->attachToHead(entry); 202 this->attachToHead(entry);
206 203
207 // GrResourceCache2 is responsible for scratch resources.
208 SkASSERT(GrGpuResource::kNo_IsScratch == entry->resource()->fIsScratch);
209 return entry->fResource; 204 return entry->fResource;
210 } 205 }
211 206
212 void GrResourceCache::addResource(const GrResourceKey& key, GrGpuResource* resou rce) { 207 void GrResourceCache::addResource(const GrResourceKey& key, GrGpuResource* resou rce) {
213 SkASSERT(NULL == resource->getCacheEntry()); 208 SkASSERT(NULL == resource->getCacheEntry());
214 // we don't expect to create new resources during a purge. In theory 209 // we don't expect to create new resources during a purge. In theory
215 // this could cause purgeAsNeeded() into an infinite loop (e.g. 210 // this could cause purgeAsNeeded() into an infinite loop (e.g.
216 // each resource destroyed creates and locks 2 resources and 211 // each resource destroyed creates and locks 2 resources and
217 // unlocks 1 thereby causing a new purge). 212 // unlocks 1 thereby causing a new purge).
218 SkASSERT(!fPurging); 213 SkASSERT(!fPurging);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes); 418 SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes);
424 SkDebugf("\t\tEntry Count: current %d (%d locked) high %d\n", 419 SkDebugf("\t\tEntry Count: current %d (%d locked) high %d\n",
425 fEntryCount, locked, fHighWaterEntryCount); 420 fEntryCount, locked, fHighWaterEntryCount);
426 SkDebugf("\t\tEntry Bytes: current %d high %d\n", 421 SkDebugf("\t\tEntry Bytes: current %d high %d\n",
427 fEntryBytes, fHighWaterEntryBytes); 422 fEntryBytes, fHighWaterEntryBytes);
428 } 423 }
429 424
430 #endif 425 #endif
431 426
432 /////////////////////////////////////////////////////////////////////////////// 427 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/gpu/GrGpuResource.cpp ('k') | src/gpu/GrResourceCache2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698