check-point for unifying results between runs and mask backends for aa
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 9 Jun 2011 15:54:38 +0000 (15:54 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 9 Jun 2011 15:54:38 +0000 (15:54 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@1554 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkScan_AntiPath.cpp

index 398f786c954b58f46ef10c666d38bdd926a60a63..4dc2cd346cc7d5ece275833faabd7a835f3f0d34 100644 (file)
 #define SCALE   (1 << SHIFT)
 #define MASK    (SCALE - 1)
 
+/*
+    We have two techniques for capturing the output of the supersampler:
+    - SUPERMASK, which records a large mask-bitmap
+        this is often faster for small, complex objects
+    - RLE, which records a rle-encoded scanline
+        this is often faster for large objects with big spans
+
+    NEW_AA is a set of code-changes to try to make both paths produce identical
+    results. Its not quite there yet, though the remaining differences may be
+    in the subsequent blits, and not in the different masks/runs...
+ */
 //#define FORCE_SUPERMASK
 //#define FORCE_RLE
+//#define SK_SUPPORT_NEW_AA
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -281,9 +293,17 @@ static void add_aa_span(uint8_t* alpha, U8CPU startAlpha, int middleCount,
         edge of the current span round to the same super-sampled x value,
         I might overflow to 256 with this add, hence the funny subtract.
     */
+#ifdef SK_SUPPORT_NEW_AA
+    if (startAlpha) {
+        unsigned tmp = *alpha + startAlpha;
+        SkASSERT(tmp <= 256);
+        *alpha++ = SkToU8(tmp - (tmp >> 8));
+    }
+#else
     unsigned tmp = *alpha + startAlpha;
     SkASSERT(tmp <= 256);
     *alpha++ = SkToU8(tmp - (tmp >> 8));
+#endif
 
     if (middleCount >= MIN_COUNT_FOR_QUAD_LOOP) {
         // loop until we're quad-byte aligned
@@ -365,7 +385,15 @@ void MaskSuperBlitter::blitH(int x, int y, int width) {
         SkASSERT(row < fMask.fImage + kMAX_STORAGE + 1);
         add_aa_span(row, coverage_to_alpha(fe - fb));
     } else {
+#ifdef SK_SUPPORT_NEW_AA
+        if (0 == fb) {
+            n += 1;
+        } else {
+            fb = (1 << SHIFT) - fb;
+        }
+#else
         fb = (1 << SHIFT) - fb;
+#endif
         SkASSERT(row >= fMask.fImage);
         SkASSERT(row + n + 1 < fMask.fImage + kMAX_STORAGE + 1);
         add_aa_span(row,  coverage_to_alpha(fb), n, coverage_to_alpha(fe),