| 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 #include "RefCntIs.h" | |
| 10 // This is a GR test | 9 // This is a GR test |
| 11 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| 12 #include "../../src/gpu/GrClipMaskManager.h" | 11 #include "../../src/gpu/GrClipMaskManager.h" |
| 13 #include "GrContextFactory.h" | 12 #include "GrContextFactory.h" |
| 14 #include "SkGpuDevice.h" | 13 #include "SkGpuDevice.h" |
| 15 | 14 |
| 16 static const int X_SIZE = 12; | 15 static const int X_SIZE = 12; |
| 17 static const int Y_SIZE = 12; | 16 static const int Y_SIZE = 12; |
| 18 | 17 |
| 19 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 cache.acquireMask(clip1.getTopmostGenID(), desc, bound1); | 157 cache.acquireMask(clip1.getTopmostGenID(), desc, bound1); |
| 159 | 158 |
| 160 GrTexture* texture1 = cache.getLastMask(); | 159 GrTexture* texture1 = cache.getLastMask(); |
| 161 REPORTER_ASSERT(reporter, texture1); | 160 REPORTER_ASSERT(reporter, texture1); |
| 162 if (NULL == texture1) { | 161 if (NULL == texture1) { |
| 163 return; | 162 return; |
| 164 } | 163 } |
| 165 | 164 |
| 166 // check that the set took | 165 // check that the set took |
| 167 check_state(reporter, cache, clip1, texture1, bound1); | 166 check_state(reporter, cache, clip1, texture1, bound1); |
| 168 REPORTER_ASSERT(reporter, !RefCntIs(*texture1, 0)); | 167 REPORTER_ASSERT(reporter, texture1->getRefCnt()); |
| 169 | 168 |
| 170 // push the state | 169 // push the state |
| 171 cache.push(); | 170 cache.push(); |
| 172 | 171 |
| 173 // verify that the pushed state is initially empty | 172 // verify that the pushed state is initially empty |
| 174 check_empty_state(reporter, cache); | 173 check_empty_state(reporter, cache); |
| 175 REPORTER_ASSERT(reporter, !RefCntIs(*texture1, 0)); | 174 REPORTER_ASSERT(reporter, texture1->getRefCnt()); |
| 176 | 175 |
| 177 // modify the new state | 176 // modify the new state |
| 178 SkIRect bound2; | 177 SkIRect bound2; |
| 179 bound2.set(-10, -10, 10, 10); | 178 bound2.set(-10, -10, 10, 10); |
| 180 | 179 |
| 181 SkClipStack clip2(bound2); | 180 SkClipStack clip2(bound2); |
| 182 | 181 |
| 183 cache.acquireMask(clip2.getTopmostGenID(), desc, bound2); | 182 cache.acquireMask(clip2.getTopmostGenID(), desc, bound2); |
| 184 | 183 |
| 185 GrTexture* texture2 = cache.getLastMask(); | 184 GrTexture* texture2 = cache.getLastMask(); |
| 186 REPORTER_ASSERT(reporter, texture2); | 185 REPORTER_ASSERT(reporter, texture2); |
| 187 if (NULL == texture2) { | 186 if (NULL == texture2) { |
| 188 return; | 187 return; |
| 189 } | 188 } |
| 190 | 189 |
| 191 // check that the changes took | 190 // check that the changes took |
| 192 check_state(reporter, cache, clip2, texture2, bound2); | 191 check_state(reporter, cache, clip2, texture2, bound2); |
| 193 REPORTER_ASSERT(reporter, !RefCntIs(*texture1, 0)); | 192 REPORTER_ASSERT(reporter, texture1->getRefCnt()); |
| 194 REPORTER_ASSERT(reporter, !RefCntIs(*texture2, 0)); | 193 REPORTER_ASSERT(reporter, texture2->getRefCnt()); |
| 195 | 194 |
| 196 // check to make sure canReuse works | 195 // check to make sure canReuse works |
| 197 REPORTER_ASSERT(reporter, cache.canReuse(clip2.getTopmostGenID(), bound2)); | 196 REPORTER_ASSERT(reporter, cache.canReuse(clip2.getTopmostGenID(), bound2)); |
| 198 REPORTER_ASSERT(reporter, !cache.canReuse(clip1.getTopmostGenID(), bound1)); | 197 REPORTER_ASSERT(reporter, !cache.canReuse(clip1.getTopmostGenID(), bound1)); |
| 199 | 198 |
| 200 // pop the state | 199 // pop the state |
| 201 cache.pop(); | 200 cache.pop(); |
| 202 | 201 |
| 203 // verify that the old state is restored | 202 // verify that the old state is restored |
| 204 check_state(reporter, cache, clip1, texture1, bound1); | 203 check_state(reporter, cache, clip1, texture1, bound1); |
| 205 REPORTER_ASSERT(reporter, !RefCntIs(*texture1, 0)); | 204 REPORTER_ASSERT(reporter, texture1->getRefCnt()); |
| 206 | 205 |
| 207 // manually clear the state | 206 // manually clear the state |
| 208 cache.reset(); | 207 cache.reset(); |
| 209 | 208 |
| 210 // verify it is now empty | 209 // verify it is now empty |
| 211 check_empty_state(reporter, cache); | 210 check_empty_state(reporter, cache); |
| 212 | 211 |
| 213 // pop again - so there is no state | 212 // pop again - so there is no state |
| 214 cache.pop(); | 213 cache.pop(); |
| 215 | 214 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 230 if (NULL == context) { | 229 if (NULL == context) { |
| 231 continue; | 230 continue; |
| 232 } | 231 } |
| 233 | 232 |
| 234 test_cache(reporter, context); | 233 test_cache(reporter, context); |
| 235 test_clip_bounds(reporter, context); | 234 test_clip_bounds(reporter, context); |
| 236 } | 235 } |
| 237 } | 236 } |
| 238 | 237 |
| 239 #endif | 238 #endif |
| OLD | NEW |