| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 REPORTER_ASSERT(reporter, s == copy); | 51 REPORTER_ASSERT(reporter, s == copy); |
| 52 | 52 |
| 53 // Test that different save levels triggers not equal. | 53 // Test that different save levels triggers not equal. |
| 54 s.restore(); | 54 s.restore(); |
| 55 REPORTER_ASSERT(reporter, 2 == s.getSaveCount()); | 55 REPORTER_ASSERT(reporter, 2 == s.getSaveCount()); |
| 56 REPORTER_ASSERT(reporter, s != copy); | 56 REPORTER_ASSERT(reporter, s != copy); |
| 57 | 57 |
| 58 // Test that an equal, but not copied version is equal. | 58 // Test that an equal, but not copied version is equal. |
| 59 s.save(); | 59 s.save(); |
| 60 REPORTER_ASSERT(reporter, 3 == s.getSaveCount()); | 60 REPORTER_ASSERT(reporter, 3 == s.getSaveCount()); |
| 61 | |
| 62 r = SkRect::MakeLTRB(14, 15, 16, 17); | 61 r = SkRect::MakeLTRB(14, 15, 16, 17); |
| 63 s.clipDevRect(r, SkRegion::kUnion_Op, doAA); | 62 s.clipDevRect(r, SkRegion::kUnion_Op, doAA); |
| 64 REPORTER_ASSERT(reporter, s == copy); | 63 REPORTER_ASSERT(reporter, s == copy); |
| 65 | 64 |
| 66 // Test that a different op on one level triggers not equal. | 65 // Test that a different op on one level triggers not equal. |
| 67 s.restore(); | 66 s.restore(); |
| 68 REPORTER_ASSERT(reporter, 2 == s.getSaveCount()); | 67 REPORTER_ASSERT(reporter, 2 == s.getSaveCount()); |
| 69 s.save(); | 68 s.save(); |
| 70 REPORTER_ASSERT(reporter, 3 == s.getSaveCount()); | 69 REPORTER_ASSERT(reporter, 3 == s.getSaveCount()); |
| 71 | |
| 72 r = SkRect::MakeLTRB(14, 15, 16, 17); | 70 r = SkRect::MakeLTRB(14, 15, 16, 17); |
| 73 s.clipDevRect(r, SkRegion::kIntersect_Op, doAA); | 71 s.clipDevRect(r, SkRegion::kIntersect_Op, doAA); |
| 74 REPORTER_ASSERT(reporter, s != copy); | 72 REPORTER_ASSERT(reporter, s != copy); |
| 75 | 73 |
| 76 // Test that different state (clip type) triggers not equal. | 74 // Test that version constructed with rect-path rather than a rect is still
considered equal. |
| 77 // NO LONGER VALID: if a path contains only a rect, we turn | |
| 78 // it into a bare rect for performance reasons (working | |
| 79 // around Chromium/JavaScript bad pattern). | |
| 80 /* | |
| 81 s.restore(); | 75 s.restore(); |
| 82 s.save(); | 76 s.save(); |
| 83 SkPath rp; | 77 SkPath rp; |
| 84 rp.addRect(r); | 78 rp.addRect(r); |
| 85 s.clipDevPath(rp, SkRegion::kUnion_Op, doAA); | 79 s.clipDevPath(rp, SkRegion::kUnion_Op, doAA); |
| 86 REPORTER_ASSERT(reporter, s != copy); | 80 REPORTER_ASSERT(reporter, s == copy); |
| 87 */ | |
| 88 | 81 |
| 89 // Test that different rects triggers not equal. | 82 // Test that different rects triggers not equal. |
| 90 s.restore(); | 83 s.restore(); |
| 91 REPORTER_ASSERT(reporter, 2 == s.getSaveCount()); | 84 REPORTER_ASSERT(reporter, 2 == s.getSaveCount()); |
| 92 s.save(); | 85 s.save(); |
| 93 REPORTER_ASSERT(reporter, 3 == s.getSaveCount()); | 86 REPORTER_ASSERT(reporter, 3 == s.getSaveCount()); |
| 94 | 87 |
| 95 r = SkRect::MakeLTRB(24, 25, 26, 27); | 88 r = SkRect::MakeLTRB(24, 25, 26, 27); |
| 96 s.clipDevRect(r, SkRegion::kUnion_Op, doAA); | 89 s.clipDevRect(r, SkRegion::kUnion_Op, doAA); |
| 97 REPORTER_ASSERT(reporter, s != copy); | 90 REPORTER_ASSERT(reporter, s != copy); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 178 |
| 186 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); | 179 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); |
| 187 | 180 |
| 188 element = iter.skipToTopmost(SkRegion::kUnion_Op); | 181 element = iter.skipToTopmost(SkRegion::kUnion_Op); |
| 189 REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == element->g
etType()); | 182 REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == element->g
etType()); |
| 190 REPORTER_ASSERT(reporter, element->getRect() == gRects[3]); | 183 REPORTER_ASSERT(reporter, element->getRect() == gRects[3]); |
| 191 } | 184 } |
| 192 } | 185 } |
| 193 | 186 |
| 194 // Exercise the SkClipStack's getConservativeBounds computation | 187 // Exercise the SkClipStack's getConservativeBounds computation |
| 195 static void test_bounds(skiatest::Reporter* reporter, bool useRects) { | 188 static void test_bounds(skiatest::Reporter* reporter, SkClipStack::Element::Type
primType) { |
| 189 SkASSERT(SkClipStack::Element::kEmpty_Type != primType); |
| 196 | 190 |
| 197 static const int gNumCases = 20; | 191 static const int gNumCases = 20; |
| 198 static const SkRect gAnswerRectsBW[gNumCases] = { | 192 static const SkRect gAnswerRectsBW[gNumCases] = { |
| 199 // A op B | 193 // A op B |
| 200 { 40, 40, 50, 50 }, | 194 { 40, 40, 50, 50 }, |
| 201 { 10, 10, 50, 50 }, | 195 { 10, 10, 50, 50 }, |
| 202 { 10, 10, 80, 80 }, | 196 { 10, 10, 80, 80 }, |
| 203 { 10, 10, 80, 80 }, | 197 { 10, 10, 80, 80 }, |
| 204 { 40, 40, 80, 80 }, | 198 { 40, 40, 80, 80 }, |
| 205 | 199 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 231 SkRegion::kUnion_Op, | 225 SkRegion::kUnion_Op, |
| 232 SkRegion::kXOR_Op, | 226 SkRegion::kXOR_Op, |
| 233 SkRegion::kReverseDifference_Op | 227 SkRegion::kReverseDifference_Op |
| 234 }; | 228 }; |
| 235 | 229 |
| 236 SkRect rectA, rectB; | 230 SkRect rectA, rectB; |
| 237 | 231 |
| 238 rectA.iset(10, 10, 50, 50); | 232 rectA.iset(10, 10, 50, 50); |
| 239 rectB.iset(40, 40, 80, 80); | 233 rectB.iset(40, 40, 80, 80); |
| 240 | 234 |
| 241 SkPath clipA, clipB; | 235 SkRRect rrectA, rrectB; |
| 236 rrectA.setOval(rectA); |
| 237 rrectB.setRectXY(rectB, SkIntToScalar(1), SkIntToScalar(2)); |
| 242 | 238 |
| 243 clipA.addRoundRect(rectA, SkIntToScalar(5), SkIntToScalar(5)); | 239 SkPath pathA, pathB; |
| 244 clipB.addRoundRect(rectB, SkIntToScalar(5), SkIntToScalar(5)); | 240 |
| 241 pathA.addRoundRect(rectA, SkIntToScalar(5), SkIntToScalar(5)); |
| 242 pathB.addRoundRect(rectB, SkIntToScalar(5), SkIntToScalar(5)); |
| 245 | 243 |
| 246 SkClipStack stack; | 244 SkClipStack stack; |
| 247 SkRect devClipBound; | 245 SkRect devClipBound; |
| 248 bool isIntersectionOfRects = false; | 246 bool isIntersectionOfRects = false; |
| 249 | 247 |
| 250 int testCase = 0; | 248 int testCase = 0; |
| 251 int numBitTests = useRects ? 1 : 4; | 249 int numBitTests = SkClipStack::Element::kPath_Type == primType ? 4 : 1; |
| 252 for (int invBits = 0; invBits < numBitTests; ++invBits) { | 250 for (int invBits = 0; invBits < numBitTests; ++invBits) { |
| 253 for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) { | 251 for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) { |
| 254 | 252 |
| 255 stack.save(); | 253 stack.save(); |
| 256 bool doInvA = SkToBool(invBits & 1); | 254 bool doInvA = SkToBool(invBits & 1); |
| 257 bool doInvB = SkToBool(invBits & 2); | 255 bool doInvB = SkToBool(invBits & 2); |
| 258 | 256 |
| 259 clipA.setFillType(doInvA ? SkPath::kInverseEvenOdd_FillType : | 257 pathA.setFillType(doInvA ? SkPath::kInverseEvenOdd_FillType : |
| 260 SkPath::kEvenOdd_FillType); | 258 SkPath::kEvenOdd_FillType); |
| 261 clipB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType : | 259 pathB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType : |
| 262 SkPath::kEvenOdd_FillType); | 260 SkPath::kEvenOdd_FillType); |
| 263 | 261 |
| 264 if (useRects) { | 262 switch (primType) { |
| 265 stack.clipDevRect(rectA, SkRegion::kIntersect_Op, false); | 263 case SkClipStack::Element::kRect_Type: |
| 266 stack.clipDevRect(rectB, gOps[op], false); | 264 stack.clipDevRect(rectA, SkRegion::kIntersect_Op, false); |
| 267 } else { | 265 stack.clipDevRect(rectB, gOps[op], false); |
| 268 stack.clipDevPath(clipA, SkRegion::kIntersect_Op, false); | 266 break; |
| 269 stack.clipDevPath(clipB, gOps[op], false); | 267 case SkClipStack::Element::kRRect_Type: |
| 268 stack.clipDevRRect(rrectA, SkRegion::kIntersect_Op, false); |
| 269 stack.clipDevRRect(rrectB, gOps[op], false); |
| 270 break; |
| 271 case SkClipStack::Element::kPath_Type: |
| 272 stack.clipDevPath(pathA, SkRegion::kIntersect_Op, false); |
| 273 stack.clipDevPath(pathB, gOps[op], false); |
| 274 break; |
| 270 } | 275 } |
| 271 | 276 |
| 272 REPORTER_ASSERT(reporter, !stack.isWideOpen()); | 277 REPORTER_ASSERT(reporter, !stack.isWideOpen()); |
| 273 REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID != stack.getTo
pmostGenID()); | 278 REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID != stack.getTo
pmostGenID()); |
| 274 | 279 |
| 275 stack.getConservativeBounds(0, 0, 100, 100, &devClipBound, | 280 stack.getConservativeBounds(0, 0, 100, 100, &devClipBound, |
| 276 &isIntersectionOfRects); | 281 &isIntersectionOfRects); |
| 277 | 282 |
| 278 if (useRects) { | 283 if (SkClipStack::Element::kRect_Type == primType) { |
| 279 REPORTER_ASSERT(reporter, isIntersectionOfRects == | 284 REPORTER_ASSERT(reporter, isIntersectionOfRects == |
| 280 (gOps[op] == SkRegion::kIntersect_Op)); | 285 (gOps[op] == SkRegion::kIntersect_Op)); |
| 281 } else { | 286 } else { |
| 282 REPORTER_ASSERT(reporter, !isIntersectionOfRects); | 287 REPORTER_ASSERT(reporter, !isIntersectionOfRects); |
| 283 } | 288 } |
| 284 | 289 |
| 285 SkASSERT(testCase < gNumCases); | 290 SkASSERT(testCase < gNumCases); |
| 286 REPORTER_ASSERT(reporter, devClipBound == gAnswerRectsBW[testCase]); | 291 REPORTER_ASSERT(reporter, devClipBound == gAnswerRectsBW[testCase]); |
| 287 ++testCase; | 292 ++testCase; |
| 288 | 293 |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 // Functions that add a shape to the clip stack. The shape is computed from a re
ctangle. | 799 // Functions that add a shape to the clip stack. The shape is computed from a re
ctangle. |
| 795 // AA is always disabled since the clip stack reducer can cause changes in aa ra
sterization of the | 800 // AA is always disabled since the clip stack reducer can cause changes in aa ra
sterization of the |
| 796 // stack. A fractional edge repeated in different elements may be rasterized few
er times using the | 801 // stack. A fractional edge repeated in different elements may be rasterized few
er times using the |
| 797 // reduced stack. | 802 // reduced stack. |
| 798 typedef void (*AddElementFunc) (const SkRect& rect, | 803 typedef void (*AddElementFunc) (const SkRect& rect, |
| 799 bool invert, | 804 bool invert, |
| 800 SkRegion::Op op, | 805 SkRegion::Op op, |
| 801 SkClipStack* stack); | 806 SkClipStack* stack); |
| 802 | 807 |
| 803 static void add_round_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkC
lipStack* stack) { | 808 static void add_round_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkC
lipStack* stack) { |
| 804 SkPath path; | |
| 805 SkScalar rx = rect.width() / 10; | 809 SkScalar rx = rect.width() / 10; |
| 806 SkScalar ry = rect.height() / 20; | 810 SkScalar ry = rect.height() / 20; |
| 807 path.addRoundRect(rect, rx, ry); | |
| 808 if (invert) { | 811 if (invert) { |
| 812 SkPath path; |
| 813 path.addRoundRect(rect, rx, ry); |
| 809 path.setFillType(SkPath::kInverseWinding_FillType); | 814 path.setFillType(SkPath::kInverseWinding_FillType); |
| 815 stack->clipDevPath(path, op, false); |
| 816 } else { |
| 817 SkRRect rrect; |
| 818 rrect.setRectXY(rect, rx, ry); |
| 819 stack->clipDevRRect(rrect, op, false); |
| 810 } | 820 } |
| 811 stack->clipDevPath(path, op, false); | |
| 812 }; | 821 }; |
| 813 | 822 |
| 814 static void add_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkClipSta
ck* stack) { | 823 static void add_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkClipSta
ck* stack) { |
| 815 if (invert) { | 824 if (invert) { |
| 816 SkPath path; | 825 SkPath path; |
| 817 path.addRect(rect); | 826 path.addRect(rect); |
| 818 path.setFillType(SkPath::kInverseWinding_FillType); | 827 path.setFillType(SkPath::kInverseWinding_FillType); |
| 819 stack->clipDevPath(path, op, false); | 828 stack->clipDevPath(path, op, false); |
| 820 } else { | 829 } else { |
| 821 stack->clipDevRect(rect, op, false); | 830 stack->clipDevRect(rect, op, false); |
| 822 } | 831 } |
| 823 }; | 832 }; |
| 824 | 833 |
| 825 static void add_oval(const SkRect& rect, bool invert, SkRegion::Op op, SkClipSta
ck* stack) { | 834 static void add_oval(const SkRect& rect, bool invert, SkRegion::Op op, SkClipSta
ck* stack) { |
| 826 SkPath path; | 835 SkPath path; |
| 827 path.addOval(rect); | 836 path.addOval(rect); |
| 828 if (invert) { | 837 if (invert) { |
| 829 path.setFillType(SkPath::kInverseWinding_FillType); | 838 path.setFillType(SkPath::kInverseWinding_FillType); |
| 830 } | 839 } |
| 831 stack->clipDevPath(path, op, false); | 840 stack->clipDevPath(path, op, false); |
| 832 }; | 841 }; |
| 833 | 842 |
| 834 static void add_elem_to_stack(const SkClipStack::Element& element, SkClipStack*
stack) { | 843 static void add_elem_to_stack(const SkClipStack::Element& element, SkClipStack*
stack) { |
| 835 switch (element.getType()) { | 844 switch (element.getType()) { |
| 836 case SkClipStack::Element::kRect_Type: | 845 case SkClipStack::Element::kRect_Type: |
| 837 stack->clipDevRect(element.getRect(), element.getOp(), element.isAA(
)); | 846 stack->clipDevRect(element.getRect(), element.getOp(), element.isAA(
)); |
| 838 break; | 847 break; |
| 848 case SkClipStack::Element::kRRect_Type: |
| 849 stack->clipDevRRect(element.getRRect(), element.getOp(), element.isA
A()); |
| 850 break; |
| 839 case SkClipStack::Element::kPath_Type: | 851 case SkClipStack::Element::kPath_Type: |
| 840 stack->clipDevPath(element.getPath(), element.getOp(), element.isAA(
)); | 852 stack->clipDevPath(element.getPath(), element.getOp(), element.isAA(
)); |
| 841 break; | 853 break; |
| 842 case SkClipStack::Element::kEmpty_Type: | 854 case SkClipStack::Element::kEmpty_Type: |
| 843 SkDEBUGFAIL("Why did the reducer produce an explicit empty."); | 855 SkDEBUGFAIL("Why did the reducer produce an explicit empty."); |
| 844 stack->clipEmpty(); | 856 stack->clipEmpty(); |
| 845 break; | 857 break; |
| 846 } | 858 } |
| 847 } | 859 } |
| 848 | 860 |
| 849 static void add_elem_to_region(const SkClipStack::Element& element, | 861 static void add_elem_to_region(const SkClipStack::Element& element, |
| 850 const SkIRect& bounds, | 862 const SkIRect& bounds, |
| 851 SkRegion* region) { | 863 SkRegion* region) { |
| 852 SkRegion elemRegion; | 864 SkRegion elemRegion; |
| 853 SkRegion boundsRgn(bounds); | 865 SkRegion boundsRgn(bounds); |
| 866 SkPath path; |
| 854 | 867 |
| 855 switch (element.getType()) { | 868 switch (element.getType()) { |
| 856 case SkClipStack::Element::kRect_Type: { | 869 case SkClipStack::Element::kEmpty_Type: |
| 857 SkPath path; | 870 elemRegion.setEmpty(); |
| 858 path.addRect(element.getRect()); | 871 break; |
| 872 default: |
| 873 element.asPath(&path); |
| 859 elemRegion.setPath(path, boundsRgn); | 874 elemRegion.setPath(path, boundsRgn); |
| 860 break; | 875 break; |
| 861 } | |
| 862 case SkClipStack::Element::kPath_Type: | |
| 863 elemRegion.setPath(element.getPath(), boundsRgn); | |
| 864 break; | |
| 865 case SkClipStack::Element::kEmpty_Type: | |
| 866 // | |
| 867 region->setEmpty(); | |
| 868 return; | |
| 869 } | 876 } |
| 870 region->op(elemRegion, element.getOp()); | 877 region->op(elemRegion, element.getOp()); |
| 871 } | 878 } |
| 872 | 879 |
| 873 static void test_reduced_clip_stack(skiatest::Reporter* reporter) { | 880 static void test_reduced_clip_stack(skiatest::Reporter* reporter) { |
| 874 // We construct random clip stacks, reduce them, and then rasterize both ver
sions to verify that | 881 // We construct random clip stacks, reduce them, and then rasterize both ver
sions to verify that |
| 875 // they are equal. | 882 // they are equal. |
| 876 | 883 |
| 877 // All the clip elements will be contained within these bounds. | 884 // All the clip elements will be contained within these bounds. |
| 878 static const SkRect kBounds = SkRect::MakeWH(100, 100); | 885 static const SkRect kBounds = SkRect::MakeWH(100, 100); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 SkSize size = SkSize::Make( | 938 SkSize size = SkSize::Make( |
| 932 SkScalarFloorToScalar(SkScalarMul(kBounds.width(), r.nextRangeSc
alar(kMinElemSizeFrac, kMaxElemSizeFrac))), | 939 SkScalarFloorToScalar(SkScalarMul(kBounds.width(), r.nextRangeSc
alar(kMinElemSizeFrac, kMaxElemSizeFrac))), |
| 933 SkScalarFloorToScalar(SkScalarMul(kBounds.height(), r.nextRangeS
calar(kMinElemSizeFrac, kMaxElemSizeFrac)))); | 940 SkScalarFloorToScalar(SkScalarMul(kBounds.height(), r.nextRangeS
calar(kMinElemSizeFrac, kMaxElemSizeFrac)))); |
| 934 | 941 |
| 935 SkPoint xy = {SkScalarFloorToScalar(r.nextRangeScalar(kBounds.fLeft,
kBounds.fRight - size.fWidth)), | 942 SkPoint xy = {SkScalarFloorToScalar(r.nextRangeScalar(kBounds.fLeft,
kBounds.fRight - size.fWidth)), |
| 936 SkScalarFloorToScalar(r.nextRangeScalar(kBounds.fTop,
kBounds.fBottom - size.fHeight))}; | 943 SkScalarFloorToScalar(r.nextRangeScalar(kBounds.fTop,
kBounds.fBottom - size.fHeight))}; |
| 937 | 944 |
| 938 SkRect rect = SkRect::MakeXYWH(xy.fX, xy.fY, size.fWidth, size.fHeig
ht); | 945 SkRect rect = SkRect::MakeXYWH(xy.fX, xy.fY, size.fWidth, size.fHeig
ht); |
| 939 | 946 |
| 940 bool invert = r.nextBiasedBool(kFractionInverted); | 947 bool invert = r.nextBiasedBool(kFractionInverted); |
| 948 |
| 941 kElementFuncs[r.nextULessThan(SK_ARRAY_COUNT(kElementFuncs))](rect,
invert, op, &stack); | 949 kElementFuncs[r.nextULessThan(SK_ARRAY_COUNT(kElementFuncs))](rect,
invert, op, &stack); |
| 942 if (doSave) { | 950 if (doSave) { |
| 943 stack.save(); | 951 stack.save(); |
| 944 } | 952 } |
| 945 } | 953 } |
| 946 | 954 |
| 947 SkRect inflatedBounds = kBounds; | 955 SkRect inflatedBounds = kBounds; |
| 948 inflatedBounds.outset(kBounds.width() / 2, kBounds.height() / 2); | 956 inflatedBounds.outset(kBounds.width() / 2, kBounds.height() / 2); |
| 949 SkIRect inflatedIBounds; | 957 SkIRect inflatedIBounds; |
| 950 inflatedBounds.roundOut(&inflatedIBounds); | 958 inflatedBounds.roundOut(&inflatedIBounds); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); | 997 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); |
| 990 while ((element = iter.next())) { | 998 while ((element = iter.next())) { |
| 991 add_elem_to_region(*element, inflatedIBounds, ®ion); | 999 add_elem_to_region(*element, inflatedIBounds, ®ion); |
| 992 } | 1000 } |
| 993 | 1001 |
| 994 reducedRegion.setRect(inflatedIBounds); | 1002 reducedRegion.setRect(inflatedIBounds); |
| 995 iter.reset(reducedStack, SkClipStack::Iter::kBottom_IterStart); | 1003 iter.reset(reducedStack, SkClipStack::Iter::kBottom_IterStart); |
| 996 while ((element = iter.next())) { | 1004 while ((element = iter.next())) { |
| 997 add_elem_to_region(*element, inflatedIBounds, &reducedRegion); | 1005 add_elem_to_region(*element, inflatedIBounds, &reducedRegion); |
| 998 } | 1006 } |
| 999 | 1007 SkString testCase; |
| 1000 REPORTER_ASSERT(reporter, region == reducedRegion); | 1008 testCase.printf("Iteration %d", i); |
| 1009 REPORTER_ASSERT_MESSAGE(reporter, region == reducedRegion, testCase.c_st
r()); |
| 1001 } | 1010 } |
| 1002 } | 1011 } |
| 1003 | 1012 |
| 1004 #if defined(WIN32) | 1013 #if defined(WIN32) |
| 1005 #define SUPPRESS_VISIBILITY_WARNING | 1014 #define SUPPRESS_VISIBILITY_WARNING |
| 1006 #else | 1015 #else |
| 1007 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) | 1016 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) |
| 1008 #endif | 1017 #endif |
| 1009 | 1018 |
| 1010 static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) { | 1019 static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 REPORTER_ASSERT(reporter, element->getRect() == answer); | 1196 REPORTER_ASSERT(reporter, element->getRect() == answer); |
| 1188 // now check that we only had one in our iterator | 1197 // now check that we only had one in our iterator |
| 1189 REPORTER_ASSERT(reporter, !iter.next()); | 1198 REPORTER_ASSERT(reporter, !iter.next()); |
| 1190 | 1199 |
| 1191 stack.reset(); | 1200 stack.reset(); |
| 1192 REPORTER_ASSERT(reporter, 0 == stack.getSaveCount()); | 1201 REPORTER_ASSERT(reporter, 0 == stack.getSaveCount()); |
| 1193 assert_count(reporter, stack, 0); | 1202 assert_count(reporter, stack, 0); |
| 1194 | 1203 |
| 1195 test_assign_and_comparison(reporter); | 1204 test_assign_and_comparison(reporter); |
| 1196 test_iterators(reporter); | 1205 test_iterators(reporter); |
| 1197 test_bounds(reporter, true); // once with rects | 1206 test_bounds(reporter, SkClipStack::Element::kRect_Type); |
| 1198 test_bounds(reporter, false); // once with paths | 1207 test_bounds(reporter, SkClipStack::Element::kRRect_Type); |
| 1208 test_bounds(reporter, SkClipStack::Element::kPath_Type); |
| 1199 test_isWideOpen(reporter); | 1209 test_isWideOpen(reporter); |
| 1200 test_rect_merging(reporter); | 1210 test_rect_merging(reporter); |
| 1201 test_rect_replace(reporter); | 1211 test_rect_replace(reporter); |
| 1202 test_rect_inverse_fill(reporter); | 1212 test_rect_inverse_fill(reporter); |
| 1203 test_path_replace(reporter); | 1213 test_path_replace(reporter); |
| 1204 test_quickContains(reporter); | 1214 test_quickContains(reporter); |
| 1205 #if SK_SUPPORT_GPU | 1215 #if SK_SUPPORT_GPU |
| 1206 test_reduced_clip_stack(reporter); | 1216 test_reduced_clip_stack(reporter); |
| 1207 test_reduced_clip_stack_genid(reporter); | 1217 test_reduced_clip_stack_genid(reporter); |
| 1208 test_reduced_clip_stack_no_aa_crash(reporter); | 1218 test_reduced_clip_stack_no_aa_crash(reporter); |
| 1209 #endif | 1219 #endif |
| 1210 } | 1220 } |
| OLD | NEW |