Lines Matching refs:cache

36     // Set the cache limits so we can fit 10 "src" images and the
93 void setDeleteWhenDestroyed(GrResourceCache* cache, TestResource* resource) {
94 fCache = cache;
116 GrResourceCache cache(5, 30000);
118 // Add two resources with the same key that delete each other from the cache when destroyed.
121 cache.addResource(key, a);
122 cache.addResource(key, b);
124 a->setDeleteWhenDestroyed(&cache, b);
125 b->setDeleteWhenDestroyed(&cache, a);
131 cache.addResource(key, r);
138 cache.purgeAsNeeded();
154 GrResourceCache cache(3, 30000);
157 cache.addResource(key, a);
158 cache.addResource(key, b);
160 a->setDeleteWhenDestroyed(&cache, b);
161 b->setDeleteWhenDestroyed(&cache, a);
170 GrResourceCache cache(3, 30000);
173 cache.addResource(key, a);
174 cache.addResource(key, b);
176 a->setDeleteWhenDestroyed(&cache, b);
177 b->setDeleteWhenDestroyed(&cache, a);
182 cache.deleteResource(a->getCacheEntry());
205 GrResourceCache cache(2, 300);
208 a->setSize(100); // Test didChangeGpuMemorySize() when not in the cache.
209 cache.addResource(key1, a);
214 cache.addResource(key2, b);
217 REPORTER_ASSERT(reporter, 200 == cache.getCachedResourceBytes());
218 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
220 static_cast<TestResource*>(cache.find(key2))->setSize(200);
221 static_cast<TestResource*>(cache.find(key1))->setSize(50);
223 REPORTER_ASSERT(reporter, 250 == cache.getCachedResourceBytes());
224 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
227 // Test increasing a resources size beyond the cache budget.
229 GrResourceCache cache(2, 300);
232 cache.addResource(key1, a);
236 cache.addResource(key2, b);
239 REPORTER_ASSERT(reporter, 200 == cache.getCachedResourceBytes());
240 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
242 static_cast<TestResource*>(cache.find(key2))->setSize(201);
243 REPORTER_ASSERT(reporter, NULL == cache.find(key1));
245 REPORTER_ASSERT(reporter, 201 == cache.getCachedResourceBytes());
246 REPORTER_ASSERT(reporter, 1 == cache.getCachedResourceCount());
251 GrResourceCache cache(2, 300);
254 cache.addResource(key1, a);
255 cache.makeExclusive(a->getCacheEntry());
258 cache.addResource(key2, b);
261 REPORTER_ASSERT(reporter, 200 == cache.getCachedResourceBytes());
262 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
263 REPORTER_ASSERT(reporter, NULL == cache.find(key1));
267 REPORTER_ASSERT(reporter, 300 == cache.getCachedResourceBytes());
268 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
269 // Internal resource cache validation will test the detached size (debug mode only).
271 cache.makeNonExclusive(a->getCacheEntry());
274 REPORTER_ASSERT(reporter, 300 == cache.getCachedResourceBytes());
275 REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
276 REPORTER_ASSERT(reporter, NULL != cache.find(key1));
277 // Internal resource cache validation will test the detached size (debug mode only).