diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-24 22:07:50 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-24 22:07:50 +0000 |
commit | 4c2a2f7c5e8ec77771153f94c454adf21fd33805 (patch) | |
tree | 5754ec12ff7ad604086a9623be1bbade880a1ba9 /tests/ClipStackTest.cpp | |
parent | dcba4c2cc30cc64f08def991376c6dab65cfb51c (diff) |
Added isIntersectionOfRects to SkClipStack
http://codereview.appspot.com/6434050/
git-svn-id: http://skia.googlecode.com/svn/trunk@4745 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/ClipStackTest.cpp')
-rw-r--r-- | tests/ClipStackTest.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp index e5001f1100..02fa8cfbf3 100644 --- a/tests/ClipStackTest.cpp +++ b/tests/ClipStackTest.cpp @@ -183,7 +183,7 @@ static void test_iterators(skiatest::Reporter* reporter) { } } -static void test_bounds(skiatest::Reporter* reporter) { +static void test_bounds(skiatest::Reporter* reporter, bool useRects) { static const int gNumCases = 20; static const SkRect gAnswerRectsBW[gNumCases] = { @@ -236,9 +236,11 @@ static void test_bounds(skiatest::Reporter* reporter) { SkClipStack stack; SkRect bound; + bool isIntersectionOfRects = false; int testCase = 0; - for (int invBits = 0; invBits < 4; ++invBits) { + int numBitTests = useRects ? 1 : 4; + for (int invBits = 0; invBits < numBitTests; ++invBits) { for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) { stack.save(); @@ -250,13 +252,26 @@ static void test_bounds(skiatest::Reporter* reporter) { clipB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType); - stack.clipDevPath(clipA, SkRegion::kIntersect_Op, false); - stack.clipDevPath(clipB, gOps[op], false); + if (useRects) { + stack.clipDevRect(rectA, SkRegion::kIntersect_Op, false); + stack.clipDevRect(rectB, gOps[op], false); + } else { + stack.clipDevPath(clipA, SkRegion::kIntersect_Op, false); + stack.clipDevPath(clipB, gOps[op], false); + } - stack.getConservativeBounds(0, 0, 100, 100, &bound); + stack.getConservativeBounds(0, 0, 100, 100, &bound, + &isIntersectionOfRects); + + if (useRects) { + REPORTER_ASSERT(reporter, isIntersectionOfRects == + (gOps[op] == SkRegion::kIntersect_Op)); + } else { + REPORTER_ASSERT(reporter, !isIntersectionOfRects); + } SkASSERT(testCase < gNumCases); - SkASSERT(bound == gAnswerRectsBW[testCase]); + REPORTER_ASSERT(reporter, bound == gAnswerRectsBW[testCase]); ++testCase; stack.restore(); @@ -300,7 +315,8 @@ static void TestClipStack(skiatest::Reporter* reporter) { test_assign_and_comparison(reporter); test_iterators(reporter); - test_bounds(reporter); + test_bounds(reporter, true); + test_bounds(reporter, false); } #include "TestClassDef.h" |