Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
bool GrTexture::NeedsFiltering(const GrResourceKey& key) {
    return 0 != (key.getValue32(3) & kFilter_TextureBit);
}
Exemplo n.º 3
0
bool GrTexture::IsScratchTexture(const GrResourceKey& key) {
    return 0 != (key.getValue32(3) & kScratch_TextureBit);
}
Exemplo n.º 4
0
bool GrTexture::NeedsResizing(const GrResourceKey& key) {
    return 0 != (key.getValue32(3) & kNPOT_TextureBit);
}
Exemplo n.º 5
0
void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) {
    SkASSERT(fScratchKey.isNullScratch());
    SkASSERT(scratchKey.isScratch());
    SkASSERT(!scratchKey.isNullScratch());
    fScratchKey = scratchKey;
}
Exemplo n.º 6
0
bool GrTexture::NeedsFiltering(const GrResourceKey& key) {
    return SkToBool(key.getResourceFlags() & kFilter_TextureFlag);
}
Exemplo n.º 7
0
bool GrTexture::NeedsResizing(const GrResourceKey& key) {
    return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag);
}
bool GrTexture::NeedsBilerp(const GrResourceKey& key) {
    return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag);
}