| 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) { |
| 196 | |
| 197 static const int gNumCases = 20; | 189 static const int gNumCases = 20; |
| 198 static const SkRect gAnswerRectsBW[gNumCases] = { | 190 static const SkRect gAnswerRectsBW[gNumCases] = { |
| 199 // A op B | 191 // A op B |
| 200 { 40, 40, 50, 50 }, | 192 { 40, 40, 50, 50 }, |
| 201 { 10, 10, 50, 50 }, | 193 { 10, 10, 50, 50 }, |
| 202 { 10, 10, 80, 80 }, | 194 { 10, 10, 80, 80 }, |
| 203 { 10, 10, 80, 80 }, | 195 { 10, 10, 80, 80 }, |
| 204 { 40, 40, 80, 80 }, | 196 { 40, 40, 80, 80 }, |
| 205 | 197 |
| 206 // invA op B | 198 // invA op B |
| (...skipping 24 matching lines...) Expand all Loading... |
| 231 SkRegion::kUnion_Op, | 223 SkRegion::kUnion_Op, |
| 232 SkRegion::kXOR_Op, | 224 SkRegion::kXOR_Op, |
| 233 SkRegion::kReverseDifference_Op | 225 SkRegion::kReverseDifference_Op |
| 234 }; | 226 }; |
| 235 | 227 |
| 236 SkRect rectA, rectB; | 228 SkRect rectA, rectB; |
| 237 | 229 |
| 238 rectA.iset(10, 10, 50, 50); | 230 rectA.iset(10, 10, 50, 50); |
| 239 rectB.iset(40, 40, 80, 80); | 231 rectB.iset(40, 40, 80, 80); |
| 240 | 232 |
| 241 SkPath clipA, clipB; | 233 SkRRect rrectA, rrectB; |
| 234 rrectA.setOval(rectA); |
| 235 rrectB.setRectXY(rectB, SkIntToScalar(1), SkIntToScalar(2)); |
| 242 | 236 |
| 243 clipA.addRoundRect(rectA, SkIntToScalar(5), SkIntToScalar(5)); | 237 SkPath pathA, pathB; |
| 244 clipB.addRoundRect(rectB, SkIntToScalar(5), SkIntToScalar(5)); | 238 |
| 239 pathA.addRoundRect(rectA, SkIntToScalar(5), SkIntToScalar(5)); |
| 240 pathB.addRoundRect(rectB, SkIntToScalar(5), SkIntToScalar(5)); |
| 245 | 241 |
| 246 SkClipStack stack; | 242 SkClipStack stack; |
| 247 SkRect devClipBound; | 243 SkRect devClipBound; |
| 248 bool isIntersectionOfRects = false; | 244 bool isIntersectionOfRects = false; |
| 249 | 245 |
| 250 int testCase = 0; | 246 int testCase = 0; |
| 251 int numBitTests = useRects ? 1 : 4; | 247 int numBitTests = SkClipStack::Element::kPath_Type == primType ? 4 : 1; |
| 252 for (int invBits = 0; invBits < numBitTests; ++invBits) { | 248 for (int invBits = 0; invBits < numBitTests; ++invBits) { |
| 253 for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) { | 249 for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) { |
| 254 | 250 |
| 255 stack.save(); | 251 stack.save(); |
| 256 bool doInvA = SkToBool(invBits & 1); | 252 bool doInvA = SkToBool(invBits & 1); |
| 257 bool doInvB = SkToBool(invBits & 2); | 253 bool doInvB = SkToBool(invBits & 2); |
| 258 | 254 |
| 259 clipA.setFillType(doInvA ? SkPath::kInverseEvenOdd_FillType : | 255 pathA.setFillType(doInvA ? SkPath::kInverseEvenOdd_FillType : |
| 260 SkPath::kEvenOdd_FillType); | 256 SkPath::kEvenOdd_FillType); |
| 261 clipB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType : | 257 pathB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType : |
| 262 SkPath::kEvenOdd_FillType); | 258 SkPath::kEvenOdd_FillType); |
| 263 | 259 |
| 264 if (useRects) { | 260 switch (primType) { |
| 265 stack.clipDevRect(rectA, SkRegion::kIntersect_Op, false); | 261 case SkClipStack::Element::kEmpty_Type: |
| 266 stack.clipDevRect(rectB, gOps[op], false); | 262 SkDEBUGFAIL("Don't call this with kEmpty."); |
| 267 } else { | 263 break; |
| 268 stack.clipDevPath(clipA, SkRegion::kIntersect_Op, false); | 264 case SkClipStack::Element::kRect_Type: |
| 269 stack.clipDevPath(clipB, gOps[op], false); | 265 stack.clipDevRect(rectA, SkRegion::kIntersect_Op, false); |
| 266 stack.clipDevRect(rectB, gOps[op], false); |
| 267 break; |
| 268 case SkClipStack::Element::kRRect_Type: |
| 269 stack.clipDevRRect(rrectA, SkRegion::kIntersect_Op, false); |
| 270 stack.clipDevRRect(rrectB, gOps[op], false); |
| 271 break; |
| 272 case SkClipStack::Element::kPath_Type: |
| 273 stack.clipDevPath(pathA, SkRegion::kIntersect_Op, false); |
| 274 stack.clipDevPath(pathB, gOps[op], false); |
| 275 break; |
| 270 } | 276 } |
| 271 | 277 |
| 272 REPORTER_ASSERT(reporter, !stack.isWideOpen()); | 278 REPORTER_ASSERT(reporter, !stack.isWideOpen()); |
| 273 REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID != stack.getTo
pmostGenID()); | 279 REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID != stack.getTo
pmostGenID()); |
| 274 | 280 |
| 275 stack.getConservativeBounds(0, 0, 100, 100, &devClipBound, | 281 stack.getConservativeBounds(0, 0, 100, 100, &devClipBound, |
| 276 &isIntersectionOfRects); | 282 &isIntersectionOfRects); |
| 277 | 283 |
| 278 if (useRects) { | 284 if (SkClipStack::Element::kRect_Type == primType) { |
| 279 REPORTER_ASSERT(reporter, isIntersectionOfRects == | 285 REPORTER_ASSERT(reporter, isIntersectionOfRects == |
| 280 (gOps[op] == SkRegion::kIntersect_Op)); | 286 (gOps[op] == SkRegion::kIntersect_Op)); |
| 281 } else { | 287 } else { |
| 282 REPORTER_ASSERT(reporter, !isIntersectionOfRects); | 288 REPORTER_ASSERT(reporter, !isIntersectionOfRects); |
| 283 } | 289 } |
| 284 | 290 |
| 285 SkASSERT(testCase < gNumCases); | 291 SkASSERT(testCase < gNumCases); |
| 286 REPORTER_ASSERT(reporter, devClipBound == gAnswerRectsBW[testCase]); | 292 REPORTER_ASSERT(reporter, devClipBound == gAnswerRectsBW[testCase]); |
| 287 ++testCase; | 293 ++testCase; |
| 288 | 294 |
| (...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. | 800 // 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 | 801 // 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 | 802 // stack. A fractional edge repeated in different elements may be rasterized few
er times using the |
| 797 // reduced stack. | 803 // reduced stack. |
| 798 typedef void (*AddElementFunc) (const SkRect& rect, | 804 typedef void (*AddElementFunc) (const SkRect& rect, |
| 799 bool invert, | 805 bool invert, |
| 800 SkRegion::Op op, | 806 SkRegion::Op op, |
| 801 SkClipStack* stack); | 807 SkClipStack* stack); |
| 802 | 808 |
| 803 static void add_round_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkC
lipStack* stack) { | 809 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; | 810 SkScalar rx = rect.width() / 10; |
| 806 SkScalar ry = rect.height() / 20; | 811 SkScalar ry = rect.height() / 20; |
| 807 path.addRoundRect(rect, rx, ry); | |
| 808 if (invert) { | 812 if (invert) { |
| 813 SkPath path; |
| 814 path.addRoundRect(rect, rx, ry); |
| 809 path.setFillType(SkPath::kInverseWinding_FillType); | 815 path.setFillType(SkPath::kInverseWinding_FillType); |
| 816 stack->clipDevPath(path, op, false); |
| 817 } else { |
| 818 SkRRect rrect; |
| 819 rrect.setRectXY(rect, rx, ry); |
| 820 stack->clipDevRRect(rrect, op, false); |
| 810 } | 821 } |
| 811 stack->clipDevPath(path, op, false); | |
| 812 }; | 822 }; |
| 813 | 823 |
| 814 static void add_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkClipSta
ck* stack) { | 824 static void add_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkClipSta
ck* stack) { |
| 815 if (invert) { | 825 if (invert) { |
| 816 SkPath path; | 826 SkPath path; |
| 817 path.addRect(rect); | 827 path.addRect(rect); |
| 818 path.setFillType(SkPath::kInverseWinding_FillType); | 828 path.setFillType(SkPath::kInverseWinding_FillType); |
| 819 stack->clipDevPath(path, op, false); | 829 stack->clipDevPath(path, op, false); |
| 820 } else { | 830 } else { |
| 821 stack->clipDevRect(rect, op, false); | 831 stack->clipDevRect(rect, op, false); |
| 822 } | 832 } |
| 823 }; | 833 }; |
| 824 | 834 |
| 825 static void add_oval(const SkRect& rect, bool invert, SkRegion::Op op, SkClipSta
ck* stack) { | 835 static void add_oval(const SkRect& rect, bool invert, SkRegion::Op op, SkClipSta
ck* stack) { |
| 826 SkPath path; | 836 SkPath path; |
| 827 path.addOval(rect); | 837 path.addOval(rect); |
| 828 if (invert) { | 838 if (invert) { |
| 829 path.setFillType(SkPath::kInverseWinding_FillType); | 839 path.setFillType(SkPath::kInverseWinding_FillType); |
| 830 } | 840 } |
| 831 stack->clipDevPath(path, op, false); | 841 stack->clipDevPath(path, op, false); |
| 832 }; | 842 }; |
| 833 | 843 |
| 834 static void add_elem_to_stack(const SkClipStack::Element& element, SkClipStack*
stack) { | 844 static void add_elem_to_stack(const SkClipStack::Element& element, SkClipStack*
stack) { |
| 835 switch (element.getType()) { | 845 switch (element.getType()) { |
| 836 case SkClipStack::Element::kRect_Type: | 846 case SkClipStack::Element::kRect_Type: |
| 837 stack->clipDevRect(element.getRect(), element.getOp(), element.isAA(
)); | 847 stack->clipDevRect(element.getRect(), element.getOp(), element.isAA(
)); |
| 838 break; | 848 break; |
| 849 case SkClipStack::Element::kRRect_Type: |
| 850 stack->clipDevRRect(element.getRRect(), element.getOp(), element.isA
A()); |
| 851 break; |
| 839 case SkClipStack::Element::kPath_Type: | 852 case SkClipStack::Element::kPath_Type: |
| 840 stack->clipDevPath(element.getPath(), element.getOp(), element.isAA(
)); | 853 stack->clipDevPath(element.getPath(), element.getOp(), element.isAA(
)); |
| 841 break; | 854 break; |
| 842 case SkClipStack::Element::kEmpty_Type: | 855 case SkClipStack::Element::kEmpty_Type: |
| 843 SkDEBUGFAIL("Why did the reducer produce an explicit empty."); | 856 SkDEBUGFAIL("Why did the reducer produce an explicit empty."); |
| 844 stack->clipEmpty(); | 857 stack->clipEmpty(); |
| 845 break; | 858 break; |
| 846 } | 859 } |
| 847 } | 860 } |
| 848 | 861 |
| 849 static void add_elem_to_region(const SkClipStack::Element& element, | 862 static void add_elem_to_region(const SkClipStack::Element& element, |
| 850 const SkIRect& bounds, | 863 const SkIRect& bounds, |
| 851 SkRegion* region) { | 864 SkRegion* region) { |
| 852 SkRegion elemRegion; | 865 SkRegion elemRegion; |
| 853 SkRegion boundsRgn(bounds); | 866 SkRegion boundsRgn(bounds); |
| 867 SkPath path; |
| 854 | 868 |
| 855 switch (element.getType()) { | 869 switch (element.getType()) { |
| 856 case SkClipStack::Element::kRect_Type: { | 870 case SkClipStack::Element::kEmpty_Type: |
| 857 SkPath path; | 871 elemRegion.setEmpty(); |
| 858 path.addRect(element.getRect()); | 872 break; |
| 873 default: |
| 874 element.asPath(&path); |
| 859 elemRegion.setPath(path, boundsRgn); | 875 elemRegion.setPath(path, boundsRgn); |
| 860 break; | 876 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 } | 877 } |
| 870 region->op(elemRegion, element.getOp()); | 878 region->op(elemRegion, element.getOp()); |
| 871 } | 879 } |
| 872 | 880 |
| 873 static void test_reduced_clip_stack(skiatest::Reporter* reporter) { | 881 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 | 882 // We construct random clip stacks, reduce them, and then rasterize both ver
sions to verify that |
| 875 // they are equal. | 883 // they are equal. |
| 876 | 884 |
| 877 // All the clip elements will be contained within these bounds. | 885 // All the clip elements will be contained within these bounds. |
| 878 static const SkRect kBounds = SkRect::MakeWH(100, 100); | 886 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( | 939 SkSize size = SkSize::Make( |
| 932 SkScalarFloorToScalar(SkScalarMul(kBounds.width(), r.nextRangeSc
alar(kMinElemSizeFrac, kMaxElemSizeFrac))), | 940 SkScalarFloorToScalar(SkScalarMul(kBounds.width(), r.nextRangeSc
alar(kMinElemSizeFrac, kMaxElemSizeFrac))), |
| 933 SkScalarFloorToScalar(SkScalarMul(kBounds.height(), r.nextRangeS
calar(kMinElemSizeFrac, kMaxElemSizeFrac)))); | 941 SkScalarFloorToScalar(SkScalarMul(kBounds.height(), r.nextRangeS
calar(kMinElemSizeFrac, kMaxElemSizeFrac)))); |
| 934 | 942 |
| 935 SkPoint xy = {SkScalarFloorToScalar(r.nextRangeScalar(kBounds.fLeft,
kBounds.fRight - size.fWidth)), | 943 SkPoint xy = {SkScalarFloorToScalar(r.nextRangeScalar(kBounds.fLeft,
kBounds.fRight - size.fWidth)), |
| 936 SkScalarFloorToScalar(r.nextRangeScalar(kBounds.fTop,
kBounds.fBottom - size.fHeight))}; | 944 SkScalarFloorToScalar(r.nextRangeScalar(kBounds.fTop,
kBounds.fBottom - size.fHeight))}; |
| 937 | 945 |
| 938 SkRect rect = SkRect::MakeXYWH(xy.fX, xy.fY, size.fWidth, size.fHeig
ht); | 946 SkRect rect = SkRect::MakeXYWH(xy.fX, xy.fY, size.fWidth, size.fHeig
ht); |
| 939 | 947 |
| 940 bool invert = r.nextBiasedBool(kFractionInverted); | 948 bool invert = r.nextBiasedBool(kFractionInverted); |
| 949 |
| 941 kElementFuncs[r.nextULessThan(SK_ARRAY_COUNT(kElementFuncs))](rect,
invert, op, &stack); | 950 kElementFuncs[r.nextULessThan(SK_ARRAY_COUNT(kElementFuncs))](rect,
invert, op, &stack); |
| 942 if (doSave) { | 951 if (doSave) { |
| 943 stack.save(); | 952 stack.save(); |
| 944 } | 953 } |
| 945 } | 954 } |
| 946 | 955 |
| 947 SkRect inflatedBounds = kBounds; | 956 SkRect inflatedBounds = kBounds; |
| 948 inflatedBounds.outset(kBounds.width() / 2, kBounds.height() / 2); | 957 inflatedBounds.outset(kBounds.width() / 2, kBounds.height() / 2); |
| 949 SkIRect inflatedIBounds; | 958 SkIRect inflatedIBounds; |
| 950 inflatedBounds.roundOut(&inflatedIBounds); | 959 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); | 998 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); |
| 990 while ((element = iter.next())) { | 999 while ((element = iter.next())) { |
| 991 add_elem_to_region(*element, inflatedIBounds, ®ion); | 1000 add_elem_to_region(*element, inflatedIBounds, ®ion); |
| 992 } | 1001 } |
| 993 | 1002 |
| 994 reducedRegion.setRect(inflatedIBounds); | 1003 reducedRegion.setRect(inflatedIBounds); |
| 995 iter.reset(reducedStack, SkClipStack::Iter::kBottom_IterStart); | 1004 iter.reset(reducedStack, SkClipStack::Iter::kBottom_IterStart); |
| 996 while ((element = iter.next())) { | 1005 while ((element = iter.next())) { |
| 997 add_elem_to_region(*element, inflatedIBounds, &reducedRegion); | 1006 add_elem_to_region(*element, inflatedIBounds, &reducedRegion); |
| 998 } | 1007 } |
| 999 | 1008 SkString testCase; |
| 1000 REPORTER_ASSERT(reporter, region == reducedRegion); | 1009 testCase.printf("Iteration %d", i); |
| 1010 REPORTER_ASSERT_MESSAGE(reporter, region == reducedRegion, testCase.c_st
r()); |
| 1001 } | 1011 } |
| 1002 } | 1012 } |
| 1003 | 1013 |
| 1004 #if defined(WIN32) | 1014 #if defined(WIN32) |
| 1005 #define SUPPRESS_VISIBILITY_WARNING | 1015 #define SUPPRESS_VISIBILITY_WARNING |
| 1006 #else | 1016 #else |
| 1007 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) | 1017 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) |
| 1008 #endif | 1018 #endif |
| 1009 | 1019 |
| 1010 static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) { | 1020 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); | 1197 REPORTER_ASSERT(reporter, element->getRect() == answer); |
| 1188 // now check that we only had one in our iterator | 1198 // now check that we only had one in our iterator |
| 1189 REPORTER_ASSERT(reporter, !iter.next()); | 1199 REPORTER_ASSERT(reporter, !iter.next()); |
| 1190 | 1200 |
| 1191 stack.reset(); | 1201 stack.reset(); |
| 1192 REPORTER_ASSERT(reporter, 0 == stack.getSaveCount()); | 1202 REPORTER_ASSERT(reporter, 0 == stack.getSaveCount()); |
| 1193 assert_count(reporter, stack, 0); | 1203 assert_count(reporter, stack, 0); |
| 1194 | 1204 |
| 1195 test_assign_and_comparison(reporter); | 1205 test_assign_and_comparison(reporter); |
| 1196 test_iterators(reporter); | 1206 test_iterators(reporter); |
| 1197 test_bounds(reporter, true); // once with rects | 1207 test_bounds(reporter, SkClipStack::Element::kRect_Type); |
| 1198 test_bounds(reporter, false); // once with paths | 1208 test_bounds(reporter, SkClipStack::Element::kRRect_Type); |
| 1209 test_bounds(reporter, SkClipStack::Element::kPath_Type); |
| 1199 test_isWideOpen(reporter); | 1210 test_isWideOpen(reporter); |
| 1200 test_rect_merging(reporter); | 1211 test_rect_merging(reporter); |
| 1201 test_rect_replace(reporter); | 1212 test_rect_replace(reporter); |
| 1202 test_rect_inverse_fill(reporter); | 1213 test_rect_inverse_fill(reporter); |
| 1203 test_path_replace(reporter); | 1214 test_path_replace(reporter); |
| 1204 test_quickContains(reporter); | 1215 test_quickContains(reporter); |
| 1205 #if SK_SUPPORT_GPU | 1216 #if SK_SUPPORT_GPU |
| 1206 test_reduced_clip_stack(reporter); | 1217 test_reduced_clip_stack(reporter); |
| 1207 test_reduced_clip_stack_genid(reporter); | 1218 test_reduced_clip_stack_genid(reporter); |
| 1208 test_reduced_clip_stack_no_aa_crash(reporter); | 1219 test_reduced_clip_stack_no_aa_crash(reporter); |
| 1209 #endif | 1220 #endif |
| 1210 } | 1221 } |
| OLD | NEW |