Home | History | Annotate | Download | only in tests

Lines Matching defs:cache

41     SkAutoTDelete<SkResourceCache> cache;
43 cache.reset(new SkResourceCache(factory));
46 cache.reset(new SkResourceCache(byteLimit));
58 REPORTER_ASSERT(reporter, !SkBitmapCache::Add(cachedPR, SkIRect::MakeWH(4, 6), cachedBitmap, cache));
59 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache));
61 REPORTER_ASSERT(reporter, !SkBitmapCache::Add(cachedPR, SkIRect::MakeXYWH(-1, 0, 5, 5), cachedBitmap, cache));
62 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache));
64 // Should not be in the cache
65 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedID, rect, &bm, cache));
67 REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedPR, rect, cachedBitmap, cache));
68 // Should be in the cache, we just added it
69 REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedID, rect, &bm, cache));
92 static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cache) {
93 cache->purgeAll();
99 const SkMipMap* mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), cache);
102 mipmap = SkMipMapCache::AddAndRef(src, cache);
106 const SkMipMap* mm = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), cache);
115 // tricky, since technically after this I'm no longer an owner, but since the cache is
120 mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), cache);
123 cache->purgeAll();
129 static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* cache) {
135 SkMipMapCache::AddAndRef(src[i], cache)->unref();
139 const SkMipMap* mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src[i]), cache);
140 if (cache) {
141 // if cache is null, we're working on the global cache, and other threads might purge
147 src[i].reset(); // delete the underlying pixelref, which *should* remove us from the cache
149 mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src[i]), cache);
154 static void test_bitmap_notify(skiatest::Reporter* reporter, SkResourceCache* cache) {
163 SkBitmapCache::Add(src[i].pixelRef(), subset, dst[i], cache);
169 bool found = SkBitmapCache::Find(genID, subset, &result, cache);
170 if (cache) {
171 // if cache is null, we're working on the global cache, and other threads might purge
176 src[i].reset(); // delete the underlying pixelref, which *should* remove us from the cache
178 found = SkBitmapCache::Find(genID, subset, &result, cache);
191 static void testBitmapCache_discarded_bitmap(skiatest::Reporter* reporter, SkResourceCache* cache,
193 SkBitmap::Allocator* allocator = cache->allocator();
212 // Add a bitmap to the cache.
214 cache));
216 cache));
220 cache));
228 // The bitmap is not in the cache since it has been dropped.
230 &bm, cache));
238 // We can add the bitmap back to the cache and find it again.
240 cache));
242 cache));
244 test_mipmapcache(reporter, cache);
245 test_bitmap_notify(reporter, cache);
246 test_mipmap_notify(reporter, cache);
252 SkResourceCache cache(byteLimit);
253 testBitmapCache_discarded_bitmap(reporter, &cache, nullptr);
260 SkResourceCache cache(factory);
261 testBitmapCache_discarded_bitmap(reporter, &cache, factory);
299 // Verify that associated bitmap cache entries are purged on SkImage destruction.
301 // Cache entries associated with SkImages fall into two categories:
306 // To exercise the first cache type, we use generated/picture-backed SkImages.