void SkBitmapCache::Add(uint32_t genID, const SkBitmap& result, SkResourceCache* localCache) { SkASSERT(result.isImmutable()); BitmapRec* rec = new BitmapRec(genID, 1, 1, SkIRect::MakeEmpty(), result); CHECK_LOCAL(localCache, add, Add, rec); }
bool SkBitmapCache::FindWH(const SkBitmapCacheDesc& desc, SkBitmap* result, SkResourceCache* localCache) { if (0 == desc.fWidth || 0 == desc.fHeight) { // degenerate return false; } return CHECK_LOCAL(localCache, find, Find, BitmapKey(desc), BitmapRec::Finder, result); }
const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* localCache) { SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache)); if (mipmap) { MipMapRec* rec = SkNEW_ARGS(MipMapRec, (src, mipmap)); CHECK_LOCAL(localCache, add, Add, rec); src.pixelRef()->notifyAddedToCache(); } return mipmap; }
const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmap& src, SkResourceCache* localCache) { MipMapKey key(src.getGenerationID(), get_bounds_from_bitmap(src)); const SkMipMap* result; if (!CHECK_LOCAL(localCache, find, Find, key, MipMapRec::Finder, &result)) { result = NULL; } return result; }
bool SkBitmapCache::Find(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY, SkBitmap* result, SkResourceCache* localCache) { if (0 == invScaleX || 0 == invScaleY) { // degenerate, and the key we use for mipmaps return false; } BitmapKey key(src.getGenerationID(), invScaleX, invScaleY, get_bounds_from_bitmap(src)); return CHECK_LOCAL(localCache, find, Find, key, BitmapRec::Finder, result); }
const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkSourceGammaTreatment treatment, SkResourceCache* localCache) { SkMipMap* mipmap = SkMipMap::Build(src, treatment, get_fact(localCache)); if (mipmap) { MipMapRec* rec = new MipMapRec(src, treatment, mipmap); CHECK_LOCAL(localCache, add, Add, rec); src.pixelRef()->notifyAddedToCache(); } return mipmap; }
bool SkBitmapCache::AddWH(const SkBitmapCacheDesc& desc, const SkBitmap& result, SkResourceCache* localCache) { if (0 == desc.fWidth || 0 == desc.fHeight) { // degenerate, and the key we use for mipmaps return false; } SkASSERT(result.isImmutable()); BitmapRec* rec = new BitmapRec(desc, result); CHECK_LOCAL(localCache, add, Add, rec); return true; }
SkCachedData* SkYUVPlanesCache::FindAndRef(uint32_t genID, Info* info, SkResourceCache* localCache) { YUVValue result; YUVPlanesKey key(genID); if (!CHECK_LOCAL(localCache, find, Find, key, YUVPlanesRec::Visitor, &result)) { return NULL; } *info = result.fInfo; return result.fData; }
void SkBitmapCache::Add(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY, const SkBitmap& result, SkResourceCache* localCache) { if (0 == invScaleX || 0 == invScaleY) { // degenerate, and the key we use for mipmaps return; } SkASSERT(result.isImmutable()); BitmapRec* rec = SkNEW_ARGS(BitmapRec, (src.getGenerationID(), invScaleX, invScaleY, get_bounds_from_bitmap(src), result)); CHECK_LOCAL(localCache, add, Add, rec); src.pixelRef()->notifyAddedToCache(); }
SkCachedData* SkMaskCache::FindAndRef(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, const SkRRect& rrect, SkMask* mask, SkResourceCache* localCache) { MaskValue result; RRectBlurKey key(sigma, rrect, style, quality); if (!CHECK_LOCAL(localCache, find, Find, key, RRectBlurRec::Visitor, &result)) { return NULL; } *mask = result.fMask; mask->fImage = (uint8_t*)(result.fData->data()); return result.fData; }
const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmapCacheDesc& desc, SkSourceGammaTreatment treatment, SkResourceCache* localCache) { // Note: we ignore width/height from desc, just need id and bounds MipMapKey key(desc.fImageID, treatment, desc.fBounds); const SkMipMap* result; if (!CHECK_LOCAL(localCache, find, Find, key, MipMapRec::Finder, &result)) { result = nullptr; } return result; }
bool SkBitmapCache::Add(SkPixelRef* pr, const SkIRect& subset, const SkBitmap& result, SkResourceCache* localCache) { SkASSERT(result.isImmutable()); if (subset.isEmpty() || subset.top() < 0 || subset.left() < 0 || result.width() != subset.width() || result.height() != subset.height()) { return false; } else { BitmapRec* rec = SkNEW_ARGS(BitmapRec, (pr->getGenerationID(), 1, 1, subset, result)); CHECK_LOCAL(localCache, add, Add, rec); pr->notifyAddedToCache(); return true; } }
bool SkBitmapCache::Find(uint32_t genID, const SkIRect& subset, SkBitmap* result, SkResourceCache* localCache) { BitmapKey key(genID, SK_Scalar1, SK_Scalar1, subset); return CHECK_LOCAL(localCache, find, Find, key, BitmapRec::Finder, result); }
void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, const SkRRect& rrect, const SkMask& mask, SkCachedData* data, SkResourceCache* localCache) { RRectBlurKey key(sigma, rrect, style, quality); return CHECK_LOCAL(localCache, add, Add, SkNEW_ARGS(RRectBlurRec, (key, mask, data))); }
void SkYUVPlanesCache::Add(uint32_t genID, SkCachedData* data, Info* info, SkResourceCache* localCache) { YUVPlanesKey key(genID); return CHECK_LOCAL(localCache, add, Add, new YUVPlanesRec(key, data, info)); }