diff options
author | Yuqian Li <liyuqian@google.com> | 2016-11-16 10:12:58 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-16 15:55:50 +0000 |
commit | e4b8b5283f45cff6a490ee73677f75b641c22bd1 (patch) | |
tree | d502bbfd21deb19c814b7afac41c28463f4d3ccc /src/core | |
parent | 08576e618883c3f8eb2cdf425e2f2bd7842f3f2e (diff) |
Simplify the signature of sk/aaa_fill_path
Previously, the clipRect is either equal to nullptr or clipRgn's bound
(after necessary supersampling shift). Hence we drop one of them to make
the signature simpler.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4874
Change-Id: Ied8d5313809d6cf90374365b01f2b8d52f2236e2
Reviewed-on: https://skia-review.googlesource.com/4874
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkScan.h | 3 | ||||
-rw-r--r-- | src/core/SkScanPriv.h | 9 | ||||
-rw-r--r-- | src/core/SkScan_AAAPath.cpp | 25 | ||||
-rw-r--r-- | src/core/SkScan_AntiPath.cpp | 9 | ||||
-rw-r--r-- | src/core/SkScan_Path.cpp | 47 |
5 files changed, 49 insertions, 44 deletions
diff --git a/src/core/SkScan.h b/src/core/SkScan.h index c0610bfe98..24e008826d 100644 --- a/src/core/SkScan.h +++ b/src/core/SkScan.h @@ -87,9 +87,6 @@ private: static void AntiHairLineRgn(const SkPoint[], int count, const SkRegion*, SkBlitter*); static void AAAFillPath(const SkPath& path, const SkRegion& origClip, SkBlitter* blitter, bool forceRLE = false); // SkAAClip uses forceRLE - static void aaa_fill_path(const SkPath& path, const SkIRect* clipRect, AdditiveBlitter*, - int start_y, int stop_y, const SkRegion& clipRgn, bool isUsingMask, - bool forceRLE); }; /** Assign an SkXRect from a SkIRect, by promoting the src rect's coordinates diff --git a/src/core/SkScanPriv.h b/src/core/SkScanPriv.h index 4ff91bb455..4c237e004b 100644 --- a/src/core/SkScanPriv.h +++ b/src/core/SkScanPriv.h @@ -30,10 +30,13 @@ private: const SkIRect* fClipRect; }; -// clipRect == null means path is entirely inside the clip -void sk_fill_path(const SkPath& path, const SkIRect* clipRect, +void sk_fill_path(const SkPath& path, const SkIRect& clipRect, SkBlitter* blitter, int start_y, int stop_y, int shiftEdgesUp, - const SkRegion& clipRgn); + bool pathContainedInClip); + +void aaa_fill_path(const SkPath& path, const SkIRect& clipRect, AdditiveBlitter*, + int start_y, int stop_y, bool pathContainedInClip, bool isUsingMask, + bool forceRLE); // blit the rects above and below avoid, clipped to clip void sk_blit_above(SkBlitter*, const SkIRect& avoid, const SkRegion& clip); diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp index 3915feae59..1c989f86fd 100644 --- a/src/core/SkScan_AAAPath.cpp +++ b/src/core/SkScan_AAAPath.cpp @@ -1143,8 +1143,8 @@ END_WALK: #endif } -void SkScan::aaa_fill_path(const SkPath& path, const SkIRect* clipRect, AdditiveBlitter* blitter, - int start_y, int stop_y, const SkRegion& clipRgn, bool isUsingMask, +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); @@ -1157,12 +1157,13 @@ void SkScan::aaa_fill_path(const SkPath& path, const SkIRect* clipRect, Additive const bool canCullToTheRight = !path.isConvex(); SkASSERT(gSkUseAnalyticAA.load()); - int count = builder.build(path, clipRect, 0, canCullToTheRight, true); + const SkIRect* builderClip = pathContainedInClip ? nullptr : &clipRect; + int count = builder.build(path, builderClip, 0, canCullToTheRight, true); SkASSERT(count >= 0); SkAnalyticEdge** list = (SkAnalyticEdge**)builder.analyticEdgeList(); - SkIRect rect = clipRgn.getBounds(); + SkIRect rect = clipRect; if (0 == count) { if (path.isInverseFillType()) { /* @@ -1208,11 +1209,11 @@ void SkScan::aaa_fill_path(const SkPath& path, const SkIRect* clipRect, Additive // now edge is the head of the sorted linklist - if (clipRect && start_y < clipRect->fTop) { - start_y = clipRect->fTop; + if (!pathContainedInClip && start_y < clipRect.fTop) { + start_y = clipRect.fTop; } - if (clipRect && stop_y > clipRect->fBottom) { - stop_y = clipRect->fBottom; + if (!pathContainedInClip && stop_y > clipRect.fBottom) { + stop_y = clipRect.fBottom; } if (!path.isInverseFillType() && path.isConvex()) { @@ -1349,12 +1350,12 @@ void SkScan::AAAFillPath(const SkPath& path, const SkRegion& origClip, SkBlitter if (MaskAdditiveBlitter::canHandleRect(ir) && !isInverse && !forceRLE) { MaskAdditiveBlitter additiveBlitter(blitter, ir, *clipRgn, isInverse); - aaa_fill_path(path, clipRect, &additiveBlitter, ir.fTop, ir.fBottom, *clipRgn, true, - forceRLE); + aaa_fill_path(path, clipRgn->getBounds(), &additiveBlitter, ir.fTop, ir.fBottom, + clipRect == nullptr, true, forceRLE); } else { RunBasedAdditiveBlitter additiveBlitter(blitter, ir, *clipRgn, isInverse); - aaa_fill_path(path, clipRect, &additiveBlitter, ir.fTop, ir.fBottom, *clipRgn, false, - forceRLE); + aaa_fill_path(path, clipRgn->getBounds(), &additiveBlitter, ir.fTop, ir.fBottom, + clipRect == nullptr, false, forceRLE); } if (isInverse) { diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp index 53dac3f65f..1d214e3078 100644 --- a/src/core/SkScan_AntiPath.cpp +++ b/src/core/SkScan_AntiPath.cpp @@ -691,6 +691,9 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip, return; } + SkASSERT(clipper.getClipRect() == nullptr || + *clipper.getClipRect() == clipRgn->getBounds()); + // now use the (possibly wrapped) blitter blitter = clipper.getBlitter(); @@ -715,10 +718,12 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip, if (!isInverse && MaskSuperBlitter::CanHandleRect(ir) && !forceRLE) { MaskSuperBlitter superBlit(blitter, ir, *clipRgn, isInverse); SkASSERT(SkIntToScalar(ir.fTop) <= path.getBounds().fTop); - sk_fill_path(path, superClipRect, &superBlit, ir.fTop, ir.fBottom, SHIFT, *clipRgn); + sk_fill_path(path, clipRgn->getBounds(), &superBlit, ir.fTop, ir.fBottom, SHIFT, + superClipRect == nullptr); } else { SuperBlitter superBlit(blitter, ir, *clipRgn, isInverse); - sk_fill_path(path, superClipRect, &superBlit, ir.fTop, ir.fBottom, SHIFT, *clipRgn); + sk_fill_path(path, clipRgn->getBounds(), &superBlit, ir.fTop, ir.fBottom, SHIFT, + superClipRect == nullptr); } if (isInverse) { diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp index 9ce18b0ee5..ec0fe06b66 100644 --- a/src/core/SkScan_Path.cpp +++ b/src/core/SkScan_Path.cpp @@ -421,21 +421,24 @@ static SkEdge* sort_edges(SkEdge* list[], int count, SkEdge** last) { return list[0]; } -// clipRect may be null, even though we always have a clip. This indicates that -// the path is contained in the clip, and so we can ignore it during the blit -// -// clipRect (if no null) has already been shifted up -// -void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitter, - int start_y, int stop_y, int shiftEdgesUp, const SkRegion& clipRgn) { +// clipRect has not been shifted up +void sk_fill_path(const SkPath& path, const SkIRect& clipRect, SkBlitter* blitter, + int start_y, int stop_y, int shiftEdgesUp, bool pathContainedInClip) { SkASSERT(blitter); + SkIRect shiftedClip = clipRect; + shiftedClip.fLeft <<= shiftEdgesUp; + shiftedClip.fRight <<= shiftEdgesUp; + shiftedClip.fTop <<= shiftEdgesUp; + shiftedClip.fBottom <<= shiftEdgesUp; + SkEdgeBuilder builder; // If we're convex, then we need both edges, even the right edge is past the clip const bool canCullToTheRight = !path.isConvex(); - int count = builder.build(path, clipRect, shiftEdgesUp, canCullToTheRight); + SkIRect* builderClip = pathContainedInClip ? nullptr : &shiftedClip; + int count = builder.build(path, builderClip, shiftEdgesUp, canCullToTheRight); SkASSERT(count >= 0); SkEdge** list = builder.edgeList(); @@ -448,7 +451,7 @@ void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte * we need to restrict our drawing to the intersection of the clip * and those two limits. */ - SkIRect rect = clipRgn.getBounds(); + SkIRect rect = clipRect; if (rect.fTop < start_y) { rect.fTop = start_y; } @@ -484,18 +487,18 @@ void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte start_y = SkLeftShift(start_y, shiftEdgesUp); stop_y = SkLeftShift(stop_y, shiftEdgesUp); - if (clipRect && start_y < clipRect->fTop) { - start_y = clipRect->fTop; + if (!pathContainedInClip && start_y < shiftedClip.fTop) { + start_y = shiftedClip.fTop; } - if (clipRect && stop_y > clipRect->fBottom) { - stop_y = clipRect->fBottom; + if (!pathContainedInClip && stop_y > shiftedClip.fBottom) { + stop_y = shiftedClip.fBottom; } InverseBlitter ib; PrePostProc proc = nullptr; if (path.isInverseFillType()) { - ib.setBlitter(blitter, clipRgn.getBounds(), shiftEdgesUp); + ib.setBlitter(blitter, clipRect, shiftEdgesUp); blitter = &ib; proc = PrePostInverseBlitterProc; } @@ -504,14 +507,8 @@ void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte SkASSERT(count >= 2); // convex walker does not handle missing right edges walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, nullptr); } else { - int rightEdge; - if (clipRect) { - rightEdge = clipRect->right(); - } else { - rightEdge = SkScalarRoundToInt(path.getBounds().right()) << shiftEdgesUp; - } - - walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc, rightEdge); + walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc, + shiftedClip.right()); } } @@ -676,8 +673,10 @@ void SkScan::FillPath(const SkPath& path, const SkRegion& origClip, if (path.isInverseFillType()) { sk_blit_above(blitter, ir, *clipPtr); } - sk_fill_path(path, clipper.getClipRect(), blitter, ir.fTop, ir.fBottom, - 0, *clipPtr); + SkASSERT(clipper.getClipRect() == nullptr || + *clipper.getClipRect() == clipPtr->getBounds()); + sk_fill_path(path, clipPtr->getBounds(), blitter, ir.fTop, ir.fBottom, + 0, clipper.getClipRect() == nullptr); if (path.isInverseFillType()) { sk_blit_below(blitter, ir, *clipPtr); } |