bool GrResourceCache::addResource(const GrResourceKey& key, GrGpuResource* resource) { if (NULL != resource->cacheAccess().getCacheEntry()) { return false; } if (key.isScratch()) { SkASSERT(resource->cacheAccess().isScratch()); SkASSERT(key == resource->cacheAccess().getScratchKey()); } else { if (!resource->cacheAccess().setContentKey(key)) { return false; } } // we don't expect to create new resources during a purge. In theory // this could cause purgeAsNeeded() into an infinite loop (e.g. // each resource destroyed creates and locks 2 resources and // unlocks 1 thereby causing a new purge). SkASSERT(!fPurging); GrAutoResourceCacheValidate atcv(this); GrResourceCacheEntry* entry = SkNEW_ARGS(GrResourceCacheEntry, (this, resource)); resource->cacheAccess().setCacheEntry(entry); this->attachToHead(entry); this->purgeAsNeeded(); return true; }
bool GrTexture::NeedsFiltering(const GrResourceKey& key) { return 0 != (key.getValue32(3) & kFilter_TextureBit); }
bool GrTexture::IsScratchTexture(const GrResourceKey& key) { return 0 != (key.getValue32(3) & kScratch_TextureBit); }
bool GrTexture::NeedsResizing(const GrResourceKey& key) { return 0 != (key.getValue32(3) & kNPOT_TextureBit); }
void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) { SkASSERT(fScratchKey.isNullScratch()); SkASSERT(scratchKey.isScratch()); SkASSERT(!scratchKey.isNullScratch()); fScratchKey = scratchKey; }
bool GrTexture::NeedsFiltering(const GrResourceKey& key) { return SkToBool(key.getResourceFlags() & kFilter_TextureFlag); }
bool GrTexture::NeedsResizing(const GrResourceKey& key) { return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); }
bool GrTexture::NeedsBilerp(const GrResourceKey& key) { return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); }