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

Side by Side Diff: tests/GpuLayerCacheTest.cpp

Issue 1413483004: Revert of Update Layer Hoisting to store its atlas texture in the resource cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
14 #include "SkPictureRecorder.h" 13 #include "SkPictureRecorder.h"
15 #include "Test.h" 14 #include "Test.h"
16 15
17 class TestingAccess { 16 class TestingAccess {
18 public: 17 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
31 static int NumLayers(GrLayerCache* cache) { 18 static int NumLayers(GrLayerCache* cache) {
32 return cache->numLayers(); 19 return cache->numLayers();
33 } 20 }
34 static void Purge(GrLayerCache* cache, uint32_t pictureID) { 21 static void Purge(GrLayerCache* cache, uint32_t pictureID) {
35 cache->purge(pictureID); 22 cache->purge(pictureID);
36 } 23 }
37 static int Uses(GrCachedLayer* layer) { 24 static int Uses(GrCachedLayer* layer) {
38 return layer->uses(); 25 return layer->uses();
39 } 26 }
40 static GrCachedLayer* Find(GrLayerCache* cache, uint32_t pictureID, 27 static GrCachedLayer* Find(GrLayerCache* cache, uint32_t pictureID,
41 const SkMatrix& initialMat, 28 const SkMatrix& initialMat,
42 const int* key, int keySize) { 29 const int* key, int keySize) {
43 return cache->findLayer(pictureID, initialMat, key, keySize); 30 return cache->findLayer(pictureID, initialMat, key, keySize);
44 } 31 }
45 }; 32 };
46 33
47 // Add several layers to the cache 34 // Add several layers to the cache
48 static void create_layers(skiatest::Reporter* reporter, 35 static void create_layers(skiatest::Reporter* reporter,
49 GrLayerCache* cache, 36 GrLayerCache* cache,
50 const SkPicture& picture, 37 const SkPicture& picture,
51 int numToAdd, 38 int numToAdd,
52 int idOffset) { 39 int idOffset) {
53 40
54 for (int i = 0; i < numToAdd; ++i) { 41 for (int i = 0; i < numToAdd; ++i) {
55 int key[1] = { idOffset+i+1 }; 42 int indices[1] = { idOffset+i+1 };
56 GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(), 43 GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(),
57 idOffset+i+1, idOffset+i +2, 44 idOffset+i+1, idOffset+i +2,
58 SkIRect::MakeEmpty(), 45 SkIRect::MakeEmpty(),
59 SkIRect::MakeEmpty(), 46 SkIRect::MakeEmpty(),
60 SkMatrix::I(), 47 SkMatrix::I(),
61 key, 1, 48 indices, 1,
62 nullptr); 49 nullptr);
63 REPORTER_ASSERT(reporter, layer); 50 REPORTER_ASSERT(reporter, layer);
64 GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkM atrix::I(), 51 GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkM atrix::I(),
65 key, 1); 52 indices, 1);
66 REPORTER_ASSERT(reporter, temp == layer); 53 REPORTER_ASSERT(reporter, temp == layer);
67 54
68 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1); 55 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1);
69 56
70 REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID()); 57 REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID());
71 REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1); 58 REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1);
72 REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2); 59 REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2);
73 REPORTER_ASSERT(reporter, nullptr == layer->texture()); 60 REPORTER_ASSERT(reporter, nullptr == layer->texture());
74 REPORTER_ASSERT(reporter, nullptr == layer->paint()); 61 REPORTER_ASSERT(reporter, nullptr == layer->paint());
75 REPORTER_ASSERT(reporter, !layer->isAtlased()); 62 REPORTER_ASSERT(reporter, !layer->isAtlased());
76 } 63 }
77 } 64 }
78 65
79 static void lock_layer(skiatest::Reporter* reporter, 66 static void lock_layer(skiatest::Reporter* reporter,
80 GrLayerCache* cache, 67 GrLayerCache* cache,
81 GrCachedLayer* layer) { 68 GrCachedLayer* layer) {
82 // Make each layer big enough to consume one whole plot in the atlas 69 // Make the layer 512x512 (so it can be atlased)
83 GrSurfaceDesc desc; 70 GrSurfaceDesc desc;
84 desc.fWidth = TestingAccess::PlotSize().fWidth; 71 desc.fWidth = 512;
85 desc.fHeight = TestingAccess::PlotSize().fHeight; 72 desc.fHeight = 512;
86 desc.fConfig = kSkia8888_GrPixelConfig; 73 desc.fConfig = kSkia8888_GrPixelConfig;
87 74
88 bool needsRerendering; 75 bool needsRerendering;
89 bool inAtlas = cache->tryToAtlas(layer, desc, &needsRerendering); 76 bool inAtlas = cache->tryToAtlas(layer, desc, &needsRerendering);
90 if (!inAtlas) { 77 if (!inAtlas) {
91 cache->lock(layer, desc, &needsRerendering); 78 cache->lock(layer, desc, &needsRerendering);
92 } 79 }
93 REPORTER_ASSERT(reporter, needsRerendering); 80 REPORTER_ASSERT(reporter, needsRerendering);
94 81
95 cache->lock(layer, desc, &needsRerendering); 82 cache->lock(layer, desc, &needsRerendering);
96 REPORTER_ASSERT(reporter, !needsRerendering); 83 REPORTER_ASSERT(reporter, !needsRerendering);
97 84
98 REPORTER_ASSERT(reporter, layer->texture()); 85 REPORTER_ASSERT(reporter, layer->texture());
99 REPORTER_ASSERT(reporter, layer->locked()); 86 REPORTER_ASSERT(reporter, layer->locked());
100 87
101 cache->addUse(layer); 88 cache->addUse(layer);
102 89
103 REPORTER_ASSERT(reporter, 1 == TestingAccess::Uses(layer)); 90 REPORTER_ASSERT(reporter, 1 == TestingAccess::Uses(layer));
104 } 91 }
105 92
106 // This test case exercises the public API of the GrLayerCache class. 93 // This test case exercises the public API of the GrLayerCache class.
107 // In particular it checks its interaction with the resource cache (w.r.t. 94 // In particular it checks its interaction with the resource cache (w.r.t.
108 // locking & unlocking textures). 95 // locking & unlocking textures).
109 // TODO: need to add checks on VRAM usage! 96 // TODO: need to add checks on VRAM usage!
110 DEF_GPUTEST(GpuLayerCache, reporter, factory) { 97 DEF_GPUTEST(GpuLayerCache, reporter, factory) {
111 // Add one more layer than can fit in the atlas 98 static const int kInitialNumLayers = 5;
112 static const int kInitialNumLayers = TestingAccess::NumPlots() + 1;
113 99
114 #if GR_CACHE_STATS 100 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
115 GrResourceCache::Stats stats;
116 #endif
117
118 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
119 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext Type) i; 101 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext Type) i;
120 102
121 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { 103 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
122 continue; 104 continue;
123 } 105 }
124 106
125 GrContext* context = factory->get(glCtxType); 107 GrContext* context = factory->get(glCtxType);
126 108
127 if (nullptr == context) { 109 if (nullptr == context) {
128 continue; 110 continue;
129 } 111 }
130 112
131 SkAutoTUnref<const SkPicture> picture; 113 SkPictureRecorder recorder;
132 114 SkCanvas* c = recorder.beginRecording(1, 1);
133 { 115 // Draw something, anything, to prevent an empty-picture optimizatio n,
134 SkPictureRecorder recorder; 116 // which is a singleton and never purged.
135 SkCanvas* c = recorder.beginRecording(1, 1); 117 c->drawRect(SkRect::MakeWH(1,1), SkPaint());
136 // Draw something, anything, to prevent an empty-picture optimiz ation, 118 SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
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();
143 119
144 GrLayerCache cache(context); 120 GrLayerCache cache(context);
145 121
146 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 122 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
147 123
148 for (int i = 0; i < kInitialNumLayers; ++i) { 124 for (int i = 0; i < kInitialNumLayers; ++i) {
149 int key[1] = { i + 1 }; 125 int indices[1] = { i + 1 };
150 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 126 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
151 key, 1); 127 indices, 1);
152 REPORTER_ASSERT(reporter, layer); 128 REPORTER_ASSERT(reporter, layer);
153 129
154 lock_layer(reporter, &cache, layer); 130 lock_layer(reporter, &cache, layer);
155 131
156 #if GR_CACHE_STATS 132 // The first 4 layers should be in the atlas (and thus have non-empt y
157 resourceCache->getStats(&stats); 133 // rects)
158 #endif 134 if (i < 4) {
159
160 // The first 4 layers should be in the atlas (and thus have non-empt y rects)
161 if (i < TestingAccess::NumPlots()) {
162 REPORTER_ASSERT(reporter, layer->isAtlased()); 135 REPORTER_ASSERT(reporter, layer->isAtlased());
163 #if GR_CACHE_STATS
164 REPORTER_ASSERT(reporter, 1 == stats.fTotal);
165 #endif
166 } else { 136 } else {
167 // The 5th layer couldn't fit in the atlas 137 // The 5th layer couldn't fit in the atlas
168 REPORTER_ASSERT(reporter, !layer->isAtlased()); 138 REPORTER_ASSERT(reporter, !layer->isAtlased());
169 #if GR_CACHE_STATS
170 REPORTER_ASSERT(reporter, 2 == stats.fTotal);
171 #endif
172 } 139 }
173 } 140 }
174 141
175 // Unlock the textures 142 // Unlock the textures
176 for (int i = 0; i < kInitialNumLayers; ++i) { 143 for (int i = 0; i < kInitialNumLayers; ++i) {
177 int key[1] = { i+1 }; 144 int indices[1] = { i+1 };
178 145
179 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 146 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
180 key, 1); 147 indices, 1);
181 REPORTER_ASSERT(reporter, layer); 148 REPORTER_ASSERT(reporter, layer);
182 cache.removeUse(layer); 149 cache.removeUse(layer);
183 } 150 }
184 151
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
193 for (int i = 0; i < kInitialNumLayers; ++i) { 152 for (int i = 0; i < kInitialNumLayers; ++i) {
194 int key[1] = { i+1 }; 153 int indices[1] = { i+1 };
195 154
196 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 155 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
197 key, 1); 156 indices, 1);
198 REPORTER_ASSERT(reporter, layer); 157 REPORTER_ASSERT(reporter, layer);
199 158
200 // All the layers should be unlocked 159 // All the layers should be unlocked
201 REPORTER_ASSERT(reporter, !layer->locked()); 160 REPORTER_ASSERT(reporter, !layer->locked());
202 161
203 // When hoisted layers aren't cached they are aggressively removed 162 // When hoisted layers aren't cached they are aggressively removed
204 // from the atlas 163 // from the atlas
205 #if GR_CACHE_HOISTED_LAYERS 164 #if GR_CACHE_HOISTED_LAYERS
206 // The first 4 layers should still be in the atlas. 165 // The first 4 layers should still be in the atlas.
207 if (i < 4) { 166 if (i < 4) {
208 REPORTER_ASSERT(reporter, layer->texture()); 167 REPORTER_ASSERT(reporter, layer->texture());
209 REPORTER_ASSERT(reporter, layer->isAtlased()); 168 REPORTER_ASSERT(reporter, layer->isAtlased());
210 } else { 169 } else {
211 #endif 170 #endif
212 // The final layer should not be atlased. 171 // The final layer should not be atlased.
213 REPORTER_ASSERT(reporter, nullptr == layer->texture()); 172 REPORTER_ASSERT(reporter, nullptr == layer->texture());
214 REPORTER_ASSERT(reporter, !layer->isAtlased()); 173 REPORTER_ASSERT(reporter, !layer->isAtlased());
215 #if GR_CACHE_HOISTED_LAYERS 174 #if GR_CACHE_HOISTED_LAYERS
216 } 175 }
217 #endif 176 #endif
218 } 177 }
219 178
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
243 { 179 {
244 int key[1] = { kInitialNumLayers+1 }; 180 int indices[1] = { kInitialNumLayers+1 };
245 181
246 // Add an additional layer. Since all the layers are unlocked this 182 // Add an additional layer. Since all the layers are unlocked this
247 // will force out the first atlased layer 183 // will force out the first atlased layer
248 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers); 184 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers);
249 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 185 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
250 key, 1); 186 indices, 1);
251 REPORTER_ASSERT(reporter, layer); 187 REPORTER_ASSERT(reporter, layer);
252 188
253 lock_layer(reporter, &cache, layer); 189 lock_layer(reporter, &cache, layer);
254 cache.removeUse(layer); 190 cache.removeUse(layer);
255 } 191 }
256 192
257 for (int i = 0; i < kInitialNumLayers+1; ++i) { 193 for (int i = 0; i < kInitialNumLayers+1; ++i) {
258 int key[1] = { i+1 }; 194 int indices[1] = { i+1 };
259 195
260 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(), 196 GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID (), SkMatrix::I(),
261 key, 1); 197 indices, 1);
262 #if GR_CACHE_HOISTED_LAYERS 198 #if GR_CACHE_HOISTED_LAYERS
263 // 3 old layers plus the new one should be in the atlas. 199 // 3 old layers plus the new one should be in the atlas.
264 if (1 == i || 2 == i || 3 == i || 5 == i) { 200 if (1 == i || 2 == i || 3 == i || 5 == i) {
265 REPORTER_ASSERT(reporter, layer); 201 REPORTER_ASSERT(reporter, layer);
266 REPORTER_ASSERT(reporter, !layer->locked()); 202 REPORTER_ASSERT(reporter, !layer->locked());
267 REPORTER_ASSERT(reporter, layer->texture()); 203 REPORTER_ASSERT(reporter, layer->texture());
268 REPORTER_ASSERT(reporter, layer->isAtlased()); 204 REPORTER_ASSERT(reporter, layer->isAtlased());
269 } else if (4 == i) { 205 } else if (4 == i) {
270 #endif 206 #endif
271 // The one that was never atlased should still be around 207 // The one that was never atlased should still be around
272 REPORTER_ASSERT(reporter, layer); 208 REPORTER_ASSERT(reporter, layer);
273 209
274 REPORTER_ASSERT(reporter, nullptr == layer->texture()); 210 REPORTER_ASSERT(reporter, nullptr == layer->texture());
275 REPORTER_ASSERT(reporter, !layer->isAtlased()); 211 REPORTER_ASSERT(reporter, !layer->isAtlased());
276 #if GR_CACHE_HOISTED_LAYERS 212 #if GR_CACHE_HOISTED_LAYERS
277 } else { 213 } else {
278 // The one bumped out of the atlas (i.e., 0) should be gone 214 // The one bumped out of the atlas (i.e., 0) should be gone
279 REPORTER_ASSERT(reporter, nullptr == layer); 215 REPORTER_ASSERT(reporter, nullptr == layer);
280 } 216 }
281 #endif 217 #endif
282 } 218 }
283 219
284 //-------------------------------------------------------------------- 220 //--------------------------------------------------------------------
285 // Free them all SkGpuDevice-style. This will not free up the 221 // Free them all SkGpuDevice-style. This will not free up the
286 // atlas' texture but will eliminate all the layers. 222 // atlas' texture but will eliminate all the layers.
287 TestingAccess::Purge(&cache, picture->uniqueID()); 223 TestingAccess::Purge(&cache, picture->uniqueID());
288 224
289 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 225 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
290 226 // TODO: add VRAM/resource cache check here
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
298 227
299 //-------------------------------------------------------------------- 228 //--------------------------------------------------------------------
300 // Test out the GrContext-style purge. This should remove all the layers 229 // Test out the GrContext-style purge. This should remove all the layers
301 // and the atlas. 230 // and the atlas.
302 // Re-create the layers 231 // Re-create the layers
303 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 232 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
304 233
305 // Free them again GrContext-style. This should free up everything. 234 // Free them again GrContext-style. This should free up everything.
306 cache.freeAll(); 235 cache.freeAll();
307 236
308 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 237 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
309 238 // TODO: add VRAM/resource cache check here
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));
329 239
330 //-------------------------------------------------------------------- 240 //--------------------------------------------------------------------
331 // Test out the MessageBus-style purge. This will not free the atlas 241 // Test out the MessageBus-style purge. This will not free the atlas
332 // but should eliminate the free-floating layers. 242 // but should eliminate the free-floating layers.
333 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 243 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
334 244
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
361 picture.reset(nullptr); 245 picture.reset(nullptr);
362 cache.processDeletedPictures(); 246 cache.processDeletedPictures();
363 247
364 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 248 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
365 249 // TODO: add VRAM/resource cache check here
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
380 } 250 }
381 } 251 }
382 252
383 #endif 253 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | tests/RecordReplaceDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698