| Index: tests/ClipStackTest.cpp
|
| diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp
|
| index 04b48b678364ee0f2bd44f532868c32a48e56cfd..03ef72ea8c559975289f2add381b669bde392cea 100644
|
| --- a/tests/ClipStackTest.cpp
|
| +++ b/tests/ClipStackTest.cpp
|
| @@ -271,6 +271,7 @@ static void test_bounds(skiatest::Reporter* reporter, bool useRects) {
|
| }
|
|
|
| REPORTER_ASSERT(reporter, !stack.isWideOpen());
|
| + REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID != stack.getTopmostGenID());
|
|
|
| stack.getConservativeBounds(0, 0, 100, 100, &devClipBound,
|
| &isIntersectionOfRects);
|
| @@ -293,6 +294,12 @@ static void test_bounds(skiatest::Reporter* reporter, bool useRects) {
|
|
|
| // Test out 'isWideOpen' entry point
|
| static void test_isWideOpen(skiatest::Reporter* reporter) {
|
| + {
|
| + // Empty stack is wide open. Wide open stack means that gen id is wide open.
|
| + SkClipStack stack;
|
| + REPORTER_ASSERT(reporter, stack.isWideOpen());
|
| + REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
|
| + }
|
|
|
| SkRect rectA, rectB;
|
|
|
| @@ -304,6 +311,7 @@ static void test_isWideOpen(skiatest::Reporter* reporter) {
|
| SkClipStack stack;
|
|
|
| REPORTER_ASSERT(reporter, stack.isWideOpen());
|
| + REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
|
| }
|
|
|
| // Test out case where the user specifies a union that includes everything
|
| @@ -322,6 +330,7 @@ static void test_isWideOpen(skiatest::Reporter* reporter) {
|
| stack.clipDevPath(clipB, SkRegion::kUnion_Op, false);
|
|
|
| REPORTER_ASSERT(reporter, stack.isWideOpen());
|
| + REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
|
| }
|
|
|
| // Test out union w/ a wide open clip
|
| @@ -331,6 +340,7 @@ static void test_isWideOpen(skiatest::Reporter* reporter) {
|
| stack.clipDevRect(rectA, SkRegion::kUnion_Op, false);
|
|
|
| REPORTER_ASSERT(reporter, stack.isWideOpen());
|
| + REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
|
| }
|
|
|
| // Test out empty difference from a wide open clip
|
| @@ -343,6 +353,7 @@ static void test_isWideOpen(skiatest::Reporter* reporter) {
|
| stack.clipDevRect(emptyRect, SkRegion::kDifference_Op, false);
|
|
|
| REPORTER_ASSERT(reporter, stack.isWideOpen());
|
| + REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
|
| }
|
|
|
| // Test out return to wide open
|
| @@ -354,10 +365,12 @@ static void test_isWideOpen(skiatest::Reporter* reporter) {
|
| stack.clipDevRect(rectA, SkRegion::kReplace_Op, false);
|
|
|
| REPORTER_ASSERT(reporter, !stack.isWideOpen());
|
| + REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID != stack.getTopmostGenID());
|
|
|
| stack.restore();
|
|
|
| REPORTER_ASSERT(reporter, stack.isWideOpen());
|
| + REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
|
| }
|
| }
|
|
|
| @@ -950,6 +963,9 @@ static void test_reduced_clip_stack(skiatest::Reporter* reporter) {
|
| &initial,
|
| tightBounds);
|
|
|
| + REPORTER_ASSERT(reporter, reducedClips.count() == 0 ||
|
| + reducedClips.tail()->getGenID() != SkClipStack::kInvalidGenID);
|
| +
|
| // Build a new clip stack based on the reduced clip elements
|
| SkClipStack reducedStack;
|
| if (GrReducedClip::kAllOut_InitialState == initial) {
|
| @@ -986,6 +1002,48 @@ static void test_reduced_clip_stack(skiatest::Reporter* reporter) {
|
| }
|
| }
|
|
|
| +static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) {
|
| + SkClipStack stack;
|
| + stack.clipDevRect(SkRect::MakeXYWH(0, 0, 100, 100), SkRegion::kReplace_Op, true);
|
| + stack.clipDevRect(SkRect::MakeXYWH(0, 0, 50.3, 50.3), SkRegion::kReplace_Op, true);
|
| + SkIRect inflatedIBounds = SkIRect::MakeXYWH(0, 0, 100, 100);
|
| +
|
| + GrReducedClip::ElementList reducedClips;
|
| + GrReducedClip::InitialState initial;
|
| + SkIRect tightBounds;
|
| +
|
| + GrReducedClip::ReduceClipStack(stack,
|
| + inflatedIBounds,
|
| + &reducedClips,
|
| + &initial,
|
| + &tightBounds);
|
| +
|
| + REPORTER_ASSERT(reporter, reducedClips.count() == 1);
|
| + // Clips will be cached based on the generation id. Make sure the gen id is valid.
|
| + REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID != reducedClips.head()->getGenID());
|
| +
|
| +}
|
| +
|
| +static void test_reduced_clip_stack_no_aa_crash(skiatest::Reporter* reporter) {
|
| + SkClipStack stack;
|
| + stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 100, 100), SkRegion::kReplace_Op);
|
| + stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 50, 50), SkRegion::kReplace_Op);
|
| + SkIRect inflatedIBounds = SkIRect::MakeXYWH(0, 0, 100, 100);
|
| +
|
| + GrReducedClip::ElementList reducedClips;
|
| + GrReducedClip::InitialState initial;
|
| + SkIRect tightBounds;
|
| +
|
| + // At the time, this would crash.
|
| + GrReducedClip::ReduceClipStack(stack,
|
| + inflatedIBounds,
|
| + &reducedClips,
|
| + &initial,
|
| + &tightBounds);
|
| +
|
| + REPORTER_ASSERT(reporter, 0 == reducedClips.count());
|
| +}
|
| +
|
| #endif
|
| ///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
| @@ -1034,6 +1092,8 @@ static void TestClipStack(skiatest::Reporter* reporter) {
|
| test_quickContains(reporter);
|
| #if SK_SUPPORT_GPU
|
| test_reduced_clip_stack(reporter);
|
| + test_reduced_clip_stack_genid(reporter);
|
| + test_reduced_clip_stack_no_aa_crash(reporter);
|
| #endif
|
| }
|
|
|
|
|