checkpoint -- more support changes for soft clipping



git-svn-id: http://skia.googlecode.com/svn/trunk@2475 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index 3f38ddd..0ba43b1 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -11,6 +11,7 @@
 #include "SkPath.h"
 #include "SkScan.h"
 #include "SkThread.h"
+#include "SkUtils.h"
 
 #define kMaxInt32   0x7FFFFFFF
 
@@ -797,6 +798,10 @@
         if (left >= bounds.fRight) {
             break;
         }
+        if (rite > bounds.fRight) {
+            rite = bounds.fRight;
+        }
+
         if (left >= bounds.fLeft) {
             SkASSERT(rite > left);
             builder.addRun(left, lastY, proc(alphaA, alphaB), rite - left);
@@ -868,6 +873,12 @@
         if (top >= bounds.fBottom) {
             break;
         }
+
+        if (bot > bounds.fBottom) {
+            bot = bounds.fBottom;
+        }
+        SkASSERT(top < bot);
+
         if (!rowA && !rowB) {
             builder.addRun(bounds.fLeft, bot - 1, 0, bounds.width());
         } else if (top >= bounds.fTop) {
@@ -1006,6 +1017,7 @@
                                           count * sizeof(SkAlpha));
         fAA = (SkAlpha*)(fRuns + count);
     }
+    SkDEBUGCODE(sk_memset16((uint16_t*)fRuns, 0xFFFF, fAAClipBounds.width() + 1);)
 }
 
 void SkAAClipBlitter::blitH(int x, int y, int width) {
@@ -1071,6 +1083,7 @@
         SkDEBUGCODE(accumulated += minN;)
         SkASSERT(accumulated <= width);
     }
+    dstRuns[0] = 0;
 }
 
 void SkAAClipBlitter::blitAntiH(int x, int y, const SkAlpha aa[],
@@ -1128,28 +1141,20 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-bool SkAAClip::offset(int dx, int dy) {
+bool SkAAClip::translate(int dx, int dy, SkAAClip* dst) const {
+    if (NULL == dst) {
+        return !this->isEmpty();
+    }
+
     if (this->isEmpty()) {
-        return false;
+        return dst->setEmpty();
     }
 
-    fBounds.offset(dx, dy);
-    return true;
-}
-
-bool SkAAClip::offset(int dx, int dy, SkAAClip* dst) const {
-    if (this == dst) {
-        return dst->offset(dx, dy);
+    if (this != dst) {
+        sk_atomic_inc(&fRunHead->fRefCnt);
+        dst->fRunHead = fRunHead;
+        dst->fBounds = fBounds;
     }
-
-    dst->setEmpty();
-    if (this->isEmpty()) {
-        return false;
-    }
-
-    sk_atomic_inc(&fRunHead->fRefCnt);
-    dst->fRunHead = fRunHead;
-    dst->fBounds = fBounds;
     dst->fBounds.offset(dx, dy);
     return true;
 }