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 | 8 |
9 #include "Test.h" | 9 #include "Test.h" |
10 // This is a GR test | 10 // This is a GR test |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // check to make sure canReuse works | 190 // check to make sure canReuse works |
191 REPORTER_ASSERT(reporter, cache.canReuse(clip2.getTopmostGenID(), bound2)); | 191 REPORTER_ASSERT(reporter, cache.canReuse(clip2.getTopmostGenID(), bound2)); |
192 REPORTER_ASSERT(reporter, !cache.canReuse(clip1.getTopmostGenID(), bound1)); | 192 REPORTER_ASSERT(reporter, !cache.canReuse(clip1.getTopmostGenID(), bound1)); |
193 | 193 |
194 // pop the state | 194 // pop the state |
195 cache.pop(); | 195 cache.pop(); |
196 | 196 |
197 // verify that the old state is restored | 197 // verify that the old state is restored |
198 check_state(reporter, cache, clip1, texture1, bound1); | 198 check_state(reporter, cache, clip1, texture1, bound1); |
199 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | 199 REPORTER_ASSERT(reporter, texture1->getRefCnt()); |
200 REPORTER_ASSERT(reporter, texture2->getRefCnt()); | |
201 | 200 |
202 // manually clear the state | 201 // manually clear the state |
203 cache.reset(); | 202 cache.reset(); |
204 | 203 |
205 // verify it is now empty | 204 // verify it is now empty |
206 check_state(reporter, cache, emptyClip, NULL, emptyBound); | 205 check_state(reporter, cache, emptyClip, NULL, emptyBound); |
207 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | |
208 REPORTER_ASSERT(reporter, texture2->getRefCnt()); | |
209 | 206 |
210 // pop again - so there is no state | 207 // pop again - so there is no state |
211 cache.pop(); | 208 cache.pop(); |
212 | 209 |
213 #if !defined(SK_DEBUG) | 210 #if !defined(SK_DEBUG) |
214 // verify that the getters don't crash | 211 // verify that the getters don't crash |
215 // only do in release since it generates asserts in debug | 212 // only do in release since it generates asserts in debug |
216 check_state(reporter, cache, emptyClip, NULL, emptyBound); | 213 check_state(reporter, cache, emptyClip, NULL, emptyBound); |
217 #endif | 214 #endif |
218 REPORTER_ASSERT(reporter, texture1->getRefCnt()); | |
219 REPORTER_ASSERT(reporter, texture2->getRefCnt()); | |
220 } | 215 } |
221 | 216 |
222 //////////////////////////////////////////////////////////////////////////////// | 217 //////////////////////////////////////////////////////////////////////////////// |
223 static void TestClipCache(skiatest::Reporter* reporter, GrContextFactory* factor
y) { | 218 static void TestClipCache(skiatest::Reporter* reporter, GrContextFactory* factor
y) { |
224 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { | 219 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
225 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); | 220 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); |
226 if (!GrContextFactory::IsRenderingGLContext(glType)) { | 221 if (!GrContextFactory::IsRenderingGLContext(glType)) { |
227 continue; | 222 continue; |
228 } | 223 } |
229 GrContext* context = factory->get(glType); | 224 GrContext* context = factory->get(glType); |
230 if (NULL == context) { | 225 if (NULL == context) { |
231 continue; | 226 continue; |
232 } | 227 } |
233 | 228 |
234 test_cache(reporter, context); | 229 test_cache(reporter, context); |
235 test_clip_bounds(reporter, context); | 230 test_clip_bounds(reporter, context); |
236 } | 231 } |
237 } | 232 } |
238 | 233 |
239 //////////////////////////////////////////////////////////////////////////////// | 234 //////////////////////////////////////////////////////////////////////////////// |
240 #include "TestClassDef.h" | 235 #include "TestClassDef.h" |
241 DEFINE_GPUTESTCLASS("ClipCache", ClipCacheTestClass, TestClipCache) | 236 DEFINE_GPUTESTCLASS("ClipCache", ClipCacheTestClass, TestClipCache) |
242 | 237 |
243 #endif | 238 #endif |
OLD | NEW |