diff options
author | bsalomon <bsalomon@google.com> | 2016-05-05 09:26:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-05 09:26:22 -0700 |
commit | d6f25bf0ef353da39859fb4173d2cf60d52277e4 (patch) | |
tree | bfe6ef191686532010689419d09120103971c438 /src/gpu | |
parent | f0cf355b55eec7dacaa6c8e87c736e359b3ee278 (diff) |
Make GrPathRenderer only support fills for path stenciling
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1950893002
Review-Url: https://codereview.chromium.org/1950893002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrClipMaskManager.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrPathRenderer.h | 24 | ||||
-rw-r--r-- | src/gpu/GrPathRendererChain.cpp | 15 | ||||
-rw-r--r-- | src/gpu/GrSoftwarePathRenderer.h | 2 | ||||
-rwxr-xr-x | src/gpu/batches/GrAADistanceFieldPathRenderer.h | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrDashLinePathRenderer.h | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrDefaultPathRenderer.cpp | 6 | ||||
-rw-r--r-- | src/gpu/batches/GrDefaultPathRenderer.h | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrMSAAPathRenderer.cpp | 6 | ||||
-rw-r--r-- | src/gpu/batches/GrMSAAPathRenderer.h | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrStencilAndCoverPathRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrStencilAndCoverPathRenderer.h | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrTessellatingPathRenderer.h | 2 |
13 files changed, 36 insertions, 32 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index 3548963d49..3988e67ffe 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -865,7 +865,6 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt, args.fPipelineBuilder = &pipelineBuilder; args.fViewMatrix = &viewMatrix; args.fPath = &clipPath; - args.fStroke = &stroke; pr->stencilPath(args); } } diff --git a/src/gpu/GrPathRenderer.h b/src/gpu/GrPathRenderer.h index 051e007852..1072f69649 100644 --- a/src/gpu/GrPathRenderer.h +++ b/src/gpu/GrPathRenderer.h @@ -57,14 +57,13 @@ public: /** * This function is to get the stencil support for a particular path. The path's fill must - * not be an inverse type. + * not be an inverse type. The path will always be filled and not stroked. * * @param path the path that will be drawn - * @param stroke the stroke information (width, join, cap). */ - StencilSupport getStencilSupport(const SkPath& path, const GrStrokeInfo& stroke) const { + StencilSupport getStencilSupport(const SkPath& path) const { SkASSERT(!path.isInverseFillType()); - return this->onGetStencilSupport(path, stroke); + return this->onGetStencilSupport(path); } /** Args to canDrawPath() @@ -161,9 +160,11 @@ public: canArgs.fIsStencilBufferMSAA = args.fPipelineBuilder->getRenderTarget()->isStencilBufferMultisampled(); SkASSERT(this->canDrawPath(canArgs)); - SkASSERT(args.fPipelineBuilder->getStencil().isDisabled() || - kNoRestriction_StencilSupport == this->getStencilSupport(*args.fPath, - *args.fStroke)); + if (!args.fPipelineBuilder->getStencil().isDisabled()) { + SkASSERT(kNoRestriction_StencilSupport == this->getStencilSupport(*args.fPath)); + SkASSERT(!args.fStroke->isDashed()); + SkASSERT(args.fStroke->isFillStyle()); + } #endif return this->onDrawPath(args); } @@ -175,7 +176,6 @@ public: * fPipelineBuilder The pipeline builder. * fViewMatrix Matrix applied to the path. * fPath The path to draw. - * fStroke The stroke information (width, join, cap) */ struct StencilPathArgs { GrDrawTarget* fTarget; @@ -183,7 +183,6 @@ public: GrPipelineBuilder* fPipelineBuilder; const SkMatrix* fViewMatrix; const SkPath* fPath; - const GrStrokeInfo* fStroke; void validate() const { SkASSERT(fTarget); @@ -191,7 +190,6 @@ public: SkASSERT(fPipelineBuilder); SkASSERT(fViewMatrix); SkASSERT(fPath); - SkASSERT(fStroke); SkASSERT(!fPath->isEmpty()); } }; @@ -203,7 +201,7 @@ public: */ void stencilPath(const StencilPathArgs& args) { SkDEBUGCODE(args.validate();) - SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(*args.fPath, *args.fStroke)); + SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(*args.fPath)); this->onStencilPath(args); } @@ -246,7 +244,7 @@ private: /** * Subclass overrides if it has any limitations of stenciling support. */ - virtual StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const { + virtual StencilSupport onGetStencilSupport(const SkPath&) const { return kNoRestriction_StencilSupport; } @@ -281,7 +279,7 @@ private: drawArgs.fColor = 0xFFFFFFFF; drawArgs.fViewMatrix = args.fViewMatrix; drawArgs.fPath = args.fPath; - drawArgs.fStroke = args.fStroke; + drawArgs.fStroke = &GrStrokeInfo::FillInfo(); drawArgs.fAntiAlias = false; drawArgs.fGammaCorrect = false; this->drawPath(drawArgs); diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp index e19a134467..c9e21ad60c 100644 --- a/src/gpu/GrPathRendererChain.cpp +++ b/src/gpu/GrPathRendererChain.cpp @@ -60,9 +60,10 @@ GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) { return pr; } -GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, - DrawType drawType, - GrPathRenderer::StencilSupport* stencilSupport) { +GrPathRenderer* GrPathRendererChain::getPathRenderer( + const GrPathRenderer::CanDrawPathArgs& args, + DrawType drawType, + GrPathRenderer::StencilSupport* stencilSupport) { GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < GrPathRenderer::kStencilOnly_StencilSupport); GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < @@ -76,12 +77,18 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrPathRenderer::CanDr } else { minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; } + if (minStencilSupport != GrPathRenderer::kNoSupport_StencilSupport) { + // We don't support (and shouldn't need) stenciling of non-fill paths. + if (!args.fStroke->isFillStyle() || args.fStroke->isDashed()) { + return nullptr; + } + } for (int i = 0; i < fChain.count(); ++i) { if (fChain[i]->canDrawPath(args)) { if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) { GrPathRenderer::StencilSupport support = - fChain[i]->getStencilSupport(*args.fPath, *args.fStroke); + fChain[i]->getStencilSupport(*args.fPath); if (support < minStencilSupport) { continue; } else if (stencilSupport) { diff --git a/src/gpu/GrSoftwarePathRenderer.h b/src/gpu/GrSoftwarePathRenderer.h index 8b2f2d7932..578911954c 100644 --- a/src/gpu/GrSoftwarePathRenderer.h +++ b/src/gpu/GrSoftwarePathRenderer.h @@ -22,7 +22,7 @@ public: : fContext(context) { } private: - StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override { + StencilSupport onGetStencilSupport(const SkPath&) const override { return GrPathRenderer::kNoSupport_StencilSupport; } diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.h b/src/gpu/batches/GrAADistanceFieldPathRenderer.h index 200d315a97..099d0c7ebe 100755 --- a/src/gpu/batches/GrAADistanceFieldPathRenderer.h +++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.h @@ -23,7 +23,7 @@ public: virtual ~GrAADistanceFieldPathRenderer(); private: - StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override { + StencilSupport onGetStencilSupport(const SkPath&) const override { return GrPathRenderer::kNoSupport_StencilSupport; } diff --git a/src/gpu/batches/GrDashLinePathRenderer.h b/src/gpu/batches/GrDashLinePathRenderer.h index af8324d6f0..e25f882d57 100644 --- a/src/gpu/batches/GrDashLinePathRenderer.h +++ b/src/gpu/batches/GrDashLinePathRenderer.h @@ -14,7 +14,7 @@ class GrDashLinePathRenderer : public GrPathRenderer { private: bool onCanDrawPath(const CanDrawPathArgs&) const override; - StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override { + StencilSupport onGetStencilSupport(const SkPath&) const override { return kNoSupport_StencilSupport; } diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp index 708bcd7234..1de0bf771e 100644 --- a/src/gpu/batches/GrDefaultPathRenderer.cpp +++ b/src/gpu/batches/GrDefaultPathRenderer.cpp @@ -46,8 +46,8 @@ static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok } GrPathRenderer::StencilSupport -GrDefaultPathRenderer::onGetStencilSupport(const SkPath& path, const GrStrokeInfo& stroke) const { - if (single_pass_path(path, stroke)) { +GrDefaultPathRenderer::onGetStencilSupport(const SkPath& path) const { + if (single_pass_path(path, SkStrokeRec(SkStrokeRec::kFill_InitStyle))) { return GrPathRenderer::kNoRestriction_StencilSupport; } else { return GrPathRenderer::kStencilOnly_StencilSupport; @@ -618,7 +618,7 @@ void GrDefaultPathRenderer::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, *args.fStroke, true); + *args.fPath, GrStrokeInfo::FillInfo(), true); } /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/batches/GrDefaultPathRenderer.h b/src/gpu/batches/GrDefaultPathRenderer.h index 9973c2be5e..8156462a51 100644 --- a/src/gpu/batches/GrDefaultPathRenderer.h +++ b/src/gpu/batches/GrDefaultPathRenderer.h @@ -22,7 +22,7 @@ public: private: - StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override; + StencilSupport onGetStencilSupport(const SkPath&) const override; bool onCanDrawPath(const CanDrawPathArgs&) const override; diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp index 988952822a..a9ba06c5f4 100644 --- a/src/gpu/batches/GrMSAAPathRenderer.cpp +++ b/src/gpu/batches/GrMSAAPathRenderer.cpp @@ -37,8 +37,8 @@ static inline bool single_pass_path(const SkPath& path, const SkStrokeRec& strok } GrPathRenderer::StencilSupport -GrMSAAPathRenderer::onGetStencilSupport(const SkPath& path, const GrStrokeInfo& stroke) const { - if (single_pass_path(path, stroke)) { +GrMSAAPathRenderer::onGetStencilSupport(const SkPath& path) const { + if (single_pass_path(path, SkStrokeRec(SkStrokeRec::kFill_InitStyle))) { return GrPathRenderer::kNoRestriction_StencilSupport; } else { return GrPathRenderer::kStencilOnly_StencilSupport; @@ -739,7 +739,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, *args.fStroke, true); + *args.fPath, GrStrokeInfo::FillInfo(), true); } /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/batches/GrMSAAPathRenderer.h b/src/gpu/batches/GrMSAAPathRenderer.h index 0ffd280291..a35536014e 100644 --- a/src/gpu/batches/GrMSAAPathRenderer.h +++ b/src/gpu/batches/GrMSAAPathRenderer.h @@ -13,7 +13,7 @@ class SK_API GrMSAAPathRenderer : public GrPathRenderer { private: - StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override; + StencilSupport onGetStencilSupport(const SkPath&) const override; bool onCanDrawPath(const CanDrawPathArgs&) const override; diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp index 4aaea84957..6933efebe3 100644 --- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp @@ -66,7 +66,7 @@ void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrStencilAndCoverPathRenderer::onStencilPath"); SkASSERT(!args.fPath->isInverseFillType()); - SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fPath, *args.fStroke)); + SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fPath, GrStrokeInfo::FillInfo())); args.fTarget->stencilPath(*args.fPipelineBuilder, *args.fViewMatrix, p, p->getFillType()); } diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.h b/src/gpu/batches/GrStencilAndCoverPathRenderer.h index 8fec6c6342..cec8126e7b 100644 --- a/src/gpu/batches/GrStencilAndCoverPathRenderer.h +++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.h @@ -24,7 +24,7 @@ public: private: - StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override { + StencilSupport onGetStencilSupport(const SkPath&) const override { return GrPathRenderer::kStencilOnly_StencilSupport; } diff --git a/src/gpu/batches/GrTessellatingPathRenderer.h b/src/gpu/batches/GrTessellatingPathRenderer.h index 7598ceb065..f1faa608a6 100644 --- a/src/gpu/batches/GrTessellatingPathRenderer.h +++ b/src/gpu/batches/GrTessellatingPathRenderer.h @@ -21,7 +21,7 @@ public: private: bool onCanDrawPath(const CanDrawPathArgs& ) const override; - StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo&) const override { + StencilSupport onGetStencilSupport(const SkPath&) const override { return GrPathRenderer::kNoSupport_StencilSupport; } |