OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 #include "GrReducedClip.h" | 10 #include "GrReducedClip.h" |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 tightBounds); | 973 tightBounds); |
974 | 974 |
975 REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID != reducedGenID); | 975 REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID != reducedGenID); |
976 | 976 |
977 // Build a new clip stack based on the reduced clip elements | 977 // Build a new clip stack based on the reduced clip elements |
978 SkClipStack reducedStack; | 978 SkClipStack reducedStack; |
979 if (GrReducedClip::kAllOut_InitialState == initial) { | 979 if (GrReducedClip::kAllOut_InitialState == initial) { |
980 // whether the result is bounded or not, the whole plane should star
t outside the clip. | 980 // whether the result is bounded or not, the whole plane should star
t outside the clip. |
981 reducedStack.clipEmpty(); | 981 reducedStack.clipEmpty(); |
982 } | 982 } |
983 for (ElementList::Iter iter = reducedClips.headIter(); NULL != iter.get(
); iter.next()) { | 983 for (ElementList::Iter iter = reducedClips.headIter(); iter.get(); iter.
next()) { |
984 add_elem_to_stack(*iter.get(), &reducedStack); | 984 add_elem_to_stack(*iter.get(), &reducedStack); |
985 } | 985 } |
986 | 986 |
987 // GrReducedClipStack assumes that the final result is clipped to the re
turned bounds | 987 // GrReducedClipStack assumes that the final result is clipped to the re
turned bounds |
988 if (NULL != tightBounds) { | 988 if (tightBounds) { |
989 reducedStack.clipDevRect(*tightBounds, SkRegion::kIntersect_Op); | 989 reducedStack.clipDevRect(*tightBounds, SkRegion::kIntersect_Op); |
990 } | 990 } |
991 | 991 |
992 // convert both the original stack and reduced stack to SkRegions and se
e if they're equal | 992 // convert both the original stack and reduced stack to SkRegions and se
e if they're equal |
993 SkRegion region; | 993 SkRegion region; |
994 SkRegion reducedRegion; | 994 SkRegion reducedRegion; |
995 | 995 |
996 region.setRect(inflatedIBounds); | 996 region.setRect(inflatedIBounds); |
997 const SkClipStack::Element* element; | 997 const SkClipStack::Element* element; |
998 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); | 998 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 for (size_t i = 0; i < SK_ARRAY_COUNT(gRects); i++) { | 1184 for (size_t i = 0; i < SK_ARRAY_COUNT(gRects); i++) { |
1185 stack.clipDevRect(gRects[i], SkRegion::kIntersect_Op); | 1185 stack.clipDevRect(gRects[i], SkRegion::kIntersect_Op); |
1186 } | 1186 } |
1187 | 1187 |
1188 // all of the above rects should have been intersected, leaving only 1 rect | 1188 // all of the above rects should have been intersected, leaving only 1 rect |
1189 SkClipStack::B2TIter iter(stack); | 1189 SkClipStack::B2TIter iter(stack); |
1190 const SkClipStack::Element* element = iter.next(); | 1190 const SkClipStack::Element* element = iter.next(); |
1191 SkRect answer; | 1191 SkRect answer; |
1192 answer.iset(25, 25, 75, 75); | 1192 answer.iset(25, 25, 75, 75); |
1193 | 1193 |
1194 REPORTER_ASSERT(reporter, NULL != element); | 1194 REPORTER_ASSERT(reporter, element); |
1195 REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == element->getTy
pe()); | 1195 REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == element->getTy
pe()); |
1196 REPORTER_ASSERT(reporter, SkRegion::kIntersect_Op == element->getOp()); | 1196 REPORTER_ASSERT(reporter, SkRegion::kIntersect_Op == element->getOp()); |
1197 REPORTER_ASSERT(reporter, element->getRect() == answer); | 1197 REPORTER_ASSERT(reporter, element->getRect() == answer); |
1198 // now check that we only had one in our iterator | 1198 // now check that we only had one in our iterator |
1199 REPORTER_ASSERT(reporter, !iter.next()); | 1199 REPORTER_ASSERT(reporter, !iter.next()); |
1200 | 1200 |
1201 stack.reset(); | 1201 stack.reset(); |
1202 REPORTER_ASSERT(reporter, 0 == stack.getSaveCount()); | 1202 REPORTER_ASSERT(reporter, 0 == stack.getSaveCount()); |
1203 assert_count(reporter, stack, 0); | 1203 assert_count(reporter, stack, 0); |
1204 | 1204 |
1205 test_assign_and_comparison(reporter); | 1205 test_assign_and_comparison(reporter); |
1206 test_iterators(reporter); | 1206 test_iterators(reporter); |
1207 test_bounds(reporter, SkClipStack::Element::kRect_Type); | 1207 test_bounds(reporter, SkClipStack::Element::kRect_Type); |
1208 test_bounds(reporter, SkClipStack::Element::kRRect_Type); | 1208 test_bounds(reporter, SkClipStack::Element::kRRect_Type); |
1209 test_bounds(reporter, SkClipStack::Element::kPath_Type); | 1209 test_bounds(reporter, SkClipStack::Element::kPath_Type); |
1210 test_isWideOpen(reporter); | 1210 test_isWideOpen(reporter); |
1211 test_rect_merging(reporter); | 1211 test_rect_merging(reporter); |
1212 test_rect_replace(reporter); | 1212 test_rect_replace(reporter); |
1213 test_rect_inverse_fill(reporter); | 1213 test_rect_inverse_fill(reporter); |
1214 test_path_replace(reporter); | 1214 test_path_replace(reporter); |
1215 test_quickContains(reporter); | 1215 test_quickContains(reporter); |
1216 #if SK_SUPPORT_GPU | 1216 #if SK_SUPPORT_GPU |
1217 test_reduced_clip_stack(reporter); | 1217 test_reduced_clip_stack(reporter); |
1218 test_reduced_clip_stack_genid(reporter); | 1218 test_reduced_clip_stack_genid(reporter); |
1219 test_reduced_clip_stack_no_aa_crash(reporter); | 1219 test_reduced_clip_stack_no_aa_crash(reporter); |
1220 #endif | 1220 #endif |
1221 } | 1221 } |
OLD | NEW |