aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ClipStackTest.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-24 13:54:00 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-24 13:54:00 +0000
commit607fe077c893fdb230e29631be096de614a14e2a (patch)
tree35af1f7d6542059ca8d1bc3f64305bcccf71881f /tests/ClipStackTest.cpp
parent7866228f06e402d37f8fcab70a688e1f34c1d27b (diff)
Added bound computation to SkClipStack
http://codereview.appspot.com/6419048/ This will require re-baselining of complexclip* and filltypespersp git-svn-id: http://skia.googlecode.com/svn/trunk@4730 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/ClipStackTest.cpp')
-rw-r--r--tests/ClipStackTest.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp
index 85a999797a..e5001f1100 100644
--- a/tests/ClipStackTest.cpp
+++ b/tests/ClipStackTest.cpp
@@ -183,6 +183,87 @@ static void test_iterators(skiatest::Reporter* reporter) {
}
}
+static void test_bounds(skiatest::Reporter* reporter) {
+
+ static const int gNumCases = 20;
+ static const SkRect gAnswerRectsBW[gNumCases] = {
+ // A op B
+ { 40, 40, 50, 50 },
+ { 10, 10, 50, 50 },
+ { 10, 10, 80, 80 },
+ { 10, 10, 80, 80 },
+ { 40, 40, 80, 80 },
+
+ // invA op B
+ { 40, 40, 80, 80 },
+ { 0, 0, 100, 100 },
+ { 0, 0, 100, 100 },
+ { 0, 0, 100, 100 },
+ { 40, 40, 50, 50 },
+
+ // A op invB
+ { 10, 10, 50, 50 },
+ { 40, 40, 50, 50 },
+ { 0, 0, 100, 100 },
+ { 0, 0, 100, 100 },
+ { 0, 0, 100, 100 },
+
+ // invA op invB
+ { 0, 0, 100, 100 },
+ { 40, 40, 80, 80 },
+ { 0, 0, 100, 100 },
+ { 10, 10, 80, 80 },
+ { 10, 10, 50, 50 },
+ };
+
+ static const SkRegion::Op gOps[] = {
+ SkRegion::kIntersect_Op,
+ SkRegion::kDifference_Op,
+ SkRegion::kUnion_Op,
+ SkRegion::kXOR_Op,
+ SkRegion::kReverseDifference_Op
+ };
+
+ SkRect rectA, rectB;
+
+ rectA.iset(10, 10, 50, 50);
+ rectB.iset(40, 40, 80, 80);
+
+ SkPath clipA, clipB;
+
+ clipA.addRoundRect(rectA, SkIntToScalar(5), SkIntToScalar(5));
+ clipB.addRoundRect(rectB, SkIntToScalar(5), SkIntToScalar(5));
+
+ SkClipStack stack;
+ SkRect bound;
+
+ int testCase = 0;
+ for (int invBits = 0; invBits < 4; ++invBits) {
+ for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) {
+
+ stack.save();
+ bool doInvA = SkToBool(invBits & 1);
+ bool doInvB = SkToBool(invBits & 2);
+
+ clipA.setFillType(doInvA ? SkPath::kInverseEvenOdd_FillType :
+ SkPath::kEvenOdd_FillType);
+ clipB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType :
+ SkPath::kEvenOdd_FillType);
+
+ stack.clipDevPath(clipA, SkRegion::kIntersect_Op, false);
+ stack.clipDevPath(clipB, gOps[op], false);
+
+ stack.getConservativeBounds(0, 0, 100, 100, &bound);
+
+ SkASSERT(testCase < gNumCases);
+ SkASSERT(bound == gAnswerRectsBW[testCase]);
+ ++testCase;
+
+ stack.restore();
+ }
+ }
+}
+
static void TestClipStack(skiatest::Reporter* reporter) {
SkClipStack stack;
@@ -219,6 +300,7 @@ static void TestClipStack(skiatest::Reporter* reporter) {
test_assign_and_comparison(reporter);
test_iterators(reporter);
+ test_bounds(reporter);
}
#include "TestClassDef.h"