SkBitmapCacheDesc SkBitmapCacheDesc::Make(const SkBitmap& bm, int width, int height) { SkBitmapCacheDesc desc; desc.fImageID = bm.getGenerationID(); desc.fWidth = width; desc.fHeight = height; desc.fBounds = get_bounds_from_bitmap(bm); return desc; }
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); }
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(); }