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

Side by Side Diff: tests/GpuLayerCacheTest.cpp

Issue 429593002: Now always use Atlas for layer cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months 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/GrLayerCache.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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 GrLayerCache cache(context); 93 GrLayerCache cache(context);
94 94
95 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 95 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
96 96
97 for (int i = 0; i < kInitialNumLayers; ++i) { 97 for (int i = 0; i < kInitialNumLayers; ++i) {
98 GrCachedLayer* layer = cache.findLayer(picture, i); 98 GrCachedLayer* layer = cache.findLayer(picture, i);
99 REPORTER_ASSERT(reporter, NULL != layer); 99 REPORTER_ASSERT(reporter, NULL != layer);
100 100
101 lock_layer(reporter, &cache, layer); 101 lock_layer(reporter, &cache, layer);
102 102
103 #if USE_ATLAS
104 // The first 4 layers should be in the atlas (and thus have non-empt y 103 // The first 4 layers should be in the atlas (and thus have non-empt y
105 // rects) 104 // rects)
106 if (i < 4) { 105 if (i < 4) {
107 REPORTER_ASSERT(reporter, layer->isAtlased()); 106 REPORTER_ASSERT(reporter, layer->isAtlased());
108 } else { 107 } else {
109 #endif
110 // The 5th layer couldn't fit in the atlas 108 // The 5th layer couldn't fit in the atlas
111 REPORTER_ASSERT(reporter, !layer->isAtlased()); 109 REPORTER_ASSERT(reporter, !layer->isAtlased());
112 #if USE_ATLAS
113 } 110 }
114 #endif
115 } 111 }
116 112
117 // Unlock the textures 113 // Unlock the textures
118 for (int i = 0; i < kInitialNumLayers; ++i) { 114 for (int i = 0; i < kInitialNumLayers; ++i) {
119 GrCachedLayer* layer = cache.findLayer(picture, i); 115 GrCachedLayer* layer = cache.findLayer(picture, i);
120 REPORTER_ASSERT(reporter, NULL != layer); 116 REPORTER_ASSERT(reporter, NULL != layer);
121 117
122 cache.unlock(layer); 118 cache.unlock(layer);
123 } 119 }
124 120
125 for (int i = 0; i < kInitialNumLayers; ++i) { 121 for (int i = 0; i < kInitialNumLayers; ++i) {
126 GrCachedLayer* layer = cache.findLayer(picture, i); 122 GrCachedLayer* layer = cache.findLayer(picture, i);
127 REPORTER_ASSERT(reporter, NULL != layer); 123 REPORTER_ASSERT(reporter, NULL != layer);
128 124
129 REPORTER_ASSERT(reporter, !layer->locked()); 125 REPORTER_ASSERT(reporter, !layer->locked());
130 #if USE_ATLAS
131 // The first 4 layers should still be in the atlas. 126 // The first 4 layers should still be in the atlas.
132 if (i < 4) { 127 if (i < 4) {
133 REPORTER_ASSERT(reporter, NULL != layer->texture()); 128 REPORTER_ASSERT(reporter, NULL != layer->texture());
134 REPORTER_ASSERT(reporter, layer->isAtlased()); 129 REPORTER_ASSERT(reporter, layer->isAtlased());
135 } else { 130 } else {
136 #endif
137 // The final layer should be unlocked. 131 // The final layer should be unlocked.
138 REPORTER_ASSERT(reporter, NULL == layer->texture()); 132 REPORTER_ASSERT(reporter, NULL == layer->texture());
139 REPORTER_ASSERT(reporter, !layer->isAtlased()); 133 REPORTER_ASSERT(reporter, !layer->isAtlased());
140 #if USE_ATLAS
141 } 134 }
142 #endif
143 } 135 }
144 136
145 { 137 {
146 // Add an additional layer. Since all the layers are unlocked this 138 // Add an additional layer. Since all the layers are unlocked this
147 // will force out the first atlased layer 139 // will force out the first atlased layer
148 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers); 140 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers);
149 GrCachedLayer* layer = cache.findLayer(picture, kInitialNumLayers); 141 GrCachedLayer* layer = cache.findLayer(picture, kInitialNumLayers);
150 REPORTER_ASSERT(reporter, NULL != layer); 142 REPORTER_ASSERT(reporter, NULL != layer);
151 143
152 lock_layer(reporter, &cache, layer); 144 lock_layer(reporter, &cache, layer);
153 cache.unlock(layer); 145 cache.unlock(layer);
154 } 146 }
155 147
156 for (int i = 0; i < kInitialNumLayers+1; ++i) { 148 for (int i = 0; i < kInitialNumLayers+1; ++i) {
157 GrCachedLayer* layer = cache.findLayer(picture, i); 149 GrCachedLayer* layer = cache.findLayer(picture, i);
158 #if USE_ATLAS
159 // 3 old layers plus the new one should be in the atlas. 150 // 3 old layers plus the new one should be in the atlas.
160 if (1 == i || 2 == i || 3 == i || 5 == i) { 151 if (1 == i || 2 == i || 3 == i || 5 == i) {
161 REPORTER_ASSERT(reporter, NULL != layer); 152 REPORTER_ASSERT(reporter, NULL != layer);
162 REPORTER_ASSERT(reporter, !layer->locked()); 153 REPORTER_ASSERT(reporter, !layer->locked());
163 REPORTER_ASSERT(reporter, NULL != layer->texture()); 154 REPORTER_ASSERT(reporter, NULL != layer->texture());
164 REPORTER_ASSERT(reporter, layer->isAtlased()); 155 REPORTER_ASSERT(reporter, layer->isAtlased());
165 } else if (4 == i) { 156 } else if (4 == i) {
166 #endif
167 // The one that was never atlased should still be around 157 // The one that was never atlased should still be around
168 REPORTER_ASSERT(reporter, NULL != layer); 158 REPORTER_ASSERT(reporter, NULL != layer);
169 159
170 REPORTER_ASSERT(reporter, NULL == layer->texture()); 160 REPORTER_ASSERT(reporter, NULL == layer->texture());
171 REPORTER_ASSERT(reporter, !layer->isAtlased()); 161 REPORTER_ASSERT(reporter, !layer->isAtlased());
172 #if USE_ATLAS
173 } else { 162 } else {
174 // The one bumped out of the atlas (i.e., 0) should be gone 163 // The one bumped out of the atlas (i.e., 0) should be gone
175 REPORTER_ASSERT(reporter, NULL == layer); 164 REPORTER_ASSERT(reporter, NULL == layer);
176 } 165 }
177 #endif
178 } 166 }
179 167
180 //-------------------------------------------------------------------- 168 //--------------------------------------------------------------------
181 // Free them all SkGpuDevice-style. This will not free up the 169 // Free them all SkGpuDevice-style. This will not free up the
182 // atlas' texture but will eliminate all the layers. 170 // atlas' texture but will eliminate all the layers.
183 TestingAccess::Purge(&cache, picture->uniqueID()); 171 TestingAccess::Purge(&cache, picture->uniqueID());
184 172
185 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 173 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
186 // TODO: add VRAM/resource cache check here 174 // TODO: add VRAM/resource cache check here
187 175
(...skipping 16 matching lines...) Expand all
204 192
205 picture.reset(NULL); 193 picture.reset(NULL);
206 cache.processDeletedPictures(); 194 cache.processDeletedPictures();
207 195
208 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 196 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
209 // TODO: add VRAM/resource cache check here 197 // TODO: add VRAM/resource cache check here
210 } 198 }
211 } 199 }
212 200
213 #endif 201 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrLayerCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698