now we trim the aaclip after building it, to ensure that it has tight bounds
around its (rle compressed) image.



git-svn-id: http://skia.googlecode.com/svn/trunk@2542 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleAAClip.cpp b/samplecode/SampleAAClip.cpp
index f2a025d..d2931fa 100644
--- a/samplecode/SampleAAClip.cpp
+++ b/samplecode/SampleAAClip.cpp
@@ -11,6 +11,34 @@
 #include "SkCanvas.h"
 #include "SkAAClip.h"
 
+static void testop(const SkIRect& r0, const SkIRect& r1, SkRegion::Op op,
+                   const SkIRect& expectedR) {
+    SkAAClip c0, c1, c2;
+    c0.setRect(r0);
+    c1.setRect(r1);
+    c2.op(c0, c1, op);
+    
+    SkIRect r2 = c2.getBounds();
+    SkASSERT(r2 == expectedR);
+}
+
+static const struct {
+    SkIRect r0;
+    SkIRect r1;
+    SkRegion::Op op;
+    SkIRect expectedR;
+} gRec[] = {
+    {{ 1, 2, 9, 3 }, { -3, 2, 5, 11 }, SkRegion::kDifference_Op, { 5, 2, 9, 3 }},
+    {{ 1, 10, 5, 13 }, { 1, 2, 5, 11 }, SkRegion::kDifference_Op, { 1, 11, 5, 13 }},
+    {{ 1, 10, 5, 13 }, { 1, 2, 5, 11 }, SkRegion::kReverseDifference_Op, { 1, 2, 5, 10 }},
+};
+
+static void testop() {
+    for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
+        testop(gRec[i].r0, gRec[i].r1, gRec[i].op, gRec[i].expectedR);
+    }
+}
+
 static void drawClip(SkCanvas* canvas, const SkAAClip& clip) {
     SkMask mask;
     SkBitmap bm;
@@ -32,6 +60,7 @@
 class AAClipView : public SampleView {
 public:
     AAClipView() {
+        testop();
     }
 
 protected: