Added isIntersectionOfRects to SkClipStack

http://codereview.appspot.com/6434050/



git-svn-id: http://skia.googlecode.com/svn/trunk@4745 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp
index e5001f1..02fa8cf 100644
--- a/tests/ClipStackTest.cpp
+++ b/tests/ClipStackTest.cpp
@@ -183,7 +183,7 @@
     }
 }
 
-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 @@
 
     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 @@
             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 @@
 
     test_assign_and_comparison(reporter);
     test_iterators(reporter);
-    test_bounds(reporter);
+    test_bounds(reporter, true);
+    test_bounds(reporter, false);
 }
 
 #include "TestClassDef.h"