robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | |
| 8 | #if SK_SUPPORT_GPU |
| 9 | |
| 10 | #include "GrContext.h" |
| 11 | #include "GrContextFactory.h" |
| 12 | #include "GrLayerCache.h" |
Robert Phillips | cfaeec4 | 2014-07-13 12:00:50 -0400 | [diff] [blame] | 13 | #include "SkPictureRecorder.h" |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 14 | #include "Test.h" |
| 15 | |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 16 | class TestingAccess { |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 17 | public: |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 18 | static unsigned NumLayers(GrLayerCache* cache) { |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 19 | return cache->numLayers(); |
| 20 | } |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 21 | static void Purge(GrLayerCache* cache, uint32_t pictureID) { |
| 22 | cache->purge(pictureID); |
| 23 | } |
robertphillips | 7bb9ed7 | 2014-10-10 11:38:29 -0700 | [diff] [blame] | 24 | static int Uses(GrCachedLayer* layer) { |
| 25 | return layer->uses(); |
| 26 | } |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 27 | static GrCachedLayer* Find(GrLayerCache* cache, uint32_t pictureID, |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 28 | const SkMatrix& initialMat, |
| 29 | const unsigned* key, int keySize) { |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 30 | return cache->findLayer(pictureID, initialMat, key, keySize); |
| 31 | } |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | // Add several layers to the cache |
| 35 | static void create_layers(skiatest::Reporter* reporter, |
| 36 | GrLayerCache* cache, |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 37 | const SkPicture& picture, |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 38 | unsigned numToAdd, |
| 39 | unsigned idOffset) { |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 40 | |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 41 | for (unsigned i = 0; i < numToAdd; ++i) { |
| 42 | unsigned indices[1] = { idOffset+i+1 }; |
robertphillips | 6f294af | 2014-08-18 08:50:03 -0700 | [diff] [blame] | 43 | GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(), |
robertphillips | 0c42332 | 2014-07-31 11:02:38 -0700 | [diff] [blame] | 44 | idOffset+i+1, idOffset+i+2, |
robertphillips | 3aac6e0 | 2014-10-20 08:52:40 -0700 | [diff] [blame] | 45 | SkIRect::MakeEmpty(), |
robertphillips | 478dd72 | 2014-12-16 08:25:55 -0800 | [diff] [blame] | 46 | SkIRect::MakeEmpty(), |
robertphillips | 4aa6dfc | 2014-09-17 07:50:47 -0700 | [diff] [blame] | 47 | SkMatrix::I(), |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 48 | indices, 1, |
robertphillips | 4aa6dfc | 2014-09-17 07:50:47 -0700 | [diff] [blame] | 49 | NULL); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 50 | REPORTER_ASSERT(reporter, layer); |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 51 | GrCachedLayer* temp = TestingAccess::Find(cache, picture.uniqueID(), SkMatrix::I(), |
| 52 | indices, 1); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 53 | REPORTER_ASSERT(reporter, temp == layer); |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 54 | |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 55 | REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1); |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 56 | |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 57 | REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID()); |
robertphillips | 0c42332 | 2014-07-31 11:02:38 -0700 | [diff] [blame] | 58 | REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1); |
| 59 | REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 60 | REPORTER_ASSERT(reporter, NULL == layer->texture()); |
robertphillips | 4aa6dfc | 2014-09-17 07:50:47 -0700 | [diff] [blame] | 61 | REPORTER_ASSERT(reporter, NULL == layer->paint()); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 62 | REPORTER_ASSERT(reporter, !layer->isAtlased()); |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 63 | } |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 64 | } |
| 65 | |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 66 | static void lock_layer(skiatest::Reporter* reporter, |
| 67 | GrLayerCache* cache, |
| 68 | GrCachedLayer* layer) { |
| 69 | // Make the layer 512x512 (so it can be atlased) |
bsalomon | f2703d8 | 2014-10-28 14:33:06 -0700 | [diff] [blame] | 70 | GrSurfaceDesc desc; |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 71 | desc.fWidth = 512; |
| 72 | desc.fHeight = 512; |
| 73 | desc.fConfig = kSkia8888_GrPixelConfig; |
| 74 | |
robertphillips | fd61ed0 | 2014-10-28 07:21:44 -0700 | [diff] [blame] | 75 | bool needsRerendering; |
| 76 | bool inAtlas = cache->tryToAtlas(layer, desc, &needsRerendering); |
| 77 | if (!inAtlas) { |
| 78 | cache->lock(layer, desc, &needsRerendering); |
| 79 | } |
robertphillips | 6f294af | 2014-08-18 08:50:03 -0700 | [diff] [blame] | 80 | REPORTER_ASSERT(reporter, needsRerendering); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 81 | |
robertphillips | fd61ed0 | 2014-10-28 07:21:44 -0700 | [diff] [blame] | 82 | cache->lock(layer, desc, &needsRerendering); |
robertphillips | 6f294af | 2014-08-18 08:50:03 -0700 | [diff] [blame] | 83 | REPORTER_ASSERT(reporter, !needsRerendering); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 84 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 85 | REPORTER_ASSERT(reporter, layer->texture()); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 86 | REPORTER_ASSERT(reporter, layer->locked()); |
robertphillips | 7bb9ed7 | 2014-10-10 11:38:29 -0700 | [diff] [blame] | 87 | |
| 88 | cache->addUse(layer); |
| 89 | |
| 90 | REPORTER_ASSERT(reporter, 1 == TestingAccess::Uses(layer)); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 91 | } |
| 92 | |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 93 | // 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. |
| 95 | // locking & unlocking textures). |
| 96 | // TODO: need to add checks on VRAM usage! |
| 97 | DEF_GPUTEST(GpuLayerCache, reporter, factory) { |
kkinnunen | b5f4961 | 2014-12-12 05:29:12 -0800 | [diff] [blame] | 98 | static const unsigned kInitialNumLayers = 5; |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 99 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 100 | for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { |
| 101 | GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i; |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 102 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 103 | if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { |
| 104 | continue; |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 105 | } |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 106 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 107 | GrContext* context = factory->get(glCtxType); |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 108 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 109 | if (NULL == context) { |
| 110 | continue; |
| 111 | } |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 112 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 113 | SkPictureRecorder recorder; |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 114 | SkCanvas* c = recorder.beginRecording(1, 1); |
| 115 | // Draw something, anything, to prevent an empty-picture optimization, |
| 116 | // which is a singleton and never purged. |
| 117 | c->drawRect(SkRect::MakeWH(1,1), SkPaint()); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 118 | SkAutoTUnref<const SkPicture> picture(recorder.endRecording()); |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 119 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 120 | GrLayerCache cache(context); |
| 121 | |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 122 | create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 123 | |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 124 | for (unsigned i = 0; i < kInitialNumLayers; ++i) { |
| 125 | unsigned indices[1] = { i + 1 }; |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 126 | GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), |
| 127 | indices, 1); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 128 | REPORTER_ASSERT(reporter, layer); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 129 | |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 130 | lock_layer(reporter, &cache, layer); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 131 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 132 | // The first 4 layers should be in the atlas (and thus have non-empty |
| 133 | // rects) |
| 134 | if (i < 4) { |
| 135 | REPORTER_ASSERT(reporter, layer->isAtlased()); |
| 136 | } else { |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 137 | // The 5th layer couldn't fit in the atlas |
| 138 | REPORTER_ASSERT(reporter, !layer->isAtlased()); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 139 | } |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 140 | } |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 141 | |
| 142 | // Unlock the textures |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 143 | for (unsigned i = 0; i < kInitialNumLayers; ++i) { |
| 144 | unsigned indices[1] = { i+1 }; |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 145 | |
| 146 | GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), |
| 147 | indices, 1); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 148 | REPORTER_ASSERT(reporter, layer); |
robertphillips | 7bb9ed7 | 2014-10-10 11:38:29 -0700 | [diff] [blame] | 149 | cache.removeUse(layer); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 150 | } |
| 151 | |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 152 | for (unsigned i = 0; i < kInitialNumLayers; ++i) { |
| 153 | unsigned indices[1] = { i+1 }; |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 154 | |
| 155 | GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), |
| 156 | indices, 1); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 157 | REPORTER_ASSERT(reporter, layer); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 158 | |
robertphillips | 7bb9ed7 | 2014-10-10 11:38:29 -0700 | [diff] [blame] | 159 | // All the layers should be unlocked |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 160 | REPORTER_ASSERT(reporter, !layer->locked()); |
robertphillips | 7bb9ed7 | 2014-10-10 11:38:29 -0700 | [diff] [blame] | 161 | |
robertphillips | 4ab5a90 | 2014-10-29 13:56:02 -0700 | [diff] [blame] | 162 | // When hoisted layers aren't cached they are aggressively removed |
| 163 | // from the atlas |
| 164 | #if GR_CACHE_HOISTED_LAYERS |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 165 | // The first 4 layers should still be in the atlas. |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 166 | if (i < 4) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 167 | REPORTER_ASSERT(reporter, layer->texture()); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 168 | REPORTER_ASSERT(reporter, layer->isAtlased()); |
| 169 | } else { |
robertphillips | 4ab5a90 | 2014-10-29 13:56:02 -0700 | [diff] [blame] | 170 | #endif |
robertphillips | 7bb9ed7 | 2014-10-10 11:38:29 -0700 | [diff] [blame] | 171 | // The final layer should not be atlased. |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 172 | REPORTER_ASSERT(reporter, NULL == layer->texture()); |
| 173 | REPORTER_ASSERT(reporter, !layer->isAtlased()); |
robertphillips | 4ab5a90 | 2014-10-29 13:56:02 -0700 | [diff] [blame] | 174 | #if GR_CACHE_HOISTED_LAYERS |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 175 | } |
robertphillips | 4ab5a90 | 2014-10-29 13:56:02 -0700 | [diff] [blame] | 176 | #endif |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 177 | } |
| 178 | |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 179 | { |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 180 | unsigned indices[1] = { kInitialNumLayers+1 }; |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 181 | |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 182 | // Add an additional layer. Since all the layers are unlocked this |
| 183 | // will force out the first atlased layer |
| 184 | create_layers(reporter, &cache, *picture, 1, kInitialNumLayers); |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 185 | GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), |
| 186 | indices, 1); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 187 | REPORTER_ASSERT(reporter, layer); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 188 | |
| 189 | lock_layer(reporter, &cache, layer); |
robertphillips | 7bb9ed7 | 2014-10-10 11:38:29 -0700 | [diff] [blame] | 190 | cache.removeUse(layer); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 191 | } |
| 192 | |
robertphillips | e99d499 | 2014-12-03 07:33:57 -0800 | [diff] [blame] | 193 | for (unsigned i = 0; i < kInitialNumLayers+1; ++i) { |
| 194 | unsigned indices[1] = { i+1 }; |
robertphillips | 01d6e5f | 2014-12-01 09:09:27 -0800 | [diff] [blame] | 195 | |
| 196 | GrCachedLayer* layer = TestingAccess::Find(&cache, picture->uniqueID(), SkMatrix::I(), |
| 197 | indices, 1); |
robertphillips | 4ab5a90 | 2014-10-29 13:56:02 -0700 | [diff] [blame] | 198 | #if GR_CACHE_HOISTED_LAYERS |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 199 | // 3 old layers plus the new one should be in the atlas. |
| 200 | if (1 == i || 2 == i || 3 == i || 5 == i) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 201 | REPORTER_ASSERT(reporter, layer); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 202 | REPORTER_ASSERT(reporter, !layer->locked()); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 203 | REPORTER_ASSERT(reporter, layer->texture()); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 204 | REPORTER_ASSERT(reporter, layer->isAtlased()); |
| 205 | } else if (4 == i) { |
robertphillips | 4ab5a90 | 2014-10-29 13:56:02 -0700 | [diff] [blame] | 206 | #endif |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 207 | // The one that was never atlased should still be around |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 208 | REPORTER_ASSERT(reporter, layer); |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 209 | |
| 210 | REPORTER_ASSERT(reporter, NULL == layer->texture()); |
| 211 | REPORTER_ASSERT(reporter, !layer->isAtlased()); |
robertphillips | 4ab5a90 | 2014-10-29 13:56:02 -0700 | [diff] [blame] | 212 | #if GR_CACHE_HOISTED_LAYERS |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 213 | } else { |
| 214 | // The one bumped out of the atlas (i.e., 0) should be gone |
| 215 | REPORTER_ASSERT(reporter, NULL == layer); |
| 216 | } |
robertphillips | 4ab5a90 | 2014-10-29 13:56:02 -0700 | [diff] [blame] | 217 | #endif |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 218 | } |
| 219 | |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 220 | //-------------------------------------------------------------------- |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 221 | // Free them all SkGpuDevice-style. This will not free up the |
| 222 | // atlas' texture but will eliminate all the layers. |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 223 | TestingAccess::Purge(&cache, picture->uniqueID()); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 224 | |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 225 | REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 226 | // TODO: add VRAM/resource cache check here |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 227 | |
| 228 | //-------------------------------------------------------------------- |
| 229 | // Test out the GrContext-style purge. This should remove all the layers |
| 230 | // and the atlas. |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 231 | // Re-create the layers |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 232 | create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 233 | |
| 234 | // Free them again GrContext-style. This should free up everything. |
| 235 | cache.freeAll(); |
| 236 | |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 237 | REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 238 | // TODO: add VRAM/resource cache check here |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 239 | |
| 240 | //-------------------------------------------------------------------- |
| 241 | // Test out the MessageBus-style purge. This will not free the atlas |
| 242 | // but should eliminate the free-floating layers. |
robertphillips | 320c923 | 2014-07-29 06:07:19 -0700 | [diff] [blame] | 243 | create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); |
robertphillips | d771f6b | 2014-07-22 10:18:06 -0700 | [diff] [blame] | 244 | |
| 245 | picture.reset(NULL); |
| 246 | cache.processDeletedPictures(); |
| 247 | |
| 248 | REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); |
| 249 | // TODO: add VRAM/resource cache check here |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 250 | } |
robertphillips | 952841b | 2014-06-30 08:26:50 -0700 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | #endif |