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

Side by Side Diff: tests/GpuLayerCacheTest.cpp

Issue 678403002: Discard atlas after every MultiPictureDraw::draw (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix rebase error Created 6 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/GrLayerHoister.cpp ('k') | no next file » | 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"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 139
140 for (int i = 0; i < kInitialNumLayers; ++i) { 140 for (int i = 0; i < kInitialNumLayers; ++i) {
141 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, 141 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1,
142 SkIRect::MakeEmpty(), SkMatri x::I()); 142 SkIRect::MakeEmpty(), SkMatri x::I());
143 REPORTER_ASSERT(reporter, layer); 143 REPORTER_ASSERT(reporter, layer);
144 144
145 // All the layers should be unlocked 145 // All the layers should be unlocked
146 REPORTER_ASSERT(reporter, !layer->locked()); 146 REPORTER_ASSERT(reporter, !layer->locked());
147 147
148 // When hoisted layers aren't cached they are aggressively removed
149 // from the atlas
150 #if GR_CACHE_HOISTED_LAYERS
148 // The first 4 layers should still be in the atlas. 151 // The first 4 layers should still be in the atlas.
149 if (i < 4) { 152 if (i < 4) {
150 REPORTER_ASSERT(reporter, layer->texture()); 153 REPORTER_ASSERT(reporter, layer->texture());
151 REPORTER_ASSERT(reporter, layer->isAtlased()); 154 REPORTER_ASSERT(reporter, layer->isAtlased());
152 } else { 155 } else {
156 #endif
153 // The final layer should not be atlased. 157 // The final layer should not be atlased.
154 REPORTER_ASSERT(reporter, NULL == layer->texture()); 158 REPORTER_ASSERT(reporter, NULL == layer->texture());
155 REPORTER_ASSERT(reporter, !layer->isAtlased()); 159 REPORTER_ASSERT(reporter, !layer->isAtlased());
160 #if GR_CACHE_HOISTED_LAYERS
156 } 161 }
162 #endif
157 } 163 }
158 164
159 { 165 {
160 // Add an additional layer. Since all the layers are unlocked this 166 // Add an additional layer. Since all the layers are unlocked this
161 // will force out the first atlased layer 167 // will force out the first atlased layer
162 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers); 168 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers);
163 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), 169 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(),
164 kInitialNumLayers+1, 170 kInitialNumLayers+1,
165 SkIRect::MakeEmpty(), SkMatri x::I()); 171 SkIRect::MakeEmpty(), SkMatri x::I());
166 REPORTER_ASSERT(reporter, layer); 172 REPORTER_ASSERT(reporter, layer);
167 173
168 lock_layer(reporter, &cache, layer); 174 lock_layer(reporter, &cache, layer);
169 cache.removeUse(layer); 175 cache.removeUse(layer);
170 } 176 }
171 177
172 for (int i = 0; i < kInitialNumLayers+1; ++i) { 178 for (int i = 0; i < kInitialNumLayers+1; ++i) {
173 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i + 1, 179 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i + 1,
174 SkIRect::MakeEmpty(), SkMatri x::I()); 180 SkIRect::MakeEmpty(), SkMatri x::I());
181 #if GR_CACHE_HOISTED_LAYERS
175 // 3 old layers plus the new one should be in the atlas. 182 // 3 old layers plus the new one should be in the atlas.
176 if (1 == i || 2 == i || 3 == i || 5 == i) { 183 if (1 == i || 2 == i || 3 == i || 5 == i) {
177 REPORTER_ASSERT(reporter, layer); 184 REPORTER_ASSERT(reporter, layer);
178 REPORTER_ASSERT(reporter, !layer->locked()); 185 REPORTER_ASSERT(reporter, !layer->locked());
179 REPORTER_ASSERT(reporter, layer->texture()); 186 REPORTER_ASSERT(reporter, layer->texture());
180 REPORTER_ASSERT(reporter, layer->isAtlased()); 187 REPORTER_ASSERT(reporter, layer->isAtlased());
181 } else if (4 == i) { 188 } else if (4 == i) {
189 #endif
182 // The one that was never atlased should still be around 190 // The one that was never atlased should still be around
183 REPORTER_ASSERT(reporter, layer); 191 REPORTER_ASSERT(reporter, layer);
184 192
185 REPORTER_ASSERT(reporter, NULL == layer->texture()); 193 REPORTER_ASSERT(reporter, NULL == layer->texture());
186 REPORTER_ASSERT(reporter, !layer->isAtlased()); 194 REPORTER_ASSERT(reporter, !layer->isAtlased());
195 #if GR_CACHE_HOISTED_LAYERS
187 } else { 196 } else {
188 // The one bumped out of the atlas (i.e., 0) should be gone 197 // The one bumped out of the atlas (i.e., 0) should be gone
189 REPORTER_ASSERT(reporter, NULL == layer); 198 REPORTER_ASSERT(reporter, NULL == layer);
190 } 199 }
200 #endif
191 } 201 }
192 202
193 //-------------------------------------------------------------------- 203 //--------------------------------------------------------------------
194 // Free them all SkGpuDevice-style. This will not free up the 204 // Free them all SkGpuDevice-style. This will not free up the
195 // atlas' texture but will eliminate all the layers. 205 // atlas' texture but will eliminate all the layers.
196 TestingAccess::Purge(&cache, picture->uniqueID()); 206 TestingAccess::Purge(&cache, picture->uniqueID());
197 207
198 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 208 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
199 // TODO: add VRAM/resource cache check here 209 // TODO: add VRAM/resource cache check here
200 210
(...skipping 16 matching lines...) Expand all
217 227
218 picture.reset(NULL); 228 picture.reset(NULL);
219 cache.processDeletedPictures(); 229 cache.processDeletedPictures();
220 230
221 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 231 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
222 // TODO: add VRAM/resource cache check here 232 // TODO: add VRAM/resource cache check here
223 } 233 }
224 } 234 }
225 235
226 #endif 236 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrLayerHoister.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698