diff options
author | 2016-05-10 05:57:27 -0700 | |
---|---|---|
committer | 2016-05-10 05:57:27 -0700 | |
commit | 33595bdf4b64a745f6340338d307e806e96c587f (patch) | |
tree | e6a4e7abd27df7aa3fdc764d67ec9e3b4cf86868 /src/gpu/batches/GrMSAAPathRenderer.cpp | |
parent | 82595b6fa4733e1525f357bdcac22db058790550 (diff) |
Replace GrStrokeInfo with GrStyle.
A side effect is that arbitrary path effects can no be pushed deeper into the Ganesh flow for paths. They may be applied by path renderers.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1957363002
Review-Url: https://codereview.chromium.org/1957363002
Diffstat (limited to 'src/gpu/batches/GrMSAAPathRenderer.cpp')
-rw-r--r-- | src/gpu/batches/GrMSAAPathRenderer.cpp | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp index a9ba06c5f4..a382c42054 100644 --- a/src/gpu/batches/GrMSAAPathRenderer.cpp +++ b/src/gpu/batches/GrMSAAPathRenderer.cpp @@ -29,7 +29,7 @@ static const float kTolerance = 0.5f; //////////////////////////////////////////////////////////////////////////////// // Helpers for drawPath -static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& stroke) { +static inline bool single_pass_path(const SkPath& path) { if (!path.isInverseFillType()) { return path.isConvex(); } @@ -38,7 +38,7 @@ static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok GrPathRenderer::StencilSupport GrMSAAPathRenderer::onGetStencilSupport(const SkPath& path) const { - if (single_pass_path(path, SkStrokeRec(SkStrokeRec::kFill_InitStyle))) { + if (single_pass_path(path)) { return GrPathRenderer::kNoRestriction_StencilSupport; } else { return GrPathRenderer::kStencilOnly_StencilSupport; @@ -571,9 +571,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target, GrColor color, const SkMatrix& viewMatrix, const SkPath& path, - const GrStrokeInfo& origStroke, bool stencilOnly) { - SkTCopyOnFirstWrite<GrStrokeInfo> stroke(origStroke); const GrXPFactory* xpFactory = pipelineBuilder->getXPFactory(); SkAutoTUnref<const GrXPFactory> backupXPFactory(SkSafeRef(xpFactory)); @@ -586,7 +584,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target, bool reverse = false; bool lastPassIsBounds; - if (single_pass_path(path, *stroke)) { + if (single_pass_path(path)) { passCount = 1; if (stencilOnly) { passes[0] = &gDirectToStencil; @@ -703,34 +701,35 @@ bool GrMSAAPathRenderer::internalDrawPath(GrDrawTarget* target, } bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { - return !IsStrokeHairlineOrEquivalent(*args.fStroke, *args.fViewMatrix, nullptr) && - !args.fAntiAlias; + // This path renderer does not support hairlines. We defer on anything that could be handled + // as a hairline by another path renderer. Also, arbitrary path effects could produce + // a hairline result. + return !IsStrokeHairlineOrEquivalent(*args.fStyle, *args.fViewMatrix, nullptr) && + !args.fStyle->hasNonDashPathEffect() && !args.fAntiAlias; } bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrMSAAPathRenderer::onDrawPath"); - SkPath path; - GrStrokeInfo stroke(*args.fStroke); - if (stroke.isDashed()) { - if (!stroke.applyDashToPath(&path, &stroke, *args.fPath)) { + SkPath tmpPath; + const SkPath* path; + if (args.fStyle->applies()) { + SkStrokeRec::InitStyle fill; + SkScalar styleScale = GrStyle::MatrixToScaleFactor(*args.fViewMatrix); + if (!args.fStyle->applyToPath(&tmpPath, &fill, *args.fPath, styleScale)) { return false; } + // We don't accept styles that are hairlines or have path effects that could produce + // hairlines. + SkASSERT(SkStrokeRec::kFill_InitStyle == fill); + path = &tmpPath; } else { - path = *args.fPath; - } - if (!stroke.isFillStyle()) { - stroke.setResScale(SkScalarAbs(args.fViewMatrix->getMaxScale())); - if (!stroke.applyToPath(&path, path)) { - return false; - } - stroke.setFillStyle(); + path = args.fPath; } return this->internalDrawPath(args.fTarget, args.fPipelineBuilder, args.fColor, *args.fViewMatrix, - path, - stroke, + *path, false); } @@ -739,7 +738,7 @@ void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) { SkASSERT(SkPath::kInverseEvenOdd_FillType != args.fPath->getFillType()); SkASSERT(SkPath::kInverseWinding_FillType != args.fPath->getFillType()); this->internalDrawPath(args.fTarget, args.fPipelineBuilder, GrColor_WHITE, *args.fViewMatrix, - *args.fPath, GrStrokeInfo::FillInfo(), true); + *args.fPath, true); } /////////////////////////////////////////////////////////////////////////////////////////////////// |