From 6987b00fae08ef0731042bb341b4e002a2da72c2 Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Thu, 19 Jan 2017 16:29:02 -0500 Subject: [PATCH] Fix performance issue and compute intersections more often. (This CL also turned on Analytic AA for concave paths by removing SK_SUPPORT_LEGACY_AAA flag.) Performance: The SK_ALWAYS_INLINE was restored because it could bring 30%-50% speedup in certain convex cases (e.g., fill_big_triangle). We also have to reduce the number of branchings in the concave code path to enable such speedup. (Although the speedup is for convex cases. The assembly code is so strange...) Intersection: Previously, the criterion is too loose and that caused some bad pixels (mostly unnoticeable by human eyes without magnifying). For example, pixel (198, 222) of https://gold.skia.org/detail?test=parsedpaths&digest=979e81de6f7b3f9e7e8dc810e31cad8d BUG=skia: Change-Id: I5e8191865c3df625f895cd4588c67c283fcbeaec Reviewed-on: https://skia-review.googlesource.com/7318 Reviewed-by: Cary Clark Reviewed-by: Mike Reed Commit-Queue: Yuqian Li --- src/core/SkAnalyticEdge.h | 5 ----- src/core/SkScan.h | 5 ----- src/core/SkScan_AAAPath.cpp | 25 +++++++------------------ 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/core/SkAnalyticEdge.h b/src/core/SkAnalyticEdge.h index c5f0a02..1df3e01 100644 --- a/src/core/SkAnalyticEdge.h +++ b/src/core/SkAnalyticEdge.h @@ -10,11 +10,6 @@ #include "SkEdge.h" -// Use this to check that we successfully guard the change against Chromium layout tests -#ifndef SK_SUPPORT_LEGACY_AAA -# define SK_SUPPORT_LEGACY_AAA -#endif - struct SkAnalyticEdge { // Similar to SkEdge, the conic edges will be converted to quadratic edges enum Type { diff --git a/src/core/SkScan.h b/src/core/SkScan.h index d0c10fa..c995542 100644 --- a/src/core/SkScan.h +++ b/src/core/SkScan.h @@ -23,11 +23,6 @@ class SkPath; */ typedef SkIRect SkXRect; -// Use this to check that we successfully guard the change against Chromium layout tests -#ifndef SK_SUPPORT_LEGACY_AAA -# define SK_SUPPORT_LEGACY_AAA -#endif - extern std::atomic gSkUseAnalyticAA; extern std::atomic gSkForceAnalyticAA; diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp index af45f00..80a09e5 100644 --- a/src/core/SkScan_AAAPath.cpp +++ b/src/core/SkScan_AAAPath.cpp @@ -1516,20 +1516,9 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead, SkAnalyticEdge* nextTail, } else { SkFixed rite = currE->fX; currE->goY(nextY, yShift); - if (leftE->fDX < 0) { - left = SkTMax(leftClip, left); - leftE->fX = SkTMax(leftClip, leftE->fX); - } else { - left = SkTMin(rightClip, left); - leftE->fX = SkTMin(rightClip, leftE->fX); - } - if (currE->fDX < 0) { - rite = SkTMax(leftClip, rite); - currE->fX = SkTMax(leftClip, currE->fX); - } else { - rite = SkTMin(rightClip, rite); - currE->fX = SkTMin(rightClip, currE->fX); - } + leftE->fX = SkTMax(leftClip, leftE->fX); + rite = SkTMin(rightClip, rite); + currE->fX = SkTMin(rightClip, currE->fX); blit_trapezoid_row(blitter, y >> 16, left, rite, leftE->fX, currE->fX, leftDY, currE->fDY, fullAlpha, maskRow, isUsingMask, noRealBlitter || (fullAlpha == 0xFF && ( @@ -1541,7 +1530,7 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead, SkAnalyticEdge* nextTail, } } else { if (isLeft) { - left = currE->fX; + left = SkTMax(currE->fX, leftClip); leftDY = currE->fDY; leftE = currE; leftEnds = leftE->fLowerY == nextY; @@ -1606,7 +1595,7 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead, SkAnalyticEdge* nextTail, leftClip, rightClip, yShift); } else { blit_trapezoid_row(blitter, y >> 16, - SkTMax(leftClip, left), rightClip, + left, rightClip, SkTMax(leftClip, leftE->fX), rightClip, leftDY, 0, fullAlpha, maskRow, isUsingMask, noRealBlitter || @@ -1629,7 +1618,7 @@ static void aaa_walk_edges(SkAnalyticEdge* prevHead, SkAnalyticEdge* nextTail, } } -static void aaa_fill_path(const SkPath& path, const SkIRect& clipRect, +static SK_ALWAYS_INLINE void aaa_fill_path(const SkPath& path, const SkIRect& clipRect, AdditiveBlitter* blitter, int start_y, int stop_y, bool pathContainedInClip, bool isUsingMask, bool forceRLE) { // forceRLE implies that SkAAClip is calling us SkASSERT(blitter); @@ -1724,7 +1713,7 @@ static void aaa_fill_path(const SkPath& path, const SkIRect& clipRect, // We skip intersection computation if there are many points which probably already // give us enough fractional scan lines. - bool skipIntersect = path.countPoints() > (stop_y - start_y) / 2; + bool skipIntersect = path.countPoints() > (stop_y - start_y) * 2; aaa_walk_edges(&headEdge, &tailEdge, path.getFillType(), blitter, start_y, stop_y, leftBound, rightBound, isUsingMask, forceRLE, useDeferred, skipIntersect); -- 2.7.4