aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkAnalyticEdge.h
diff options
context:
space:
mode:
authorGravatar Yuqian Li <liyuqian@google.com>2017-08-08 14:00:52 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-09 21:05:35 +0000
commit5eb8fc585e9b3c9ccc82b0921986e1020ddaff23 (patch)
tree4ebfe1a26d0bd2fc0eb7c27e3fc8581af46777ef /src/core/SkAnalyticEdge.h
parent0f450acd76fd58a2f7464f99869ed6afbfac303c (diff)
No chop at y extrema for cubics
The new Delta AA scan converter does not need the edge to be updated with monotonic Y so chopping at y extrema is not necessary. Removing such chopping brings ~10% performance increase to chalkboard.svg which has tons of small cubics (the same is true for many svgs I saw). We didn't remove the chopping for quads because that does not bring a significant speedup. Moreover, dropping those y extremas would make our strokecircle animation look a little more wobbly (because we would have fewer divisions for the quads at the top and bottom of the circle). Bug: skia: Change-Id: I3984d2619f9f77269ed24e8cbfa9f1429ebca4a8 Reviewed-on: https://skia-review.googlesource.com/31940 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src/core/SkAnalyticEdge.h')
-rw-r--r--src/core/SkAnalyticEdge.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/SkAnalyticEdge.h b/src/core/SkAnalyticEdge.h
index 533d769c55..13f62571a9 100644
--- a/src/core/SkAnalyticEdge.h
+++ b/src/core/SkAnalyticEdge.h
@@ -81,7 +81,7 @@ struct SkAnalyticEdge {
inline bool updateLine(SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by, SkFixed slope);
// return true if we're NOT done with this edge
- bool update(SkFixed last_y);
+ bool update(SkFixed last_y, bool sortY = true);
#ifdef SK_DEBUG
void dump() const {
@@ -124,8 +124,8 @@ struct SkAnalyticCubicEdge : public SkAnalyticEdge {
SkFixed fSnappedY; // to make sure that y is increasing with smooth jump and snapping
- bool setCubic(const SkPoint pts[4]);
- bool updateCubic();
+ bool setCubic(const SkPoint pts[4], bool sortY = true);
+ bool updateCubic(bool sortY = true);
inline void keepContinuous() {
SkASSERT(SkAbs32(fX - SkFixedMul(fDX, fY - SnapY(fCEdge.fCy)) - fCEdge.fCx) < SK_Fixed1);
fCEdge.fCx = fX;
@@ -223,7 +223,11 @@ struct SkCubic : public SkBezier {
SkPoint fP3;
bool set(const SkPoint pts[4]){
- if (IsEmpty(pts[0].fY, pts[3].fY)) {
+ // We do not chop at y extrema for cubics so pts[0], pts[1], pts[2], pts[3] may not be
+ // monotonic. Therefore, we have to check the emptiness for all three pairs, instead of just
+ // checking IsEmpty(pts[0].fY, pts[3].fY).
+ if (IsEmpty(pts[0].fY, pts[1].fY) && IsEmpty(pts[1].fY, pts[2].fY) &&
+ IsEmpty(pts[2].fY, pts[3].fY)) {
return false;
}
fCount = 4;