Unify DAA and AAA usage decision

Bug: skia:
Change-Id: I2481d872e072fdd638640ef2306aa89c1a1d6d94
Reviewed-on: https://skia-review.googlesource.com/26801
Commit-Queue: Yuqian Li <liyuqian@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index 2a92b42..10b8891 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -582,8 +582,50 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
+static bool ShouldUseDAA(const SkPath& path) {
+    if (gSkForceDeltaAA) {
+        return true;
+    }
+    if (!gSkUseDeltaAA) {
+        return false;
+    }
+    const SkRect& bounds = path.getBounds();
+    return !path.isConvex() && path.countPoints() >= SkTMax(bounds.width(), bounds.height()) / 8;
+}
+
+static bool ShouldUseAAA(const SkPath& path) {
+    if (gSkForceAnalyticAA) {
+        return true;
+    }
+    if (!gSkUseAnalyticAA) {
+        return false;
+    }
+    if (path.isRect(nullptr)) {
+        return true;
+    }
+    const SkRect& bounds = path.getBounds();
+    // When the path have so many points compared to the size of its bounds/resolution,
+    // it indicates that the path is not quite smooth in the current resolution:
+    // the expected number of turning points in every pixel row/column is significantly greater than
+    // zero. Hence Aanlytic AA is not likely to produce visible quality improvements, and Analytic
+    // AA might be slower than supersampling.
+    return path.countPoints() < SkTMax(bounds.width(), bounds.height()) / 2 - 10;
+}
+
 void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip,
                           SkBlitter* blitter, bool forceRLE) {
+#if !defined(SK_SUPPORT_LEGACY_DELTA_AA)
+    if (ShouldUseDAA(path)) {
+        SkScan::DAAFillPath(path, origClip, blitter, forceRLE);
+        return;
+    } else if (ShouldUseAAA(path)) {
+        // Do not use AAA if path is too complicated:
+        // there won't be any speedup or significant visual improvement.
+        SkScan::AAAFillPath(path, origClip, blitter, forceRLE);
+        return;
+    }
+#endif
+
     FillPathFunc fillPathFunc = [](const SkPath& path, SkBlitter* blitter, bool isInverse,
             const SkIRect& ir, const SkRegion* clipRgn, const SkIRect* clipRect, bool forceRLE){
         SkIRect superRect, *superClipRect = nullptr;
@@ -634,30 +676,6 @@
     }
 }
 
-static bool suitableForDAA(const SkPath& path) {
-    if (gSkForceAnalyticAA.load()) {
-        return true;
-    }
-    const SkRect& bounds = path.getBounds();
-    return !path.isConvex() && path.countPoints() >= SkTMax(bounds.width(), bounds.height()) / 8;
-}
-
-static bool suitableForAAA(const SkPath& path) {
-    if (gSkForceAnalyticAA.load()) {
-        return true;
-    }
-    if (path.isRect(nullptr)) {
-        return true;
-    }
-    const SkRect& bounds = path.getBounds();
-    // When the path have so many points compared to the size of its bounds/resolution,
-    // it indicates that the path is not quite smooth in the current resolution:
-    // the expected number of turning points in every pixel row/column is significantly greater than
-    // zero. Hence Aanlytic AA is not likely to produce visible quality improvements, and Analytic
-    // AA might be slower than supersampling.
-    return path.countPoints() < SkTMax(bounds.width(), bounds.height()) / 2 - 10;
-}
-
 void SkScan::AntiFillPath(const SkPath& path, const SkRasterClip& clip,
                           SkBlitter* blitter) {
     if (clip.isEmpty()) {
@@ -667,13 +685,15 @@
     using FillPathProc = void(*)(const SkPath&, const SkRegion&, SkBlitter*, bool);
     FillPathProc fillPathProc = &SkScan::AntiFillPath;
 
-    if (gSkUseDeltaAA.load() && suitableForDAA(path)) {
+#ifdef SK_SUPPORT_LEGACY_DELTA_AA
+    if (ShouldUseDAA(path)) {
         fillPathProc = &SkScan::DAAFillPath;
-    } else if (gSkUseAnalyticAA.load() && suitableForAAA(path)) {
+    } else if (ShouldUseAAA(path)) {
         // Do not use AAA if path is too complicated:
         // there won't be any speedup or significant visual improvement.
         fillPathProc = &SkScan::AAAFillPath;
     }
+#endif
 
     if (clip.isBW()) {
         fillPathProc(path, clip.bwRgn(), blitter, false);