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

Side by Side Diff: tests/GpuLayerCacheTest.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 years, 3 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 | « tests/GLProgramsTest.cpp ('k') | tests/GrAllocatorTest.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"
(...skipping 16 matching lines...) Expand all
27 static void create_layers(skiatest::Reporter* reporter, 27 static void create_layers(skiatest::Reporter* reporter,
28 GrLayerCache* cache, 28 GrLayerCache* cache,
29 const SkPicture& picture, 29 const SkPicture& picture,
30 int numToAdd, 30 int numToAdd,
31 int idOffset) { 31 int idOffset) {
32 32
33 for (int i = 0; i < numToAdd; ++i) { 33 for (int i = 0; i < numToAdd; ++i) {
34 GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(), 34 GrCachedLayer* layer = cache->findLayerOrCreate(picture.uniqueID(),
35 idOffset+i+1, idOffset+i +2, 35 idOffset+i+1, idOffset+i +2,
36 SkMatrix::I()); 36 SkMatrix::I());
37 REPORTER_ASSERT(reporter, NULL != layer); 37 REPORTER_ASSERT(reporter, layer);
38 GrCachedLayer* temp = cache->findLayer(picture.uniqueID(), idOffset+i+1, idOffset+i+2, SkMatrix::I()); 38 GrCachedLayer* temp = cache->findLayer(picture.uniqueID(), idOffset+i+1, idOffset+i+2, SkMatrix::I());
39 REPORTER_ASSERT(reporter, temp == layer); 39 REPORTER_ASSERT(reporter, temp == layer);
40 40
41 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1); 41 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == idOffset + i + 1);
42 42
43 REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID()); 43 REPORTER_ASSERT(reporter, picture.uniqueID() == layer->pictureID());
44 REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1); 44 REPORTER_ASSERT(reporter, layer->start() == idOffset + i + 1);
45 REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2); 45 REPORTER_ASSERT(reporter, layer->stop() == idOffset + i + 2);
46 REPORTER_ASSERT(reporter, layer->ctm() == SkMatrix::I()); 46 REPORTER_ASSERT(reporter, layer->ctm() == SkMatrix::I());
47 REPORTER_ASSERT(reporter, NULL == layer->texture()); 47 REPORTER_ASSERT(reporter, NULL == layer->texture());
(...skipping 11 matching lines...) Expand all
59 desc.fWidth = 512; 59 desc.fWidth = 512;
60 desc.fHeight = 512; 60 desc.fHeight = 512;
61 desc.fConfig = kSkia8888_GrPixelConfig; 61 desc.fConfig = kSkia8888_GrPixelConfig;
62 62
63 bool needsRerendering = cache->lock(layer, desc, false); 63 bool needsRerendering = cache->lock(layer, desc, false);
64 REPORTER_ASSERT(reporter, needsRerendering); 64 REPORTER_ASSERT(reporter, needsRerendering);
65 65
66 needsRerendering = cache->lock(layer, desc, false); 66 needsRerendering = cache->lock(layer, desc, false);
67 REPORTER_ASSERT(reporter, !needsRerendering); 67 REPORTER_ASSERT(reporter, !needsRerendering);
68 68
69 REPORTER_ASSERT(reporter, NULL != layer->texture()); 69 REPORTER_ASSERT(reporter, layer->texture());
70 REPORTER_ASSERT(reporter, layer->locked()); 70 REPORTER_ASSERT(reporter, layer->locked());
71 } 71 }
72 72
73 // This test case exercises the public API of the GrLayerCache class. 73 // This test case exercises the public API of the GrLayerCache class.
74 // In particular it checks its interaction with the resource cache (w.r.t. 74 // In particular it checks its interaction with the resource cache (w.r.t.
75 // locking & unlocking textures). 75 // locking & unlocking textures).
76 // TODO: need to add checks on VRAM usage! 76 // TODO: need to add checks on VRAM usage!
77 DEF_GPUTEST(GpuLayerCache, reporter, factory) { 77 DEF_GPUTEST(GpuLayerCache, reporter, factory) {
78 static const int kInitialNumLayers = 5; 78 static const int kInitialNumLayers = 5;
79 79
(...skipping 13 matching lines...) Expand all
93 SkPictureRecorder recorder; 93 SkPictureRecorder recorder;
94 recorder.beginRecording(1, 1); 94 recorder.beginRecording(1, 1);
95 SkAutoTUnref<const SkPicture> picture(recorder.endRecording()); 95 SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
96 96
97 GrLayerCache cache(context); 97 GrLayerCache cache(context);
98 98
99 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0); 99 create_layers(reporter, &cache, *picture, kInitialNumLayers, 0);
100 100
101 for (int i = 0; i < kInitialNumLayers; ++i) { 101 for (int i = 0; i < kInitialNumLayers; ++i) {
102 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, i+2 , SkMatrix::I()); 102 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, i+2 , SkMatrix::I());
103 REPORTER_ASSERT(reporter, NULL != layer); 103 REPORTER_ASSERT(reporter, layer);
104 104
105 lock_layer(reporter, &cache, layer); 105 lock_layer(reporter, &cache, layer);
106 106
107 // The first 4 layers should be in the atlas (and thus have non-empt y 107 // The first 4 layers should be in the atlas (and thus have non-empt y
108 // rects) 108 // rects)
109 if (i < 4) { 109 if (i < 4) {
110 REPORTER_ASSERT(reporter, layer->isAtlased()); 110 REPORTER_ASSERT(reporter, layer->isAtlased());
111 } else { 111 } else {
112 // The 5th layer couldn't fit in the atlas 112 // The 5th layer couldn't fit in the atlas
113 REPORTER_ASSERT(reporter, !layer->isAtlased()); 113 REPORTER_ASSERT(reporter, !layer->isAtlased());
114 } 114 }
115 } 115 }
116 116
117 // Unlock the textures 117 // Unlock the textures
118 for (int i = 0; i < kInitialNumLayers; ++i) { 118 for (int i = 0; i < kInitialNumLayers; ++i) {
119 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, i+2 , SkMatrix::I()); 119 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, i+2 , SkMatrix::I());
120 REPORTER_ASSERT(reporter, NULL != layer); 120 REPORTER_ASSERT(reporter, layer);
121 121
122 cache.unlock(layer); 122 cache.unlock(layer);
123 } 123 }
124 124
125 for (int i = 0; i < kInitialNumLayers; ++i) { 125 for (int i = 0; i < kInitialNumLayers; ++i) {
126 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, i+2 , SkMatrix::I()); 126 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, i+2 , SkMatrix::I());
127 REPORTER_ASSERT(reporter, NULL != layer); 127 REPORTER_ASSERT(reporter, layer);
128 128
129 REPORTER_ASSERT(reporter, !layer->locked()); 129 REPORTER_ASSERT(reporter, !layer->locked());
130 // The first 4 layers should still be in the atlas. 130 // The first 4 layers should still be in the atlas.
131 if (i < 4) { 131 if (i < 4) {
132 REPORTER_ASSERT(reporter, NULL != layer->texture()); 132 REPORTER_ASSERT(reporter, layer->texture());
133 REPORTER_ASSERT(reporter, layer->isAtlased()); 133 REPORTER_ASSERT(reporter, layer->isAtlased());
134 } else { 134 } else {
135 // The final layer should be unlocked. 135 // The final layer should be unlocked.
136 REPORTER_ASSERT(reporter, NULL == layer->texture()); 136 REPORTER_ASSERT(reporter, NULL == layer->texture());
137 REPORTER_ASSERT(reporter, !layer->isAtlased()); 137 REPORTER_ASSERT(reporter, !layer->isAtlased());
138 } 138 }
139 } 139 }
140 140
141 { 141 {
142 // Add an additional layer. Since all the layers are unlocked this 142 // Add an additional layer. Since all the layers are unlocked this
143 // will force out the first atlased layer 143 // will force out the first atlased layer
144 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers); 144 create_layers(reporter, &cache, *picture, 1, kInitialNumLayers);
145 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), 145 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(),
146 kInitialNumLayers+1, kInitial NumLayers+2, 146 kInitialNumLayers+1, kInitial NumLayers+2,
147 SkMatrix::I()); 147 SkMatrix::I());
148 REPORTER_ASSERT(reporter, NULL != layer); 148 REPORTER_ASSERT(reporter, layer);
149 149
150 lock_layer(reporter, &cache, layer); 150 lock_layer(reporter, &cache, layer);
151 cache.unlock(layer); 151 cache.unlock(layer);
152 } 152 }
153 153
154 for (int i = 0; i < kInitialNumLayers+1; ++i) { 154 for (int i = 0; i < kInitialNumLayers+1; ++i) {
155 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, i+2 , SkMatrix::I()); 155 GrCachedLayer* layer = cache.findLayer(picture->uniqueID(), i+1, i+2 , SkMatrix::I());
156 // 3 old layers plus the new one should be in the atlas. 156 // 3 old layers plus the new one should be in the atlas.
157 if (1 == i || 2 == i || 3 == i || 5 == i) { 157 if (1 == i || 2 == i || 3 == i || 5 == i) {
158 REPORTER_ASSERT(reporter, NULL != layer); 158 REPORTER_ASSERT(reporter, layer);
159 REPORTER_ASSERT(reporter, !layer->locked()); 159 REPORTER_ASSERT(reporter, !layer->locked());
160 REPORTER_ASSERT(reporter, NULL != layer->texture()); 160 REPORTER_ASSERT(reporter, layer->texture());
161 REPORTER_ASSERT(reporter, layer->isAtlased()); 161 REPORTER_ASSERT(reporter, layer->isAtlased());
162 } else if (4 == i) { 162 } else if (4 == i) {
163 // The one that was never atlased should still be around 163 // The one that was never atlased should still be around
164 REPORTER_ASSERT(reporter, NULL != layer); 164 REPORTER_ASSERT(reporter, layer);
165 165
166 REPORTER_ASSERT(reporter, NULL == layer->texture()); 166 REPORTER_ASSERT(reporter, NULL == layer->texture());
167 REPORTER_ASSERT(reporter, !layer->isAtlased()); 167 REPORTER_ASSERT(reporter, !layer->isAtlased());
168 } else { 168 } else {
169 // The one bumped out of the atlas (i.e., 0) should be gone 169 // The one bumped out of the atlas (i.e., 0) should be gone
170 REPORTER_ASSERT(reporter, NULL == layer); 170 REPORTER_ASSERT(reporter, NULL == layer);
171 } 171 }
172 } 172 }
173 173
174 //-------------------------------------------------------------------- 174 //--------------------------------------------------------------------
(...skipping 23 matching lines...) Expand all
198 198
199 picture.reset(NULL); 199 picture.reset(NULL);
200 cache.processDeletedPictures(); 200 cache.processDeletedPictures();
201 201
202 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0); 202 REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
203 // TODO: add VRAM/resource cache check here 203 // TODO: add VRAM/resource cache check here
204 } 204 }
205 } 205 }
206 206
207 #endif 207 #endif
OLDNEW
« no previous file with comments | « tests/GLProgramsTest.cpp ('k') | tests/GrAllocatorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698