Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/GpuLayerCacheTest.cpp

Issue 1406013006: Update Layer Hoisting to store its atlas texture in the resource cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix build Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #if SK_SUPPORT_GPU 8 #if SK_SUPPORT_GPU
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
11 #include "GrContextFactory.h" 11 #include "GrContextFactory.h"
12 #include "GrLayerCache.h" 12 #include "GrLayerCache.h"
13 #include "GrResourceCache.h"
13 #include "SkPictureRecorder.h" 14 #include "SkPictureRecorder.h"
14 #include "Test.h" 15 #include "Test.h"
15 16
16 class TestingAccess { 17 class TestingAccess {
17 public: 18 public:
19 static int NumPlots() {
20 return GrLayerCache::kNumPlotsX * GrLayerCache::kNumPlotsY;
21 }
22 static SkISize PlotSize() {
23 return SkISize::Make(GrLayerCache::kAtlasTextureWidth / GrLayerCache::kN umPlotsX,
24 GrLayerCache::kAtlasTextureHeight / GrLayerCache::k NumPlotsY);
25 }
26
27 static GrTexture* GetBackingTexture(GrLayerCache* cache) {
28 return cache->fAtlas->getTextureOrNull();
29 }
30
18 static int NumLayers(GrLayerCache* cache) { 31 static int NumLayers(GrLayerCache* cache) {
19 return cache->numLayers(); 32 return cache->numLayers();
20 } 33 }
21 static void Purge(GrLayerCache* cache, uint32_t pictureID) { 34 static void Purge(GrLayerCache* cache, uint32_t pictureID) {
22 cache->purge(pictureID); 35 cache->purge(pictureID);
23 } 36 }
24 static int Uses(GrCachedLayer* layer) { 37 static int Uses(GrCachedLayer* layer) {
25 return layer->uses(); 38 return layer->uses();
26 } 39 }
27 static GrCachedLayer* Find(GrLayerCache* cache, uint32_t pictureID, 40 static GrCachedLayer* Find(GrLayerCache* cache, uint32_t pictureID,
28 const SkMatrix& initialMat, 41 const SkMatrix& initialMat,
29 const int* key, int keySize) { 42 const int* key, int keySize) {
30 return cache->findLayer(pictureID, initialMat, key, keySize); 43 return cache->findLayer(pictureID, initialMat, key, keySize);
31 } 44 }
32 }; 45 };
33 46
34 // Add several layers to the cache 47 // Add several layers to the cache
35 static void create_layers(skiatest::Reporter* reporter, 48 static void create_layers(skiatest::Reporter* reporter,
36 GrLayerCache* cache, 49 GrLayerCache* cache,
37 const SkPicture& picture, 50 const SkPicture& picture,
38 int numToAdd, 51 int numToAdd,
39 int idOffset) { 52 int idOffset) {
40 53
41 for (int i = 0; i < numToAdd; ++i) { 54 for (int i = 0; i < numToAdd; ++i) {
42 int indices[1] = { idOffset+i+1 }; 55 int key[1] = { idOffset+i+1 };
43 GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(), 56 GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(),
44 idOffset+i+1, idOffset+i +2, 57 idOffset+i+1, idOffset+i +2,
45 SkIRect::MakeEmpty(), 58 SkIRect::MakeEmpty(),
46 SkIRect::MakeEmpty(), 59 SkIRect::MakeEmpty(),
47 SkMatrix::I(), 60 SkMatrix::I(),
48 indices, 1, 61 key, 1,
49 nullptr); 62 nullptr);
50 REPORTER_ASSERT(reporter, layer); 63 REPORTER_ASSERT(reporter, layer);
51 GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkM atrix::I(), 64 GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkM atrix::I(),
52 indices, 1); 65 key, 1);
53 REPORTER_ASSERT(reporter, temp == layer); 66 REPORTER_ASSERT(reporter, temp == layer);
54 67
55 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1); 68 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1);
56 69
57 REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID()); 70 REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID());
58 REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1); 71 REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1);
59 REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2); 72 REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2);
60 REPORTER_ASSERT(reporter, nullptr == layer->texture()); 73 REPORTER_ASSERT(reporter, nullptr == layer->texture());
61 REPORTER_ASSERT(reporter, nullptr == layer->paint()); 74 REPORTER_ASSERT(reporter, nullptr == layer->paint());
62 REPORTER_ASSERT(reporter, !layer->isAtlased()); 75 REPORTER_ASSERT(reporter, !layer->isAtlased());
63 } 76 }
64 } 77 }
65 78
66 static void lock_layer(skiatest::Reporter* reporter, 79 static void lock_layer(skiatest::Reporter* reporter,
67 GrLayerCache* cache, 80 GrLayerCache* cache,
68 GrCachedLayer* layer) { 81 GrCachedLayer* layer) {
69 // Make the layer 512x512 (so it can be atlased) 82 // Make each layer big enough to consume one whole plot in the atlas
70 GrSurfaceDesc desc; 83 GrSurfaceDesc desc;
71 desc.fWidth = 512; 84 desc.fWidth = TestingAccess::PlotSize().fWidth;
72 desc.fHeight = 512; 85 desc.fHeight = TestingAccess::PlotSize().fHeight;
73 desc.fConfig = kSkia8888_GrPixelConfig; 86 desc.fConfig = kSkia8888_GrPixelConfig;
74 87
75 bool needsRerendering; 88 bool needsRerendering;
76 bool inAtlas = cache->tryToAtlas(layer, desc, &needsRerendering); 89 bool inAtlas = cache->tryToAtlas(layer, desc, &needsRerendering);
77 if (!inAtlas) { 90 if (!inAtlas) {
78 cache->lock(layer, desc, &needsRerendering); 91 cache->lock(layer, desc, &needsRerendering);
79 } 92 }
80 REPORTER_ASSERT(reporter, needsRerendering); 93 REPORTER_ASSERT(reporter, needsRerendering);
81 94
82 cache->lock(layer, desc, &needsRerendering); 95 cache->lock(layer, desc, &needsRerendering);
83 REPORTER_ASSERT(reporter, !needsRerendering); 96 REPORTER_ASSERT(reporter, !needsRerendering);
84 97
85 REPORTER_ASSERT(reporter, layer->texture()); 98 REPORTER_ASSERT(reporter, layer->texture());
86 REPORTER_ASSERT(reporter, layer->locked()); 99 REPORTER_ASSERT(reporter, layer->locked());
87 100
88 cache->addUse(layer); 101 cache->addUse(layer);
89 102
90 REPORTER_ASSERT(reporter, 1 == TestingAccess::Uses(layer)); 103 REPORTER_ASSERT(reporter, 1 == TestingAccess::Uses(layer));
91 } 104 }
92 105
93 // This test case exercises the public API of the GrLayerCache class. 106 // This test case exercises the public API of the GrLayerCache class.
94 // In particular it checks its interaction with the resource cache (w.r.t. 107 // In particular it checks its interaction with the resource cache (w.r.t.
95 // locking & unlocking textures). 108 // locking & unlocking textures).
96 // TODO: need to add checks on VRAM usage! 109 // TODO: need to add checks on VRAM usage!
97 DEF_GPUTEST(GpuLayerCache, reporter, factory) { 110 DEF_GPUTEST(GpuLayerCache, reporter, factory) {
98 static const int kInitialNumLayers = 5; 111 // Add one more layer than can fit in the atlas
112 static const int kInitialNumLayers = TestingAccess::NumPlots() + 1;
99 113
100 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { 114 #if GR_CACHE_STATS
115 GrResourceCache::Stats stats;
116 #endif
117
118 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
101 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext Type) i; 119 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext Type) i;
102 120
103 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { 121 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
104 continue; 122 continue;
105 } 123 }
106 124
107 GrContext* context = factory->get(glCtxType); 125 GrContext* context = factory->get(glCtxType);
108 126
109 if (nullptr == context) { 127 if (nullptr == context) {
110 continue; 128 continue;
111 } 129 }
112 130
113 SkPictureRecorder recorder; 131 SkAutoTUnref<const SkPicture> picture;
114 SkCanvas* c = recorder.beginRecording(1, 1); 132
115 // Draw something, anything, to prevent an empty-picture optimizatio n, 133 {
116 // which is a singleton and never purged. 134 SkPictureRecorder recorder;
117 c->drawRect(SkRect::MakeWH(1,1), SkPaint()); 135 SkCanvas* c = recorder.beginRecording(1, 1);
118 SkAutoTUnref<const SkPicture> picture(recorder.endRecording()); 136 // Draw something, anything, to prevent an empty-picture optimiz ation,
137 // which is a singleton and never purged.
138 c->drawRect(SkRect::MakeWH(1,1), SkPaint());
139 picture.reset(recorder.endRecording());
140 }
141
142 GrResourceCache* resourceCache = context->getResourceCache();
119 143
120 GrLayerCache cache(context); 144 GrLayerCache cache(context);
121 145
122 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 146 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
123 147
124 for (int i = 0; i < kInitialNumLayers; ++i) { 148 for (int i = 0; i < kInitialNumLayers; ++i) {
125 int indices[1] = { i + 1 }; 149 int key[1] = { i + 1 };
126 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 150 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
127 indices, 1); 151 key, 1);
128 REPORTER_ASSERT(reporter, layer); 152 REPORTER_ASSERT(reporter, layer);
129 153
130 lock_layer(reporter, &cache, layer); 154 lock_layer(reporter, &cache, layer);
131 155
132 // The first 4 layers should be in the atlas (and thus have non-empt y 156 #if GR_CACHE_STATS
133 // rects) 157 resourceCache->getStats(&stats);
134 if (i < 4) { 158 #endif
159
160 // The first 4 layers should be in the atlas (and thus have non-empt y rects)
161 if (i < TestingAccess::NumPlots()) {
135 REPORTER_ASSERT(reporter, layer->isAtlased()); 162 REPORTER_ASSERT(reporter, layer->isAtlased());
163 #if GR_CACHE_STATS
164 REPORTER_ASSERT(reporter, 1 == stats.fTotal);
165 #endif
136 } else { 166 } else {
137 // The 5th layer couldn't fit in the atlas 167 // The 5th layer couldn't fit in the atlas
138 REPORTER_ASSERT(reporter, !layer->isAtlased()); 168 REPORTER_ASSERT(reporter, !layer->isAtlased());
169 #if GR_CACHE_STATS
170 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
171 #endif
139 } 172 }
140 } 173 }
141 174
142 // Unlock the textures 175 // Unlock the textures
143 for (int i = 0; i < kInitialNumLayers; ++i) { 176 for (int i = 0; i < kInitialNumLayers; ++i) {
144 int indices[1] = { i+1 }; 177 int key[1] = { i+1 };
145 178
146 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 179 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
147 indices, 1); 180 key, 1);
148 REPORTER_ASSERT(reporter, layer); 181 REPORTER_ASSERT(reporter, layer);
149 cache.removeUse(layer); 182 cache.removeUse(layer);
150 } 183 }
151 184
185 #if GR_CACHE_STATS
186 resourceCache->getStats(&stats);
187 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
188 // The floating layer is purgeable the cache is not
189 REPORTER_ASSERT(reporter, 1 == stats.fNumPurgeable);
190 REPORTER_ASSERT(reporter, 1 == stats.fNumNonPurgeable);
191 #endif
192
152 for (int i = 0; i < kInitialNumLayers; ++i) { 193 for (int i = 0; i < kInitialNumLayers; ++i) {
153 int indices[1] = { i+1 }; 194 int key[1] = { i+1 };
154 195
155 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 196 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
156 indices, 1); 197 key, 1);
157 REPORTER_ASSERT(reporter, layer); 198 REPORTER_ASSERT(reporter, layer);
158 199
159 // All the layers should be unlocked 200 // All the layers should be unlocked
160 REPORTER_ASSERT(reporter, !layer->locked()); 201 REPORTER_ASSERT(reporter, !layer->locked());
161 202
162 // When hoisted layers aren't cached they are aggressively removed 203 // When hoisted layers aren't cached they are aggressively removed
163 // from the atlas 204 // from the atlas
164 #if GR_CACHE_HOISTED_LAYERS 205 #if GR_CACHE_HOISTED_LAYERS
165 // The first 4 layers should still be in the atlas. 206 // The first 4 layers should still be in the atlas.
166 if (i < 4) { 207 if (i < 4) {
167 REPORTER_ASSERT(reporter, layer->texture()); 208 REPORTER_ASSERT(reporter, layer->texture());
168 REPORTER_ASSERT(reporter, layer->isAtlased()); 209 REPORTER_ASSERT(reporter, layer->isAtlased());
169 } else { 210 } else {
170 #endif 211 #endif
171 // The final layer should not be atlased. 212 // The final layer should not be atlased.
172 REPORTER_ASSERT(reporter, nullptr == layer->texture()); 213 REPORTER_ASSERT(reporter, nullptr == layer->texture());
173 REPORTER_ASSERT(reporter, !layer->isAtlased()); 214 REPORTER_ASSERT(reporter, !layer->isAtlased());
174 #if GR_CACHE_HOISTED_LAYERS 215 #if GR_CACHE_HOISTED_LAYERS
175 } 216 }
176 #endif 217 #endif
177 } 218 }
178 219
220 // Let go of the backing texture
221 cache.end();
222 REPORTER_ASSERT(reporter, nullptr == TestingAccess::GetBackingTexture(&c ache));
223
224 #if GR_CACHE_STATS
225 resourceCache->getStats(&stats);
226 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
227 // Now both the floater and the atlas are purgeable
228 REPORTER_ASSERT(reporter, 2 == stats.fNumPurgeable);
229 #endif
230
231 // re-attach to the backing texture
232 cache.begin();
233 REPORTER_ASSERT(reporter, TestingAccess::GetBackingTexture(&cache));
234
235 #if GR_CACHE_STATS
236 resourceCache->getStats(&stats);
237 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
238 // The atlas is restored to being non-purgeable
239 REPORTER_ASSERT(reporter, 1 == stats.fNumPurgeable);
240 REPORTER_ASSERT(reporter, 1 == stats.fNumNonPurgeable);
241 #endif
242
179 { 243 {
180 int indices[1] = { kInitialNumLayers+1 }; 244 int key[1] = { kInitialNumLayers+1 };
181 245
182 // Add an additional layer. Since all the layers are unlocked this 246 // Add an additional layer. Since all the layers are unlocked this
183 // will force out the first atlased layer 247 // will force out the first atlased layer
184 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers); 248 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers);
185 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 249 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
186 indices, 1); 250 key, 1);
187 REPORTER_ASSERT(reporter, layer); 251 REPORTER_ASSERT(reporter, layer);
188 252
189 lock_layer(reporter, &cache, layer); 253 lock_layer(reporter, &cache, layer);
190 cache.removeUse(layer); 254 cache.removeUse(layer);
191 } 255 }
192 256
193 for (int i = 0; i < kInitialNumLayers+1; ++i) { 257 for (int i = 0; i < kInitialNumLayers+1; ++i) {
194 int indices[1] = { i+1 }; 258 int key[1] = { i+1 };
195 259
196 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 260 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
197 indices, 1); 261 key, 1);
198 #if GR_CACHE_HOISTED_LAYERS 262 #if GR_CACHE_HOISTED_LAYERS
199 // 3 old layers plus the new one should be in the atlas. 263 // 3 old layers plus the new one should be in the atlas.
200 if (1 == i || 2 == i || 3 == i || 5 == i) { 264 if (1 == i || 2 == i || 3 == i || 5 == i) {
201 REPORTER_ASSERT(reporter, layer); 265 REPORTER_ASSERT(reporter, layer);
202 REPORTER_ASSERT(reporter, !layer->locked()); 266 REPORTER_ASSERT(reporter, !layer->locked());
203 REPORTER_ASSERT(reporter, layer->texture()); 267 REPORTER_ASSERT(reporter, layer->texture());
204 REPORTER_ASSERT(reporter, layer->isAtlased()); 268 REPORTER_ASSERT(reporter, layer->isAtlased());
205 } else if (4 == i) { 269 } else if (4 == i) {
206 #endif 270 #endif
207 // The one that was never atlased should still be around 271 // The one that was never atlased should still be around
208 REPORTER_ASSERT(reporter, layer); 272 REPORTER_ASSERT(reporter, layer);
209 273
210 REPORTER_ASSERT(reporter, nullptr == layer->texture()); 274 REPORTER_ASSERT(reporter, nullptr == layer->texture());
211 REPORTER_ASSERT(reporter, !layer->isAtlased()); 275 REPORTER_ASSERT(reporter, !layer->isAtlased());
212 #if GR_CACHE_HOISTED_LAYERS 276 #if GR_CACHE_HOISTED_LAYERS
213 } else { 277 } else {
214 // The one bumped out of the atlas (i.e., 0) should be gone 278 // The one bumped out of the atlas (i.e., 0) should be gone
215 REPORTER_ASSERT(reporter, nullptr == layer); 279 REPORTER_ASSERT(reporter, nullptr == layer);
216 } 280 }
217 #endif 281 #endif
218 } 282 }
219 283
220 //-------------------------------------------------------------------- 284 //--------------------------------------------------------------------
221 // Free them all SkGpuDevice-style. This will not free up the 285 // Free them all SkGpuDevice-style. This will not free up the
222 // atlas' texture but will eliminate all the layers. 286 // atlas' texture but will eliminate all the layers.
223 TestingAccess::Purge(&cache, picture->uniqueID()); 287 TestingAccess::Purge(&cache, picture->uniqueID());
224 288
225 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 289 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
226 // TODO: add VRAM/resource cache check here 290
291 #if GR_CACHE_STATS
292 resourceCache->getStats(&stats);
293 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
294 // Atlas isn't purgeable
295 REPORTER_ASSERT(reporter, 1 == stats.fNumPurgeable);
296 REPORTER_ASSERT(reporter, 1 == stats.fNumNonPurgeable);
297 #endif
227 298
228 //-------------------------------------------------------------------- 299 //--------------------------------------------------------------------
229 // Test out the GrContext-style purge. This should remove all the layers 300 // Test out the GrContext-style purge. This should remove all the layers
230 // and the atlas. 301 // and the atlas.
231 // Re-create the layers 302 // Re-create the layers
232 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 303 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
233 304
234 // Free them again GrContext-style. This should free up everything. 305 // Free them again GrContext-style. This should free up everything.
235 cache.freeAll(); 306 cache.freeAll();
236 307
237 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 308 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
238 // TODO: add VRAM/resource cache check here 309
310 REPORTER_ASSERT(reporter, nullptr == TestingAccess::GetBackingTexture(&c ache));
311
312 #if GR_CACHE_STATS
313 resourceCache->getStats(&stats);
314 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
315 REPORTER_ASSERT(reporter, 2 == stats.fNumPurgeable);
316 #endif
317
318 // Purge the resource cache ...
319 resourceCache->purgeAllUnlocked();
320
321 #if GR_CACHE_STATS
322 resourceCache->getStats(&stats);
323 REPORTER_ASSERT(reporter, 0 == stats.fTotal);
324 #endif
325
326 // and try to re-attach to the backing texture. This should fail
327 cache.begin();
328 REPORTER_ASSERT(reporter, nullptr == TestingAccess::GetBackingTexture(&c ache));
239 329
240 //-------------------------------------------------------------------- 330 //--------------------------------------------------------------------
241 // Test out the MessageBus-style purge. This will not free the atlas 331 // Test out the MessageBus-style purge. This will not free the atlas
242 // but should eliminate the free-floating layers. 332 // but should eliminate the free-floating layers.
243 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 333 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
244 334
335 // Allocate/use the layers
336 for (int i = 0; i < kInitialNumLayers; ++i) {
337 int key[1] = { i + 1 };
338 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
339 key, 1);
340 REPORTER_ASSERT(reporter, layer);
341
342 lock_layer(reporter, &cache, layer);
343 }
344
345 #if GR_CACHE_STATS
346 resourceCache->getStats(&stats);
347 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
348 REPORTER_ASSERT(reporter, 2 == stats.fNumNonPurgeable);
349 #endif
350
351 // Unlock the textures
352 for (int i = 0; i < kInitialNumLayers; ++i) {
353 int key[1] = { i+1 };
354
355 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
356 key, 1);
357 REPORTER_ASSERT(reporter, layer);
358 cache.removeUse(layer);
359 }
360
245 picture.reset(nullptr); 361 picture.reset(nullptr);
246 cache.processDeletedPictures(); 362 cache.processDeletedPictures();
247 363
248 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 364 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
249 // TODO: add VRAM/resource cache check here 365
366 #if GR_CACHE_STATS
367 resourceCache->getStats(&stats);
368 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
369 REPORTER_ASSERT(reporter, 1 == stats.fNumPurgeable);
370 REPORTER_ASSERT(reporter, 1 == stats.fNumNonPurgeable);
371 #endif
372
373 cache.end();
374
375 #if GR_CACHE_STATS
376 resourceCache->getStats(&stats);
377 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
378 REPORTER_ASSERT(reporter, 2 == stats.fNumPurgeable);
379 #endif
250 } 380 }
251 } 381 }
252 382
253 #endif 383 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698