aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuqian Li <liyuqian@google.com>2017-07-26 13:47:26 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-27 13:51:33 +0000
commit7d99dad70b97a534a6e23e9c74d914b5eb17ff1e (patch)
tree7081cd1ae966778426509710f0bd9e46c3edb805 /src
parent41a930f85bc3988cfbb47a902b03a9830f8149bb (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkAAClip.cpp8
-rw-r--r--src/core/SkScan_AntiPath.cpp72
2 files changed, 51 insertions, 29 deletions
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index 100ac9c646..092eb69bcf 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -1421,13 +1421,15 @@ bool SkAAClip::setPath(const SkPath& path, const SkRegion* clip, bool doAA) {
BuilderBlitter blitter(&builder);
if (doAA) {
- if (!path.isConvex() && gSkUseDeltaAA.load()) {
- SkScan::DAAFillPath(path, snugClip, &blitter, true);
- } else if (gSkUseAnalyticAA.load()) {
+#ifdef SK_SUPPORT_LEGACY_DELTA_AA
+ if (gSkUseAnalyticAA.load()) {
SkScan::AAAFillPath(path, snugClip, &blitter, true);
} else {
SkScan::AntiFillPath(path, snugClip, &blitter, true);
}
+#else
+ SkScan::AntiFillPath(path, snugClip, &blitter, true);
+#endif
} else {
SkScan::FillPath(path, snugClip, &blitter);
}
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index 2a92b42360..10b8891c14 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -582,8 +582,50 @@ void MaskSuperBlitter::blitH(int x, int y, int width) {
///////////////////////////////////////////////////////////////////////////////
+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 @@ void SkScan::FillPath(const SkPath& path, const SkRasterClip& clip,
}
}
-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 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRasterClip& clip,
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);