blob: f925b0775443813e9c12a780665dc40573abb74f [file] [log] [blame]
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +00008#if SK_SUPPORT_GPU
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +00009
bsalomonbcf0a522014-10-08 08:40:09 -070010#include "GrContext.h"
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000011#include "GrContextFactory.h"
bsalomonbcf0a522014-10-08 08:40:09 -070012#include "GrGpu.h"
bsalomon33435572014-11-05 14:47:41 -080013#include "GrResourceCache2.h"
bsalomonbcf0a522014-10-08 08:40:09 -070014#include "SkCanvas.h"
bsalomon71cb0c22014-11-14 12:10:14 -080015#include "SkGr.h"
16#include "SkMessageBus.h"
reed69f6f002014-09-18 06:09:44 -070017#include "SkSurface.h"
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +000018#include "Test.h"
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000019
20static const int gWidth = 640;
21static const int gHeight = 480;
22
23////////////////////////////////////////////////////////////////////////////////
bsalomon33435572014-11-05 14:47:41 -080024static void test_cache(skiatest::Reporter* reporter, GrContext* context, SkCanvas* canvas) {
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000025 const SkIRect size = SkIRect::MakeWH(gWidth, gHeight);
26
27 SkBitmap src;
mike@reedtribe.orgdeee4962014-02-13 14:41:43 +000028 src.allocN32Pixels(size.width(), size.height());
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000029 src.eraseColor(SK_ColorBLACK);
30 size_t srcSize = src.getSize();
31
commit-bot@chromium.org95c20032014-05-09 14:29:32 +000032 size_t initialCacheSize;
33 context->getResourceCacheUsage(NULL, &initialCacheSize);
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000034
35 int oldMaxNum;
36 size_t oldMaxBytes;
commit-bot@chromium.org95c20032014-05-09 14:29:32 +000037 context->getResourceCacheLimits(&oldMaxNum, &oldMaxBytes);
skia.committer@gmail.com17f1ae62013-08-09 07:01:22 +000038
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000039 // Set the cache limits so we can fit 10 "src" images and the
40 // max number of textures doesn't matter
41 size_t maxCacheSize = initialCacheSize + 10*srcSize;
commit-bot@chromium.org95c20032014-05-09 14:29:32 +000042 context->setResourceCacheLimits(1000, maxCacheSize);
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000043
44 SkBitmap readback;
mike@reedtribe.orgdeee4962014-02-13 14:41:43 +000045 readback.allocN32Pixels(size.width(), size.height());
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000046
47 for (int i = 0; i < 100; ++i) {
48 canvas->drawBitmap(src, 0, 0);
49 canvas->readPixels(size, &readback);
50
51 // "modify" the src texture
52 src.notifyPixelsChanged();
53
commit-bot@chromium.org95c20032014-05-09 14:29:32 +000054 size_t curCacheSize;
55 context->getResourceCacheUsage(NULL, &curCacheSize);
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000056
57 // we should never go over the size limit
58 REPORTER_ASSERT(reporter, curCacheSize <= maxCacheSize);
59 }
60
commit-bot@chromium.org95c20032014-05-09 14:29:32 +000061 context->setResourceCacheLimits(oldMaxNum, oldMaxBytes);
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +000062}
63
bsalomon6d3fe022014-07-25 08:35:45 -070064class TestResource : public GrGpuResource {
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +000065 static const size_t kDefaultSize = 100;
66
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +000067public:
68 SK_DECLARE_INST_COUNT(TestResource);
bsalomondace19e2014-11-17 07:34:06 -080069 TestResource(GrGpu* gpu, bool isWrapped)
70 : INHERITED(gpu, isWrapped)
71 , fToDelete(NULL)
72 , fSize(kDefaultSize) {
73 ++fNumAlive;
74 this->registerWithCache();
75 }
76
bsalomon8b79d232014-11-10 10:19:06 -080077 TestResource(GrGpu* gpu)
bsalomonc44be0e2014-07-25 07:32:33 -070078 : INHERITED(gpu, false)
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +000079 , fToDelete(NULL)
bsalomon8b79d232014-11-10 10:19:06 -080080 , fSize(kDefaultSize) {
81 ++fNumAlive;
82 this->registerWithCache();
83 }
84
85 TestResource(GrGpu* gpu, const GrResourceKey& scratchKey)
86 : INHERITED(gpu, false)
bsalomon8b79d232014-11-10 10:19:06 -080087 , fToDelete(NULL)
88 , fSize(kDefaultSize) {
89 this->setScratchKey(scratchKey);
bsalomon33435572014-11-05 14:47:41 -080090 ++fNumAlive;
bsalomon16961262014-08-26 14:01:07 -070091 this->registerWithCache();
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +000092 }
93
94 ~TestResource() {
bsalomon33435572014-11-05 14:47:41 -080095 --fNumAlive;
bsalomon71cb0c22014-11-14 12:10:14 -080096 SkSafeUnref(fToDelete);
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +000097 }
98
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +000099 void setSize(size_t size) {
100 fSize = size;
101 this->didChangeGpuMemorySize();
102 }
103
bsalomon33435572014-11-05 14:47:41 -0800104 static int NumAlive() { return fNumAlive; }
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000105
bsalomon71cb0c22014-11-14 12:10:14 -0800106 void setUnrefWhenDestroyed(TestResource* resource) {
107 SkRefCnt_SafeAssign(fToDelete, resource);
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000108 }
109
110private:
bsalomon69ed47f2014-11-12 11:13:39 -0800111 size_t onGpuMemorySize() const SK_OVERRIDE { return fSize; }
112
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000113 TestResource* fToDelete;
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000114 size_t fSize;
bsalomon33435572014-11-05 14:47:41 -0800115 static int fNumAlive;
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000116
bsalomon6d3fe022014-07-25 08:35:45 -0700117 typedef GrGpuResource INHERITED;
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000118};
bsalomon33435572014-11-05 14:47:41 -0800119int TestResource::fNumAlive = 0;
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000120
bsalomon71cb0c22014-11-14 12:10:14 -0800121static void test_no_key(skiatest::Reporter* reporter) {
122 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
123 REPORTER_ASSERT(reporter, SkToBool(context));
124 if (NULL == context) {
125 return;
126 }
127 context->setResourceCacheLimits(10, 30000);
128 GrResourceCache2* cache2 = context->getResourceCache2();
129 cache2->purgeAllUnlocked();
130 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
131
132 // Create a bunch of resources with no keys
133 TestResource* a = new TestResource(context->getGpu());
134 TestResource* b = new TestResource(context->getGpu());
135 TestResource* c = new TestResource(context->getGpu());
136 TestResource* d = new TestResource(context->getGpu());
137 a->setSize(11);
138 b->setSize(12);
139 c->setSize(13);
140 d->setSize(14);
141
142 REPORTER_ASSERT(reporter, 4 == TestResource::NumAlive());
143 REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount());
144 REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() + c->gpuMemorySize() +
145 d->gpuMemorySize() == cache2->getResourceBytes());
146
147 // Should be safe to purge without deleting the resources since we still have refs.
148 cache2->purgeAllUnlocked();
149 REPORTER_ASSERT(reporter, 4 == TestResource::NumAlive());
150
151 // Since the resources have neither content nor scratch keys, delete immediately upon unref.
152
153 a->unref();
154 REPORTER_ASSERT(reporter, 3 == TestResource::NumAlive());
155 REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount());
156 REPORTER_ASSERT(reporter, b->gpuMemorySize() + c->gpuMemorySize() + d->gpuMemorySize() ==
157 cache2->getResourceBytes());
158
159 c->unref();
160 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
161 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
162 REPORTER_ASSERT(reporter, b->gpuMemorySize() + d->gpuMemorySize() ==
163 cache2->getResourceBytes());
164
165 d->unref();
166 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
167 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
168 REPORTER_ASSERT(reporter, b->gpuMemorySize() == cache2->getResourceBytes());
169
170 b->unref();
171 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
172 REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
173 REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
174}
175
bsalomon84c8e622014-11-17 09:33:27 -0800176static void test_budgeting(skiatest::Reporter* reporter) {
bsalomondace19e2014-11-17 07:34:06 -0800177 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
178 REPORTER_ASSERT(reporter, SkToBool(context));
179 if (NULL == context) {
180 return;
181 }
182 context->setResourceCacheLimits(10, 300);
183 GrResourceCache2* cache2 = context->getResourceCache2();
184 cache2->purgeAllUnlocked();
185 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
186 SkASSERT(0 == cache2->getBudgetedResourceCount() && 0 == cache2->getBudgetedResourceBytes());
187
188 GrCacheID::Key keyData;
189 memset(&keyData, 0, sizeof(keyData));
190 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
191 GrResourceKey scratchKey(GrCacheID(GrResourceKey::ScratchDomain(), keyData), t, 0);
192 GrResourceKey contentKey(GrCacheID(GrCacheID::GenerateDomain(), keyData), t, 0);
193
194 // Create a scratch, a content, and a wrapped resource
195 TestResource* scratch = new TestResource(context->getGpu(), scratchKey);
196 scratch->setSize(10);
197 TestResource* content = new TestResource(context->getGpu());
198 scratch->setSize(11);
199 REPORTER_ASSERT(reporter, content->cacheAccess().setContentKey(contentKey));
200 TestResource* wrapped = new TestResource(context->getGpu(), true);
201 scratch->setSize(12);
bsalomon84c8e622014-11-17 09:33:27 -0800202 TestResource* unbudgeted = new TestResource(context->getGpu());
203 unbudgeted->setSize(13);
204 unbudgeted->cacheAccess().setBudgeted(false);
bsalomondace19e2014-11-17 07:34:06 -0800205
206 // Make sure we can't add a content key to the wrapped resource
207 keyData.fData8[0] = 1;
208 GrResourceKey contentKey2(GrCacheID(GrCacheID::GenerateDomain(), keyData), t, 0);
209 REPORTER_ASSERT(reporter, !wrapped->cacheAccess().setContentKey(contentKey2));
210 REPORTER_ASSERT(reporter, NULL == cache2->findAndRefContentResource(contentKey2));
211
212 // Make sure sizes are as we expect
bsalomon84c8e622014-11-17 09:33:27 -0800213 REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount());
bsalomondace19e2014-11-17 07:34:06 -0800214 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() +
bsalomon84c8e622014-11-17 09:33:27 -0800215 wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() ==
216 cache2->getResourceBytes());
bsalomondace19e2014-11-17 07:34:06 -0800217 REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
218 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() ==
219 cache2->getBudgetedResourceBytes());
220
221 // Our refs mean that the resources are non purgable.
222 cache2->purgeAllUnlocked();
bsalomon84c8e622014-11-17 09:33:27 -0800223 REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount());
bsalomondace19e2014-11-17 07:34:06 -0800224 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() +
bsalomon84c8e622014-11-17 09:33:27 -0800225 wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() ==
226 cache2->getResourceBytes());
bsalomondace19e2014-11-17 07:34:06 -0800227 REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
228 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() ==
229 cache2->getBudgetedResourceBytes());
230
231 // Unreffing the wrapped resource should free it right away.
232 wrapped->unref();
bsalomon84c8e622014-11-17 09:33:27 -0800233 REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount());
234 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() +
235 unbudgeted->gpuMemorySize() == cache2->getResourceBytes());
bsalomondace19e2014-11-17 07:34:06 -0800236
bsalomon84c8e622014-11-17 09:33:27 -0800237 // Now try freeing the budgeted resources first
bsalomondace19e2014-11-17 07:34:06 -0800238 wrapped = new TestResource(context->getGpu(), true);
239 scratch->setSize(12);
240 content->unref();
241 cache2->purgeAllUnlocked();
bsalomon84c8e622014-11-17 09:33:27 -0800242 REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount());
243 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + wrapped->gpuMemorySize() +
244 unbudgeted->gpuMemorySize() == cache2->getResourceBytes());
bsalomondace19e2014-11-17 07:34:06 -0800245 REPORTER_ASSERT(reporter, 1 == cache2->getBudgetedResourceCount());
246 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() == cache2->getBudgetedResourceBytes());
247
248 scratch->unref();
249 cache2->purgeAllUnlocked();
bsalomon84c8e622014-11-17 09:33:27 -0800250 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
251 REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() + wrapped->gpuMemorySize() ==
252 cache2->getResourceBytes());
bsalomondace19e2014-11-17 07:34:06 -0800253 REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
254 REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
255
256 wrapped->unref();
bsalomon84c8e622014-11-17 09:33:27 -0800257 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
258 REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() == cache2->getResourceBytes());
259 REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
260 REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
261
262 unbudgeted->unref();
bsalomondace19e2014-11-17 07:34:06 -0800263 REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
264 REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
bsalomon84c8e622014-11-17 09:33:27 -0800265 REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
266 REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
bsalomondace19e2014-11-17 07:34:06 -0800267}
268
bsalomon8b79d232014-11-10 10:19:06 -0800269static void test_duplicate_scratch_key(skiatest::Reporter* reporter) {
270 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
271 REPORTER_ASSERT(reporter, SkToBool(context));
272 if (NULL == context) {
273 return;
274 }
275 context->setResourceCacheLimits(5, 30000);
bsalomon71cb0c22014-11-14 12:10:14 -0800276 GrResourceCache2* cache2 = context->getResourceCache2();
277 cache2->purgeAllUnlocked();
278 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
bsalomon8b79d232014-11-10 10:19:06 -0800279
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000280 GrCacheID::Key keyData;
bsalomon48ea2022014-11-12 10:28:17 -0800281 memset(&keyData, 0, sizeof(keyData));
bsalomon8b79d232014-11-10 10:19:06 -0800282 GrCacheID::Domain domain = GrResourceKey::ScratchDomain();
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000283 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
bsalomon8b79d232014-11-10 10:19:06 -0800284 GrResourceKey scratchKey(GrCacheID(domain, keyData), t, 0);
285
286 // Create two resources that have the same scratch key.
287 TestResource* a = new TestResource(context->getGpu(), scratchKey);
288 TestResource* b = new TestResource(context->getGpu(), scratchKey);
289 a->setSize(11);
290 b->setSize(12);
291 // Scratch resources are registered with GrResourceCache2 just by existing. There are 2.
bsalomon8b79d232014-11-10 10:19:06 -0800292 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
293 SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey(scratchKey));)
bsalomon71cb0c22014-11-14 12:10:14 -0800294 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
295 REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() ==
296 cache2->getResourceBytes());
bsalomon8b79d232014-11-10 10:19:06 -0800297
298 // Our refs mean that the resources are non purgable.
bsalomon71cb0c22014-11-14 12:10:14 -0800299 cache2->purgeAllUnlocked();
bsalomon8b79d232014-11-10 10:19:06 -0800300 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
bsalomon71cb0c22014-11-14 12:10:14 -0800301 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
bsalomon8b79d232014-11-10 10:19:06 -0800302
303 // Unref but don't purge
304 a->unref();
305 b->unref();
306 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
307 SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey(scratchKey));)
308
309 // Purge again. This time resources should be purgable.
bsalomon71cb0c22014-11-14 12:10:14 -0800310 cache2->purgeAllUnlocked();
bsalomon8b79d232014-11-10 10:19:06 -0800311 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
bsalomon71cb0c22014-11-14 12:10:14 -0800312 REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
bsalomon8b79d232014-11-10 10:19:06 -0800313 SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey(scratchKey));)
314}
315
bsalomon10e23ca2014-11-25 05:52:06 -0800316static void test_remove_scratch_key(skiatest::Reporter* reporter) {
317 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
318 REPORTER_ASSERT(reporter, SkToBool(context));
319 if (NULL == context) {
320 return;
321 }
322 context->setResourceCacheLimits(5, 30000);
323 GrResourceCache2* cache2 = context->getResourceCache2();
324 cache2->purgeAllUnlocked();
325 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
326
327 GrCacheID::Key keyData;
328 memset(&keyData, 0, sizeof(keyData));
329 GrCacheID::Domain domain = GrResourceKey::ScratchDomain();
330 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
331 GrResourceKey scratchKey(GrCacheID(domain, keyData), t, 0);
332
333 // Create two resources that have the same scratch key.
334 TestResource* a = new TestResource(context->getGpu(), scratchKey);
335 TestResource* b = new TestResource(context->getGpu(), scratchKey);
336 a->unref();
337 b->unref();
338
339 // Scratch resources are registered with GrResourceCache2 just by existing. There are 2.
340 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
341 SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey(scratchKey));)
342 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
343
344 // Find the first resource and remove its scratch key
345 GrGpuResource* find;
346 find = cache2->findAndRefScratchResource(scratchKey);
347 find->cacheAccess().removeScratchKey();
348 // It's still alive, but not cached by scratch key anymore
349 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
350 SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache2->countScratchEntriesForKey(scratchKey));)
351 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
352
353 // The cache should immediately delete it when it's unrefed since it isn't accessible.
354 find->unref();
355 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
356 SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache2->countScratchEntriesForKey(scratchKey));)
357 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
358
359 // Repeat for the second resource.
360 find = cache2->findAndRefScratchResource(scratchKey);
361 find->cacheAccess().removeScratchKey();
362 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
363 SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey(scratchKey));)
364 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
365
366 // Should be able to call this multiple times with no problem.
367 find->cacheAccess().removeScratchKey();
368 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
369 SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey(scratchKey));)
370 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
371
372 find->unref();
373 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
374 SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey(scratchKey));)
375 REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
376}
377
bsalomon8b79d232014-11-10 10:19:06 -0800378static void test_duplicate_content_key(skiatest::Reporter* reporter) {
379 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
380 REPORTER_ASSERT(reporter, SkToBool(context));
381 if (NULL == context) {
382 return;
383 }
bsalomon33435572014-11-05 14:47:41 -0800384 context->setResourceCacheLimits(5, 30000);
bsalomon71cb0c22014-11-14 12:10:14 -0800385 GrResourceCache2* cache2 = context->getResourceCache2();
386 cache2->purgeAllUnlocked();
387 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000388
bsalomon8b79d232014-11-10 10:19:06 -0800389 GrCacheID::Domain domain = GrCacheID::GenerateDomain();
390 GrCacheID::Key keyData;
391 memset(&keyData, 0, sizeof(keyData));
392 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
393 GrResourceKey key(GrCacheID(domain, keyData), t, 0);
394
bsalomon8b79d232014-11-10 10:19:06 -0800395 // Create two resources that we will attempt to register with the same content key.
bsalomonc44be0e2014-07-25 07:32:33 -0700396 TestResource* a = new TestResource(context->getGpu());
397 TestResource* b = new TestResource(context->getGpu());
bsalomon8b79d232014-11-10 10:19:06 -0800398 a->setSize(11);
399 b->setSize(12);
bsalomon71cb0c22014-11-14 12:10:14 -0800400
401 // Can't set the same content key on two resources.
402 REPORTER_ASSERT(reporter, a->cacheAccess().setContentKey(key));
403 REPORTER_ASSERT(reporter, !b->cacheAccess().setContentKey(key));
404
405 // Still have two resources because b is still reffed.
406 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
407 REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() ==
408 cache2->getResourceBytes());
bsalomon8b79d232014-11-10 10:19:06 -0800409 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
410
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000411 b->unref();
bsalomon71cb0c22014-11-14 12:10:14 -0800412 // Now b should be gone.
413 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
414 REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache2->getResourceBytes());
bsalomon8b79d232014-11-10 10:19:06 -0800415 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000416
bsalomon71cb0c22014-11-14 12:10:14 -0800417 cache2->purgeAllUnlocked();
418 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
419 REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache2->getResourceBytes());
420 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
421
422 // Drop the ref on a but it isn't immediately purged as it still has a valid scratch key.
bsalomon8b79d232014-11-10 10:19:06 -0800423 a->unref();
bsalomon71cb0c22014-11-14 12:10:14 -0800424 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
425 REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache2->getResourceBytes());
426 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
427
428 cache2->purgeAllUnlocked();
429 REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
430 REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
bsalomon33435572014-11-05 14:47:41 -0800431 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000432}
433
bsalomon8b79d232014-11-10 10:19:06 -0800434static void test_purge_invalidated(skiatest::Reporter* reporter) {
435 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
436 REPORTER_ASSERT(reporter, SkToBool(context));
437 if (NULL == context) {
438 return;
439 }
440
commit-bot@chromium.orgbd58feb2014-01-17 17:56:21 +0000441 GrCacheID::Domain domain = GrCacheID::GenerateDomain();
442 GrCacheID::Key keyData;
bsalomon8b79d232014-11-10 10:19:06 -0800443 memset(&keyData, 0, sizeof(keyData));
444
commit-bot@chromium.orgbd58feb2014-01-17 17:56:21 +0000445 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
446
bsalomon8b79d232014-11-10 10:19:06 -0800447 keyData.fData64[0] = 1;
448 GrResourceKey key1(GrCacheID(domain, keyData), t, 0);
449 keyData.fData64[0] = 2;
450 GrResourceKey key2(GrCacheID(domain, keyData), t, 0);
451 keyData.fData64[0] = 3;
452 GrResourceKey key3(GrCacheID(domain, keyData), t, 0);
453
454 context->setResourceCacheLimits(5, 30000);
bsalomon8b79d232014-11-10 10:19:06 -0800455 GrResourceCache2* cache2 = context->getResourceCache2();
bsalomon71cb0c22014-11-14 12:10:14 -0800456 cache2->purgeAllUnlocked();
457 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
bsalomon8b79d232014-11-10 10:19:06 -0800458
459 // Add three resources to the cache.
460 TestResource* a = new TestResource(context->getGpu());
461 TestResource* b = new TestResource(context->getGpu());
462 TestResource* c = new TestResource(context->getGpu());
bsalomon71cb0c22014-11-14 12:10:14 -0800463 a->cacheAccess().setContentKey(key1);
464 b->cacheAccess().setContentKey(key2);
465 c->cacheAccess().setContentKey(key3);
bsalomon8b79d232014-11-10 10:19:06 -0800466 a->unref();
467 b->unref();
468 c->unref();
469
470 REPORTER_ASSERT(reporter, cache2->hasContentKey(key1));
471 REPORTER_ASSERT(reporter, cache2->hasContentKey(key2));
472 REPORTER_ASSERT(reporter, cache2->hasContentKey(key3));
473
474 // Invalidate two of the three, they should be purged and destroyed.
475 REPORTER_ASSERT(reporter, 3 == TestResource::NumAlive());
476 const GrResourceInvalidatedMessage msg1 = { key1 };
477 SkMessageBus<GrResourceInvalidatedMessage>::Post(msg1);
478 const GrResourceInvalidatedMessage msg2 = { key2 };
479 SkMessageBus<GrResourceInvalidatedMessage>::Post(msg2);
bsalomon6d4488c2014-11-11 07:27:16 -0800480#if 0 // Disabled until reimplemented in GrResourceCache2.
bsalomon71cb0c22014-11-14 12:10:14 -0800481 cache2->purgeAsNeeded();
bsalomon8b79d232014-11-10 10:19:06 -0800482 REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
483 REPORTER_ASSERT(reporter, !cache2->hasContentKey(key1));
484 REPORTER_ASSERT(reporter, !cache2->hasContentKey(key2));
485 REPORTER_ASSERT(reporter, cache2->hasContentKey(key3));
bsalomon6d4488c2014-11-11 07:27:16 -0800486#endif
bsalomon8b79d232014-11-10 10:19:06 -0800487
488 // Invalidate the third.
489 const GrResourceInvalidatedMessage msg3 = { key3 };
490 SkMessageBus<GrResourceInvalidatedMessage>::Post(msg3);
bsalomon6d4488c2014-11-11 07:27:16 -0800491#if 0 // Disabled until reimplemented in GrResourceCache2.
bsalomon71cb0c22014-11-14 12:10:14 -0800492 cache2->purgeAsNeeded();
bsalomon8b79d232014-11-10 10:19:06 -0800493 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
494 REPORTER_ASSERT(reporter, !cache2->hasContentKey(key3));
bsalomon6d4488c2014-11-11 07:27:16 -0800495#endif
bsalomon71cb0c22014-11-14 12:10:14 -0800496
497 cache2->purgeAllUnlocked();
498 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
499 REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
500 REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
bsalomon8b79d232014-11-10 10:19:06 -0800501}
502
bsalomon71cb0c22014-11-14 12:10:14 -0800503static void test_cache_chained_purge(skiatest::Reporter* reporter) {
bsalomon8b79d232014-11-10 10:19:06 -0800504 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
505 REPORTER_ASSERT(reporter, SkToBool(context));
506 if (NULL == context) {
507 return;
508 }
509
510 GrCacheID::Domain domain = GrCacheID::GenerateDomain();
511 GrCacheID::Key keyData;
512 memset(&keyData, 0, sizeof(keyData));
513 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
514
515 keyData.fData64[0] = 1;
516 GrResourceKey key1(GrCacheID(domain, keyData), t, 0);
517
518 keyData.fData64[0] = 2;
519 GrResourceKey key2(GrCacheID(domain, keyData), t, 0);
commit-bot@chromium.orgbd58feb2014-01-17 17:56:21 +0000520
521 {
bsalomon33435572014-11-05 14:47:41 -0800522 context->setResourceCacheLimits(3, 30000);
bsalomon71cb0c22014-11-14 12:10:14 -0800523 GrResourceCache2* cache2 = context->getResourceCache2();
524 cache2->purgeAllUnlocked();
525 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
commit-bot@chromium.orgbd58feb2014-01-17 17:56:21 +0000526
bsalomon820dd6c2014-11-05 12:09:45 -0800527 TestResource* a = new TestResource(context->getGpu());
528 TestResource* b = new TestResource(context->getGpu());
bsalomon71cb0c22014-11-14 12:10:14 -0800529 a->cacheAccess().setContentKey(key1);
530 b->cacheAccess().setContentKey(key2);
bsalomon820dd6c2014-11-05 12:09:45 -0800531
bsalomon71cb0c22014-11-14 12:10:14 -0800532 // Make a cycle
533 a->setUnrefWhenDestroyed(b);
534 b->setUnrefWhenDestroyed(a);
535
536 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
bsalomon33435572014-11-05 14:47:41 -0800537
538 a->unref();
539 b->unref();
bsalomon8b79d232014-11-10 10:19:06 -0800540
bsalomon33435572014-11-05 14:47:41 -0800541 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
bsalomon8b79d232014-11-10 10:19:06 -0800542
bsalomon71cb0c22014-11-14 12:10:14 -0800543 cache2->purgeAllUnlocked();
544 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
bsalomon8b79d232014-11-10 10:19:06 -0800545
bsalomon71cb0c22014-11-14 12:10:14 -0800546 // Break the cycle
547 a->setUnrefWhenDestroyed(NULL);
548 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
bsalomon33435572014-11-05 14:47:41 -0800549
bsalomon71cb0c22014-11-14 12:10:14 -0800550 cache2->purgeAllUnlocked();
bsalomon33435572014-11-05 14:47:41 -0800551 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
commit-bot@chromium.orgbd58feb2014-01-17 17:56:21 +0000552 }
553}
554
bsalomon8b79d232014-11-10 10:19:06 -0800555static void test_resource_size_changed(skiatest::Reporter* reporter) {
556 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
557 REPORTER_ASSERT(reporter, SkToBool(context));
558 if (NULL == context) {
559 return;
560 }
561
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000562 GrCacheID::Domain domain = GrCacheID::GenerateDomain();
563 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
564
565 GrCacheID::Key key1Data;
566 key1Data.fData64[0] = 0;
567 key1Data.fData64[1] = 0;
568 GrResourceKey key1(GrCacheID(domain, key1Data), t, 0);
569
570 GrCacheID::Key key2Data;
571 key2Data.fData64[0] = 1;
572 key2Data.fData64[1] = 0;
573 GrResourceKey key2(GrCacheID(domain, key2Data), t, 0);
574
575 // Test changing resources sizes (both increase & decrease).
576 {
bsalomon33435572014-11-05 14:47:41 -0800577 context->setResourceCacheLimits(3, 30000);
bsalomon8b79d232014-11-10 10:19:06 -0800578 GrResourceCache2* cache2 = context->getResourceCache2();
bsalomon71cb0c22014-11-14 12:10:14 -0800579 cache2->purgeAllUnlocked();
580 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000581
bsalomonc44be0e2014-07-25 07:32:33 -0700582 TestResource* a = new TestResource(context->getGpu());
bsalomon71cb0c22014-11-14 12:10:14 -0800583 a->cacheAccess().setContentKey(key1);
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000584 a->unref();
585
bsalomonc44be0e2014-07-25 07:32:33 -0700586 TestResource* b = new TestResource(context->getGpu());
bsalomon71cb0c22014-11-14 12:10:14 -0800587 b->cacheAccess().setContentKey(key2);
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000588 b->unref();
589
bsalomon71cb0c22014-11-14 12:10:14 -0800590 REPORTER_ASSERT(reporter, 200 == cache2->getResourceBytes());
591 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
bsalomon8b79d232014-11-10 10:19:06 -0800592 {
593 SkAutoTUnref<TestResource> find2(static_cast<TestResource*>(cache2->findAndRefContentResource(key2)));
594 find2->setSize(200);
595 SkAutoTUnref<TestResource> find1(static_cast<TestResource*>(cache2->findAndRefContentResource(key1)));
596 find1->setSize(50);
597 }
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000598
bsalomon71cb0c22014-11-14 12:10:14 -0800599 REPORTER_ASSERT(reporter, 250 == cache2->getResourceBytes());
600 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000601 }
602
603 // Test increasing a resources size beyond the cache budget.
604 {
bsalomon33435572014-11-05 14:47:41 -0800605 context->setResourceCacheLimits(2, 300);
bsalomon8b79d232014-11-10 10:19:06 -0800606 GrResourceCache2* cache2 = context->getResourceCache2();
bsalomon71cb0c22014-11-14 12:10:14 -0800607 cache2->purgeAllUnlocked();
608 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000609
bsalomon8b79d232014-11-10 10:19:06 -0800610 TestResource* a = new TestResource(context->getGpu());
611 a->setSize(100);
bsalomon71cb0c22014-11-14 12:10:14 -0800612 a->cacheAccess().setContentKey(key1);
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000613 a->unref();
614
bsalomon8b79d232014-11-10 10:19:06 -0800615 TestResource* b = new TestResource(context->getGpu());
616 b->setSize(100);
bsalomon71cb0c22014-11-14 12:10:14 -0800617 b->cacheAccess().setContentKey(key2);
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000618 b->unref();
619
bsalomon71cb0c22014-11-14 12:10:14 -0800620 REPORTER_ASSERT(reporter, 200 == cache2->getResourceBytes());
621 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000622
bsalomon8b79d232014-11-10 10:19:06 -0800623 {
624 SkAutoTUnref<TestResource> find2(static_cast<TestResource*>(cache2->findAndRefContentResource(key2)));
625 find2->setSize(201);
626 }
627 REPORTER_ASSERT(reporter, !cache2->hasContentKey(key1));
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000628
bsalomon71cb0c22014-11-14 12:10:14 -0800629 REPORTER_ASSERT(reporter, 201 == cache2->getResourceBytes());
630 REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000631 }
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +0000632}
633
bsalomon10e23ca2014-11-25 05:52:06 -0800634static void test_large_resource_count(skiatest::Reporter* reporter) {
635 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
636 REPORTER_ASSERT(reporter, SkToBool(context));
637 if (NULL == context) {
638 return;
639 }
640
641 static const int kResourceCnt = 2000;
642 // Set the cache size to double the resource count because we're going to create 2x that number
643 // resources, using two different key domains. Add a little slop to the bytes because we resize
644 // down to 1 byte after creating the resource.
645 context->setResourceCacheLimits(2 * kResourceCnt, 2 * kResourceCnt + 1000);
646 GrResourceCache2* cache2 = context->getResourceCache2();
647 cache2->purgeAllUnlocked();
648 SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
649
650 GrCacheID::Domain domain0 = GrCacheID::GenerateDomain();
651 GrCacheID::Domain domain1 = GrCacheID::GenerateDomain();
652 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
653
654 GrCacheID::Key keyData;
655 memset(&keyData, 0, sizeof(keyData));
656
657 for (int i = 0; i < kResourceCnt; ++i) {
658 TestResource* resource;
659 keyData.fData32[0] = i;
660
661 GrResourceKey key0(GrCacheID(domain0, keyData), t, 0);
662 resource = SkNEW_ARGS(TestResource, (context->getGpu()));
663 resource->cacheAccess().setContentKey(key0);
664 resource->setSize(1);
665 resource->unref();
666
667 GrResourceKey key1(GrCacheID(domain1, keyData), t, 0);
668 resource = SkNEW_ARGS(TestResource, (context->getGpu()));
669 resource->cacheAccess().setContentKey(key1);
670 resource->setSize(1);
671 resource->unref();
672 }
673
674 REPORTER_ASSERT(reporter, TestResource::NumAlive() == 2 * kResourceCnt);
675 REPORTER_ASSERT(reporter, cache2->getBudgetedResourceBytes() == 2 * kResourceCnt);
676 REPORTER_ASSERT(reporter, cache2->getBudgetedResourceCount() == 2 * kResourceCnt);
677 REPORTER_ASSERT(reporter, cache2->getResourceBytes() == 2 * kResourceCnt);
678 REPORTER_ASSERT(reporter, cache2->getResourceCount() == 2 * kResourceCnt);
679 for (int i = 0; i < kResourceCnt; ++i) {
680 keyData.fData32[0] = i;
681 GrResourceKey key0(GrCacheID(domain0, keyData), t, 0);
682 REPORTER_ASSERT(reporter, cache2->hasContentKey(key0));
683 GrResourceKey key1(GrCacheID(domain0, keyData), t, 0);
684 REPORTER_ASSERT(reporter, cache2->hasContentKey(key1));
685 }
686
687 cache2->purgeAllUnlocked();
688 REPORTER_ASSERT(reporter, TestResource::NumAlive() == 0);
689 REPORTER_ASSERT(reporter, cache2->getBudgetedResourceBytes() == 0);
690 REPORTER_ASSERT(reporter, cache2->getBudgetedResourceCount() == 0);
691 REPORTER_ASSERT(reporter, cache2->getResourceBytes() == 0);
692 REPORTER_ASSERT(reporter, cache2->getResourceCount() == 0);
693
694 for (int i = 0; i < kResourceCnt; ++i) {
695 keyData.fData32[0] = i;
696 GrResourceKey key0(GrCacheID(domain0, keyData), t, 0);
697 REPORTER_ASSERT(reporter, !cache2->hasContentKey(key0));
698 GrResourceKey key1(GrCacheID(domain0, keyData), t, 0);
699 REPORTER_ASSERT(reporter, !cache2->hasContentKey(key1));
700 }
701}
702
703
commit-bot@chromium.orgc6658042014-01-15 23:09:01 +0000704////////////////////////////////////////////////////////////////////////////////
tfarina@chromium.org4ee16bf2014-01-10 22:08:27 +0000705DEF_GPUTEST(ResourceCache, reporter, factory) {
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +0000706 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
707 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
708 if (!GrContextFactory::IsRenderingGLContext(glType)) {
709 continue;
710 }
711 GrContext* context = factory->get(glType);
bsalomonfdcf2c02014-11-05 12:30:32 -0800712 if (NULL == context) {
713 continue;
714 }
bsalomonf2703d82014-10-28 14:33:06 -0700715 GrSurfaceDesc desc;
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +0000716 desc.fConfig = kSkia8888_GrPixelConfig;
bsalomonf2703d82014-10-28 14:33:06 -0700717 desc.fFlags = kRenderTarget_GrSurfaceFlag;
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +0000718 desc.fWidth = gWidth;
719 desc.fHeight = gHeight;
reed69f6f002014-09-18 06:09:44 -0700720 SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight);
reed4a8126e2014-09-22 07:29:03 -0700721 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, info));
reed69f6f002014-09-18 06:09:44 -0700722 test_cache(reporter, context, surface->getCanvas());
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +0000723 }
bsalomon33435572014-11-05 14:47:41 -0800724
bsalomon8b79d232014-11-10 10:19:06 -0800725 // The below tests create their own mock contexts.
bsalomon71cb0c22014-11-14 12:10:14 -0800726 test_no_key(reporter);
bsalomon84c8e622014-11-17 09:33:27 -0800727 test_budgeting(reporter);
bsalomon8b79d232014-11-10 10:19:06 -0800728 test_duplicate_content_key(reporter);
729 test_duplicate_scratch_key(reporter);
bsalomon10e23ca2014-11-25 05:52:06 -0800730 test_remove_scratch_key(reporter);
bsalomon8b79d232014-11-10 10:19:06 -0800731 test_purge_invalidated(reporter);
bsalomon71cb0c22014-11-14 12:10:14 -0800732 test_cache_chained_purge(reporter);
bsalomon8b79d232014-11-10 10:19:06 -0800733 test_resource_size_changed(reporter);
bsalomon10e23ca2014-11-25 05:52:06 -0800734 test_large_resource_count(reporter);
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +0000735}
736
commit-bot@chromium.orgc28f5552013-08-08 22:55:21 +0000737#endif