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

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

Issue 1286203002: Defer flushes if kPreferNoIO is specified (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use explicit size in test Created 5 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/GrResourceCache.h ('k') | src/gpu/GrResourceProvider.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 "GrResourceCache.h" 10 #include "GrResourceCache.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return false; 239 return false;
240 } 240 }
241 return !fRejectPendingIO || !resource->internalHasPendingIO(); 241 return !fRejectPendingIO || !resource->internalHasPendingIO();
242 } 242 }
243 243
244 private: 244 private:
245 bool fRejectPendingIO; 245 bool fRejectPendingIO;
246 }; 246 };
247 247
248 GrGpuResource* GrResourceCache::findAndRefScratchResource(const GrScratchKey& sc ratchKey, 248 GrGpuResource* GrResourceCache::findAndRefScratchResource(const GrScratchKey& sc ratchKey,
249 size_t resourceSize,
249 uint32_t flags) { 250 uint32_t flags) {
250 SkASSERT(scratchKey.isValid()); 251 SkASSERT(scratchKey.isValid());
251 252
252 GrGpuResource* resource; 253 GrGpuResource* resource;
253 if (flags & (kPreferNoPendingIO_ScratchFlag | kRequireNoPendingIO_ScratchFla g)) { 254 if (flags & (kPreferNoPendingIO_ScratchFlag | kRequireNoPendingIO_ScratchFla g)) {
254 resource = fScratchMap.find(scratchKey, AvailableForScratchUse(true)); 255 resource = fScratchMap.find(scratchKey, AvailableForScratchUse(true));
255 if (resource) { 256 if (resource) {
256 this->refAndMakeResourceMRU(resource); 257 this->refAndMakeResourceMRU(resource);
257 this->validate(); 258 this->validate();
258 return resource; 259 return resource;
259 } else if (flags & kRequireNoPendingIO_ScratchFlag) { 260 } else if (flags & kRequireNoPendingIO_ScratchFlag) {
260 return NULL; 261 return NULL;
261 } 262 }
262 // TODO: fail here when kPrefer is specified, we didn't find a resource without pending io, 263 if (this->wouldFit(resourceSize)) {
263 // but there is still space in our budget for the resource. 264 // kPrefer is specified, we didn't find a resource without pending i o,
265 // but there is still space in our budget for the resource.
266 return NULL;
267 }
264 } 268 }
265 resource = fScratchMap.find(scratchKey, AvailableForScratchUse(false)); 269 resource = fScratchMap.find(scratchKey, AvailableForScratchUse(false));
266 if (resource) { 270 if (resource) {
267 this->refAndMakeResourceMRU(resource); 271 this->refAndMakeResourceMRU(resource);
268 this->validate(); 272 this->validate();
269 } 273 }
270 return resource; 274 return resource;
271 } 275 }
272 276
273 void GrResourceCache::willRemoveScratchKey(const GrGpuResource* resource) { 277 void GrResourceCache::willRemoveScratchKey(const GrGpuResource* resource) {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 return true; 720 return true;
717 } 721 }
718 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index] == resource) { 722 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index] == resource) {
719 return true; 723 return true;
720 } 724 }
721 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca che."); 725 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca che.");
722 return false; 726 return false;
723 } 727 }
724 728
725 #endif 729 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrResourceCache.h ('k') | src/gpu/GrResourceProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698