OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "Test.h" | 8 #include "Test.h" |
9 // This is a GR test | 9 // This is a GR test |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 50 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
51 desc.fConfig = kAlpha_8_GrPixelConfig; | 51 desc.fConfig = kAlpha_8_GrPixelConfig; |
52 desc.fWidth = kXSize; | 52 desc.fWidth = kXSize; |
53 desc.fHeight = kYSize; | 53 desc.fHeight = kYSize; |
54 | 54 |
55 GrTexture* texture = context->createUncachedTexture(desc, NULL, 0); | 55 GrTexture* texture = context->createUncachedTexture(desc, NULL, 0); |
56 if (!texture) { | 56 if (!texture) { |
57 return; | 57 return; |
58 } | 58 } |
59 | 59 |
60 SkAutoUnref au(texture); | 60 SkAutoTUnref<GrTexture> au(texture); |
61 | 61 |
62 SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); | 62 SkIRect intScreen = SkIRect::MakeWH(kXSize, kYSize); |
63 SkRect screen; | 63 SkRect screen; |
64 | 64 |
65 screen = SkRect::MakeWH(SkIntToScalar(kXSize), | 65 screen = SkRect::MakeWH(SkIntToScalar(kXSize), |
66 SkIntToScalar(kYSize)); | 66 SkIntToScalar(kYSize)); |
67 | 67 |
68 SkRect clipRect(screen); | 68 SkRect clipRect(screen); |
69 clipRect.outset(10, 10); | 69 clipRect.outset(10, 10); |
70 | 70 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 cache.acquireMask(clip1.getTopmostGenID(), desc, bound1); | 157 cache.acquireMask(clip1.getTopmostGenID(), desc, bound1); |
158 | 158 |
159 GrTexture* texture1 = cache.getLastMask(); | 159 GrTexture* texture1 = cache.getLastMask(); |
160 REPORTER_ASSERT(reporter, texture1); | 160 REPORTER_ASSERT(reporter, texture1); |
161 if (NULL == texture1) { | 161 if (NULL == texture1) { |
162 return; | 162 return; |
163 } | 163 } |
164 | 164 |
165 // check that the set took | 165 // check that the set took |
166 check_state(reporter, cache, clip1, texture1, bound1); | 166 check_state(reporter, cache, clip1, texture1, bound1); |
167 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | |
168 | 167 |
169 // push the state | 168 // push the state |
170 cache.push(); | 169 cache.push(); |
171 | 170 |
172 // verify that the pushed state is initially empty | 171 // verify that the pushed state is initially empty |
173 check_empty_state(reporter, cache); | 172 check_empty_state(reporter, cache); |
174 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | |
175 | 173 |
176 // modify the new state | 174 // modify the new state |
177 SkIRect bound2; | 175 SkIRect bound2; |
178 bound2.set(-10, -10, 10, 10); | 176 bound2.set(-10, -10, 10, 10); |
179 | 177 |
180 SkClipStack clip2(bound2); | 178 SkClipStack clip2(bound2); |
181 | 179 |
182 cache.acquireMask(clip2.getTopmostGenID(), desc, bound2); | 180 cache.acquireMask(clip2.getTopmostGenID(), desc, bound2); |
183 | 181 |
184 GrTexture* texture2 = cache.getLastMask(); | 182 GrTexture* texture2 = cache.getLastMask(); |
185 REPORTER_ASSERT(reporter, texture2); | 183 REPORTER_ASSERT(reporter, texture2); |
186 if (NULL == texture2) { | 184 if (NULL == texture2) { |
187 return; | 185 return; |
188 } | 186 } |
189 | 187 |
190 // check that the changes took | 188 // check that the changes took |
191 check_state(reporter, cache, clip2, texture2, bound2); | 189 check_state(reporter, cache, clip2, texture2, bound2); |
192 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | |
193 REPORTER_ASSERT(reporter, texture2->getRefCnt()); | |
194 | 190 |
195 // check to make sure canReuse works | 191 // check to make sure canReuse works |
196 REPORTER_ASSERT(reporter, cache.canReuse(clip2.getTopmostGenID(), bound2)); | 192 REPORTER_ASSERT(reporter, cache.canReuse(clip2.getTopmostGenID(), bound2)); |
197 REPORTER_ASSERT(reporter, !cache.canReuse(clip1.getTopmostGenID(), bound1)); | 193 REPORTER_ASSERT(reporter, !cache.canReuse(clip1.getTopmostGenID(), bound1)); |
198 | 194 |
199 // pop the state | 195 // pop the state |
200 cache.pop(); | 196 cache.pop(); |
201 | 197 |
202 // verify that the old state is restored | 198 // verify that the old state is restored |
203 check_state(reporter, cache, clip1, texture1, bound1); | 199 check_state(reporter, cache, clip1, texture1, bound1); |
204 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | |
205 | 200 |
206 // manually clear the state | 201 // manually clear the state |
207 cache.reset(); | 202 cache.reset(); |
208 | 203 |
209 // verify it is now empty | 204 // verify it is now empty |
210 check_empty_state(reporter, cache); | 205 check_empty_state(reporter, cache); |
211 | 206 |
212 // pop again - so there is no state | 207 // pop again - so there is no state |
213 cache.pop(); | 208 cache.pop(); |
214 | 209 |
(...skipping 14 matching lines...) Expand all Loading... |
229 if (NULL == context) { | 224 if (NULL == context) { |
230 continue; | 225 continue; |
231 } | 226 } |
232 | 227 |
233 test_cache(reporter, context); | 228 test_cache(reporter, context); |
234 test_clip_bounds(reporter, context); | 229 test_clip_bounds(reporter, context); |
235 } | 230 } |
236 } | 231 } |
237 | 232 |
238 #endif | 233 #endif |
OLD | NEW |