OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 layers[i] = cache->findLayerOrCreate(&picture, i); | 32 layers[i] = cache->findLayerOrCreate(&picture, i); |
33 REPORTER_ASSERT(reporter, NULL != layers[i]); | 33 REPORTER_ASSERT(reporter, NULL != layers[i]); |
34 GrCachedLayer* layer = cache->findLayer(&picture, i); | 34 GrCachedLayer* layer = cache->findLayer(&picture, i); |
35 REPORTER_ASSERT(reporter, layer == layers[i]); | 35 REPORTER_ASSERT(reporter, layer == layers[i]); |
36 | 36 |
37 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(cache) == i+1); | 37 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(cache) == i+1); |
38 | 38 |
39 REPORTER_ASSERT(reporter, picture.uniqueID() == layers[i]->pictureID()); | 39 REPORTER_ASSERT(reporter, picture.uniqueID() == layers[i]->pictureID()); |
40 REPORTER_ASSERT(reporter, layers[i]->layerID() == i); | 40 REPORTER_ASSERT(reporter, layers[i]->layerID() == i); |
41 REPORTER_ASSERT(reporter, NULL == layers[i]->texture()); | 41 REPORTER_ASSERT(reporter, NULL == layers[i]->texture()); |
42 REPORTER_ASSERT(reporter, layers[i]->rect().isEmpty()); | 42 REPORTER_ASSERT(reporter, !layers[i]->isAtlased()); |
43 } | 43 } |
44 | 44 |
45 } | 45 } |
46 | 46 |
47 // This test case exercises the public API of the GrLayerCache class. | 47 // This test case exercises the public API of the GrLayerCache class. |
48 // In particular it checks its interaction with the resource cache (w.r.t. | 48 // In particular it checks its interaction with the resource cache (w.r.t. |
49 // locking & unlocking textures). | 49 // locking & unlocking textures). |
50 // TODO: need to add checks on VRAM usage! | 50 // TODO: need to add checks on VRAM usage! |
51 DEF_GPUTEST(GpuLayerCache, reporter, factory) { | 51 DEF_GPUTEST(GpuLayerCache, reporter, factory) { |
52 | 52 |
(...skipping 23 matching lines...) Expand all Loading... |
76 bool foundInCache = cache.lock(layer, desc); | 76 bool foundInCache = cache.lock(layer, desc); |
77 REPORTER_ASSERT(reporter, !foundInCache); | 77 REPORTER_ASSERT(reporter, !foundInCache); |
78 foundInCache = cache.lock(layer, desc); | 78 foundInCache = cache.lock(layer, desc); |
79 REPORTER_ASSERT(reporter, foundInCache); | 79 REPORTER_ASSERT(reporter, foundInCache); |
80 | 80 |
81 REPORTER_ASSERT(reporter, NULL != layer->texture()); | 81 REPORTER_ASSERT(reporter, NULL != layer->texture()); |
82 #if USE_ATLAS | 82 #if USE_ATLAS |
83 // The first 4 layers should be in the atlas (and thus have non-empty | 83 // The first 4 layers should be in the atlas (and thus have non-empty |
84 // rects) | 84 // rects) |
85 if (i < 4) { | 85 if (i < 4) { |
86 REPORTER_ASSERT(reporter, !layer->rect().isEmpty()); | 86 REPORTER_ASSERT(reporter, layer->isAtlased()); |
87 } else { | 87 } else { |
88 #endif | 88 #endif |
89 REPORTER_ASSERT(reporter, layer->rect().isEmpty()); | 89 REPORTER_ASSERT(reporter, !layer->isAtlased()); |
90 #if USE_ATLAS | 90 #if USE_ATLAS |
91 } | 91 } |
92 #endif | 92 #endif |
93 } | 93 } |
94 | 94 |
95 // Unlock the textures | 95 // Unlock the textures |
96 for (int i = 0; i < kNumLayers; ++i) { | 96 for (int i = 0; i < kNumLayers; ++i) { |
97 GrCachedLayer* layer = cache.findLayer(picture, i); | 97 GrCachedLayer* layer = cache.findLayer(picture, i); |
98 REPORTER_ASSERT(reporter, NULL != layer); | 98 REPORTER_ASSERT(reporter, NULL != layer); |
99 | 99 |
100 cache.unlock(layer); | 100 cache.unlock(layer); |
101 } | 101 } |
102 | 102 |
103 for (int i = 0; i < kNumLayers; ++i) { | 103 for (int i = 0; i < kNumLayers; ++i) { |
104 GrCachedLayer* layer = cache.findLayer(picture, i); | 104 GrCachedLayer* layer = cache.findLayer(picture, i); |
105 REPORTER_ASSERT(reporter, NULL != layer); | 105 REPORTER_ASSERT(reporter, NULL != layer); |
106 | 106 |
107 #if USE_ATLAS | 107 #if USE_ATLAS |
108 // The first 4 layers should be in the atlas (and thus do not | 108 // The first 4 layers should be in the atlas (and thus do not |
109 // currently unlock). The final layer should be unlocked. | 109 // currently unlock). The final layer should be unlocked. |
110 if (i < 4) { | 110 if (i < 4) { |
111 REPORTER_ASSERT(reporter, NULL != layer->texture()); | 111 REPORTER_ASSERT(reporter, NULL != layer->texture()); |
112 REPORTER_ASSERT(reporter, !layer->rect().isEmpty()); | 112 REPORTER_ASSERT(reporter, layer->isAtlased()); |
113 } else { | 113 } else { |
114 #endif | 114 #endif |
115 REPORTER_ASSERT(reporter, NULL == layer->texture()); | 115 REPORTER_ASSERT(reporter, NULL == layer->texture()); |
116 REPORTER_ASSERT(reporter, layer->rect().isEmpty()); | 116 REPORTER_ASSERT(reporter, !layer->isAtlased()); |
117 #if USE_ATLAS | 117 #if USE_ATLAS |
118 } | 118 } |
119 #endif | 119 #endif |
120 } | 120 } |
121 | 121 |
122 // Free them all SkGpuDevice-style. This will not free up the | 122 // Free them all SkGpuDevice-style. This will not free up the |
123 // atlas' texture but will eliminate all the layers. | 123 // atlas' texture but will eliminate all the layers. |
124 cache.purge(picture); | 124 cache.purge(picture); |
125 | 125 |
126 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0); | 126 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0); |
127 // TODO: add VRAM/resource cache check here | 127 // TODO: add VRAM/resource cache check here |
128 #if 0 | 128 #if 0 |
129 // Re-create the layers | 129 // Re-create the layers |
130 create_layers(reporter, &cache, picture); | 130 create_layers(reporter, &cache, picture); |
131 | 131 |
132 // Free them again GrContext-style. This should free up everything. | 132 // Free them again GrContext-style. This should free up everything. |
133 cache.freeAll(); | 133 cache.freeAll(); |
134 | 134 |
135 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0); | 135 REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0); |
136 // TODO: add VRAM/resource cache check here | 136 // TODO: add VRAM/resource cache check here |
137 #endif | 137 #endif |
138 } | 138 } |
139 | 139 |
140 #endif | 140 #endif |
OLD | NEW |