From e5ede4b138e84d05d63c9ab7f426884dc9b4d926 Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Thu, 7 Sep 2017 18:33:08 +0000 Subject: [PATCH] Revert "Improve GrPathRendererChain heuristics" This reverts commit 60f42494f5d45c38e260ce089cdddfb600f799b2. Reason for revert: breaking gold Original change's description: > Improve GrPathRendererChain heuristics > > Changes GrPathRenderer::canDrawPath to return a 'CanDrawPath' enum, > which contains a new kAsBackup value that means "I'm better than SW, > but give the path renderers below me a chance first." > > Bug: skia: > Change-Id: I45aac5462ca1bc0bc839eb1c315db9493901a07e > Reviewed-on: https://skia-review.googlesource.com/42222 > Reviewed-by: Brian Osman > Reviewed-by: Brian Salomon > Commit-Queue: Chris Dalton TBR=jvanverth@google.com,bsalomon@google.com,brianosman@google.com,csmartdalton@google.com,senorblanco@google.com Change-Id: I46020dbd56b6f6b88668894285b9b7b80f89b9a2 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/43780 Reviewed-by: Chris Dalton Commit-Queue: Chris Dalton --- src/gpu/GrDrawingManager.cpp | 2 +- src/gpu/GrPathRenderer.h | 20 +++++------ src/gpu/GrPathRendererChain.cpp | 33 +++++++------------ src/gpu/GrSoftwarePathRenderer.cpp | 11 ++----- src/gpu/GrSoftwarePathRenderer.h | 2 +- .../ccpr/GrCoverageCountingPathRenderer.cpp | 11 ++----- src/gpu/ccpr/GrCoverageCountingPathRenderer.h | 2 +- src/gpu/ops/GrAAConvexPathRenderer.cpp | 12 +++---- src/gpu/ops/GrAAConvexPathRenderer.h | 2 +- src/gpu/ops/GrAAHairLinePathRenderer.cpp | 13 ++++---- src/gpu/ops/GrAAHairLinePathRenderer.h | 2 +- .../ops/GrAALinearizingConvexPathRenderer.cpp | 31 +++++++---------- .../ops/GrAALinearizingConvexPathRenderer.h | 2 +- src/gpu/ops/GrDashLinePathRenderer.cpp | 12 +++---- src/gpu/ops/GrDashLinePathRenderer.h | 2 +- src/gpu/ops/GrDefaultPathRenderer.cpp | 13 +++----- src/gpu/ops/GrDefaultPathRenderer.h | 2 +- src/gpu/ops/GrMSAAPathRenderer.cpp | 9 ++--- src/gpu/ops/GrMSAAPathRenderer.h | 2 +- src/gpu/ops/GrSmallPathRenderer.cpp | 21 +++++------- src/gpu/ops/GrSmallPathRenderer.h | 2 +- src/gpu/ops/GrStencilAndCoverPathRenderer.cpp | 12 +++---- src/gpu/ops/GrStencilAndCoverPathRenderer.h | 2 +- src/gpu/ops/GrTessellatingPathRenderer.cpp | 26 +++++++-------- src/gpu/ops/GrTessellatingPathRenderer.h | 2 +- 25 files changed, 94 insertions(+), 154 deletions(-) diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index bbcd8a85d9..31da84e7e6 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -312,7 +312,7 @@ GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP new GrSoftwarePathRenderer(fContext->resourceProvider(), fOptionsForPathRendererChain.fAllowPathMaskCaching); } - if (GrPathRenderer::CanDrawPath::kNo != fSoftwarePathRenderer->canDrawPath(args)) { + if (fSoftwarePathRenderer->canDrawPath(args)) { pr = fSoftwarePathRenderer; } } diff --git a/src/gpu/GrPathRenderer.h b/src/gpu/GrPathRenderer.h index cf0ef6effc..a3cf8c6151 100644 --- a/src/gpu/GrPathRenderer.h +++ b/src/gpu/GrPathRenderer.h @@ -67,12 +67,6 @@ public: return this->onGetStencilSupport(shape); } - enum class CanDrawPath { - kNo, - kAsBackup, // i.e. This renderer is better than SW fallback if no others can draw the path. - kYes - }; - /** Args to canDrawPath() * * fCaps The context caps @@ -100,11 +94,13 @@ public: }; /** - * Returns how well this path renderer is able to render the given path. Returning kNo or - * kAsBackup allows the caller to keep searching for a better path renderer. This function is - * called when searching for the best path renderer to draw a path. + * Returns true if this path renderer is able to render the path. Returning false allows the + * caller to fallback to another path renderer This function is called when searching for a path + * renderer capable of rendering a path. + * + * @return true if the path can be drawn by this object, false otherwise. */ - CanDrawPath canDrawPath(const CanDrawPathArgs& args) const { + bool canDrawPath(const CanDrawPathArgs& args) const { SkDEBUGCODE(args.validate();) return this->onCanDrawPath(args); } @@ -162,7 +158,7 @@ public: GrFSAAType::kUnifiedMSAA != args.fRenderTargetContext->fsaaType())); SkASSERT(!(canArgs.fAAType == GrAAType::kMixedSamples && GrFSAAType::kMixedSamples != args.fRenderTargetContext->fsaaType())); - SkASSERT(CanDrawPath::kNo != this->canDrawPath(canArgs)); + SkASSERT(this->canDrawPath(canArgs)); if (!args.fUserStencilSettings->isUnused()) { SkPath path; args.fShape->asPath(&path); @@ -257,7 +253,7 @@ private: /** * Subclass implementation of canDrawPath() */ - virtual CanDrawPath onCanDrawPath(const CanDrawPathArgs& args) const = 0; + virtual bool onCanDrawPath(const CanDrawPathArgs& args) const = 0; /** * Subclass implementation of stencilPath(). Subclass must override iff it ever returns diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp index 4a39f256fe..354d086a22 100644 --- a/src/gpu/GrPathRendererChain.cpp +++ b/src/gpu/GrPathRendererChain.cpp @@ -96,29 +96,18 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer( } } - GrPathRenderer* bestPathRenderer = nullptr; - for (const sk_sp& pr : fChain) { - GrPathRenderer::StencilSupport support = GrPathRenderer::kNoSupport_StencilSupport; - if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) { - support = pr->getStencilSupport(*args.fShape); - if (support < minStencilSupport) { - continue; + 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.fShape); + if (support < minStencilSupport) { + continue; + } else if (stencilSupport) { + *stencilSupport = support; + } } - } - GrPathRenderer::CanDrawPath canDrawPath = pr->canDrawPath(args); - if (GrPathRenderer::CanDrawPath::kNo == canDrawPath) { - continue; - } - if (GrPathRenderer::CanDrawPath::kAsBackup == canDrawPath && bestPathRenderer) { - continue; - } - if (stencilSupport) { - *stencilSupport = support; - } - bestPathRenderer = pr.get(); - if (GrPathRenderer::CanDrawPath::kYes == canDrawPath) { - break; + return fChain[i].get(); } } - return bestPathRenderer; + return nullptr; } diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index 37433ff0c4..5780cee4e8 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -22,16 +22,11 @@ #include "ops/GrRectOpFactory.h" //////////////////////////////////////////////////////////////////////////////// -GrPathRenderer::CanDrawPath -GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { // Pass on any style that applies. The caller will apply the style if a suitable renderer is // not found and try again with the new GrShape. - if (!args.fShape->style().applies() && SkToBool(fResourceProvider) && - (args.fAAType == GrAAType::kCoverage || args.fAAType == GrAAType::kNone)) { - // This is the fallback renderer for when a path is too complicated for the GPU ones. - return CanDrawPath::kAsBackup; - } - return CanDrawPath::kNo; + return !args.fShape->style().applies() && SkToBool(fResourceProvider) && + (args.fAAType == GrAAType::kCoverage || args.fAAType == GrAAType::kNone); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GrSoftwarePathRenderer.h b/src/gpu/GrSoftwarePathRenderer.h index d36b2f6486..2421fa4d70 100644 --- a/src/gpu/GrSoftwarePathRenderer.h +++ b/src/gpu/GrSoftwarePathRenderer.h @@ -53,7 +53,7 @@ private: return GrPathRenderer::kNoSupport_StencilSupport; } - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; bool onDrawPath(const DrawPathArgs&) override; diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp index 4aff0a918c..2bec4ffeb1 100644 --- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp +++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp @@ -39,22 +39,17 @@ GrCoverageCountingPathRenderer::CreateIfSupported(const GrCaps& caps) { new GrCoverageCountingPathRenderer : nullptr); } -GrPathRenderer::CanDrawPath -GrCoverageCountingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrCoverageCountingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { if (!args.fShape->style().isSimpleFill() || args.fShape->inverseFilled() || args.fViewMatrix->hasPerspective() || GrAAType::kCoverage != args.fAAType) { - return CanDrawPath::kNo; + return false; } SkPath path; args.fShape->asPath(&path); - if (SkPathPriv::ConicWeightCnt(path)) { - return CanDrawPath::kNo; - } - - return CanDrawPath::kYes; + return !SkPathPriv::ConicWeightCnt(path); } bool GrCoverageCountingPathRenderer::onDrawPath(const DrawPathArgs& args) { diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h index d7617281a2..e1e28a40bc 100644 --- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h +++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h @@ -38,7 +38,7 @@ public: StencilSupport onGetStencilSupport(const GrShape&) const override { return GrPathRenderer::kNoSupport_StencilSupport; } - CanDrawPath onCanDrawPath(const CanDrawPathArgs& args) const override; + bool onCanDrawPath(const CanDrawPathArgs& args) const override; bool onDrawPath(const DrawPathArgs&) final; // GrOnFlushCallbackObject overrides. diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 0fe74433ff..425dbae148 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -665,14 +665,10 @@ sk_sp QuadEdgeEffect::TestCreate(GrProcessorTestData* d) { /////////////////////////////////////////////////////////////////////////////// -GrPathRenderer::CanDrawPath -GrAAConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { - if (args.fCaps->shaderCaps()->shaderDerivativeSupport() && - (GrAAType::kCoverage == args.fAAType) && args.fShape->style().isSimpleFill() && - !args.fShape->inverseFilled() && args.fShape->knownToBeConvex()) { - return CanDrawPath::kYes; - } - return CanDrawPath::kNo; +bool GrAAConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { + return (args.fCaps->shaderCaps()->shaderDerivativeSupport() && + (GrAAType::kCoverage == args.fAAType) && args.fShape->style().isSimpleFill() && + !args.fShape->inverseFilled() && args.fShape->knownToBeConvex()); } // extract the result vertices and indices from the GrAAConvexTessellator diff --git a/src/gpu/ops/GrAAConvexPathRenderer.h b/src/gpu/ops/GrAAConvexPathRenderer.h index a31d6b9593..420ca60139 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.h +++ b/src/gpu/ops/GrAAConvexPathRenderer.h @@ -15,7 +15,7 @@ public: GrAAConvexPathRenderer(); private: - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; bool onDrawPath(const DrawPathArgs&) override; }; diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp index ba72eacd7e..e00ca3fd5d 100644 --- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp @@ -677,27 +677,26 @@ static void add_line(const SkPoint p[2], /////////////////////////////////////////////////////////////////////////////// -GrPathRenderer::CanDrawPath -GrAAHairLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrAAHairLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { if (GrAAType::kCoverage != args.fAAType) { - return CanDrawPath::kNo; + return false; } if (!IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix, nullptr)) { - return CanDrawPath::kNo; + return false; } // We don't currently handle dashing in this class though perhaps we should. if (args.fShape->style().pathEffect()) { - return CanDrawPath::kNo; + return false; } if (SkPath::kLine_SegmentMask == args.fShape->segmentMask() || args.fCaps->shaderCaps()->shaderDerivativeSupport()) { - return CanDrawPath::kYes; + return true; } - return CanDrawPath::kNo; + return false; } template diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.h b/src/gpu/ops/GrAAHairLinePathRenderer.h index b52d5e9959..e2406a5c01 100644 --- a/src/gpu/ops/GrAAHairLinePathRenderer.h +++ b/src/gpu/ops/GrAAHairLinePathRenderer.h @@ -19,7 +19,7 @@ public: typedef SkTArray FloatArray; private: - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; bool onDrawPath(const DrawPathArgs&) override; diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp index d206951ce4..c1fd4f7e65 100644 --- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp @@ -34,46 +34,39 @@ GrAALinearizingConvexPathRenderer::GrAALinearizingConvexPathRenderer() { /////////////////////////////////////////////////////////////////////////////// -GrPathRenderer::CanDrawPath -GrAALinearizingConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrAALinearizingConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { if (GrAAType::kCoverage != args.fAAType) { - return CanDrawPath::kNo; + return false; } if (!args.fShape->knownToBeConvex()) { - return CanDrawPath::kNo; + return false; } if (args.fShape->style().pathEffect()) { - return CanDrawPath::kNo; + return false; } if (args.fShape->inverseFilled()) { - return CanDrawPath::kNo; + return false; } if (args.fShape->bounds().width() <= 0 && args.fShape->bounds().height() <= 0) { // Stroked zero length lines should draw, but this PR doesn't handle that case - return CanDrawPath::kNo; + return false; } const SkStrokeRec& stroke = args.fShape->style().strokeRec(); if (stroke.getStyle() == SkStrokeRec::kStroke_Style || stroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style) { if (!args.fViewMatrix->isSimilarity()) { - return CanDrawPath::kNo; + return false; } SkScalar strokeWidth = args.fViewMatrix->getMaxScale() * stroke.getWidth(); if (strokeWidth < 1.0f && stroke.getStyle() == SkStrokeRec::kStroke_Style) { - return CanDrawPath::kNo; + return false; } - if (strokeWidth > kMaxStrokeWidth || - !args.fShape->knownToBeClosed() || - stroke.getJoin() == SkPaint::Join::kRound_Join) { - return CanDrawPath::kNo; - } - return CanDrawPath::kYes; + return strokeWidth <= kMaxStrokeWidth && + args.fShape->knownToBeClosed() && + stroke.getJoin() != SkPaint::Join::kRound_Join; } - if (stroke.getStyle() != SkStrokeRec::kFill_Style) { - return CanDrawPath::kNo; - } - return CanDrawPath::kYes; + return stroke.getStyle() == SkStrokeRec::kFill_Style; } // extract the result vertices and indices from the GrAAConvexTessellator diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.h b/src/gpu/ops/GrAALinearizingConvexPathRenderer.h index 4fdcb12a26..afee5db4d4 100644 --- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.h +++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.h @@ -15,7 +15,7 @@ public: GrAALinearizingConvexPathRenderer(); private: - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; bool onDrawPath(const DrawPathArgs&) override; }; diff --git a/src/gpu/ops/GrDashLinePathRenderer.cpp b/src/gpu/ops/GrDashLinePathRenderer.cpp index 73c2b3e8f2..38d486c79f 100644 --- a/src/gpu/ops/GrDashLinePathRenderer.cpp +++ b/src/gpu/ops/GrDashLinePathRenderer.cpp @@ -12,22 +12,18 @@ #include "ops/GrDashOp.h" #include "ops/GrMeshDrawOp.h" -GrPathRenderer::CanDrawPath -GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { SkPoint pts[2]; bool inverted; if (args.fShape->style().isDashed() && args.fShape->asLine(pts, &inverted)) { if (args.fAAType == GrAAType::kMixedSamples) { - return CanDrawPath::kNo; + return false; } // We should never have an inverse dashed case. SkASSERT(!inverted); - if (!GrDashOp::CanDrawDashLine(pts, args.fShape->style(), *args.fViewMatrix)) { - return CanDrawPath::kNo; - } - return CanDrawPath::kYes; + return GrDashOp::CanDrawDashLine(pts, args.fShape->style(), *args.fViewMatrix); } - return CanDrawPath::kNo; + return false; } bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) { diff --git a/src/gpu/ops/GrDashLinePathRenderer.h b/src/gpu/ops/GrDashLinePathRenderer.h index 23227bc824..11abf99396 100644 --- a/src/gpu/ops/GrDashLinePathRenderer.h +++ b/src/gpu/ops/GrDashLinePathRenderer.h @@ -14,7 +14,7 @@ class GrGpu; class GrDashLinePathRenderer : public GrPathRenderer { private: - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; StencilSupport onGetStencilSupport(const GrShape&) const override { return kNoSupport_StencilSupport; diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp index 9741781013..e3b48a8db9 100644 --- a/src/gpu/ops/GrDefaultPathRenderer.cpp +++ b/src/gpu/ops/GrDefaultPathRenderer.cpp @@ -609,20 +609,15 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget return true; } -GrPathRenderer::CanDrawPath -GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { bool isHairline = IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix, nullptr); // If we aren't a single_pass_shape or hairline, we require stencil buffers. if (!(single_pass_shape(*args.fShape) || isHairline) && args.fCaps->avoidStencilBuffers()) { - return CanDrawPath::kNo; + return false; } // This can draw any path with any simple fill style but doesn't do coverage-based antialiasing. - if (GrAAType::kCoverage == args.fAAType || - (!args.fShape->style().isSimpleFill() && !isHairline)) { - return CanDrawPath::kNo; - } - // This is the fallback renderer for when a path is too complicated for the others to draw. - return CanDrawPath::kAsBackup; + return GrAAType::kCoverage != args.fAAType && + (args.fShape->style().isSimpleFill() || isHairline); } bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) { diff --git a/src/gpu/ops/GrDefaultPathRenderer.h b/src/gpu/ops/GrDefaultPathRenderer.h index f7d98190c2..7f7ab2a5e0 100644 --- a/src/gpu/ops/GrDefaultPathRenderer.h +++ b/src/gpu/ops/GrDefaultPathRenderer.h @@ -23,7 +23,7 @@ public: private: StencilSupport onGetStencilSupport(const GrShape&) const override; - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; bool onDrawPath(const DrawPathArgs&) override; diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp index b80a811430..ef19367f61 100644 --- a/src/gpu/ops/GrMSAAPathRenderer.cpp +++ b/src/gpu/ops/GrMSAAPathRenderer.cpp @@ -682,18 +682,15 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon return true; } -GrPathRenderer::CanDrawPath GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { // If we aren't a single_pass_shape, we require stencil buffers. if (!single_pass_shape(*args.fShape) && args.fCaps->avoidStencilBuffers()) { - return CanDrawPath::kNo; + return false; } // This path renderer only fills and relies on MSAA for antialiasing. Stroked shapes are // handled by passing on the original shape and letting the caller compute the stroked shape // which will have a fill style. - if (!args.fShape->style().isSimpleFill() || GrAAType::kCoverage == args.fAAType) { - return CanDrawPath::kNo; - } - return CanDrawPath::kYes; + return args.fShape->style().isSimpleFill() && (GrAAType::kCoverage != args.fAAType); } bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) { diff --git a/src/gpu/ops/GrMSAAPathRenderer.h b/src/gpu/ops/GrMSAAPathRenderer.h index 1353867f16..13d3e15a7e 100644 --- a/src/gpu/ops/GrMSAAPathRenderer.h +++ b/src/gpu/ops/GrMSAAPathRenderer.h @@ -15,7 +15,7 @@ class SK_API GrMSAAPathRenderer : public GrPathRenderer { private: StencilSupport onGetStencilSupport(const GrShape&) const override; - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; bool onDrawPath(const DrawPathArgs&) override; diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp index 1b0648615d..cfdf8734c9 100644 --- a/src/gpu/ops/GrSmallPathRenderer.cpp +++ b/src/gpu/ops/GrSmallPathRenderer.cpp @@ -81,30 +81,30 @@ GrSmallPathRenderer::~GrSmallPathRenderer() { } //////////////////////////////////////////////////////////////////////////////// -GrPathRenderer::CanDrawPath GrSmallPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrSmallPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { if (!args.fCaps->shaderCaps()->shaderDerivativeSupport()) { - return CanDrawPath::kNo; + return false; } // If the shape has no key then we won't get any reuse. if (!args.fShape->hasUnstyledKey()) { - return CanDrawPath::kNo; + return false; } // This only supports filled paths, however, the caller may apply the style to make a filled // path and try again. if (!args.fShape->style().isSimpleFill()) { - return CanDrawPath::kNo; + return false; } // This does non-inverse coverage-based antialiased fills. if (GrAAType::kCoverage != args.fAAType) { - return CanDrawPath::kNo; + return false; } // TODO: Support inverse fill if (args.fShape->inverseFilled()) { - return CanDrawPath::kNo; + return false; } // currently don't support perspective if (args.fViewMatrix->hasPerspective()) { - return CanDrawPath::kNo; + return false; } // Only support paths with bounds within kMaxDim by kMaxDim, @@ -112,18 +112,15 @@ GrPathRenderer::CanDrawPath GrSmallPathRenderer::onCanDrawPath(const CanDrawPath // The goal is to accelerate rendering of lots of small paths that may be scaling. SkScalar scaleFactors[2]; if (!args.fViewMatrix->getMinMaxScales(scaleFactors)) { - return CanDrawPath::kNo; + return false; } SkRect bounds = args.fShape->styledBounds(); SkScalar minDim = SkMinScalar(bounds.width(), bounds.height()); SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); SkScalar minSize = minDim * SkScalarAbs(scaleFactors[0]); SkScalar maxSize = maxDim * SkScalarAbs(scaleFactors[1]); - if (maxDim > kMaxDim || kMinSize > minSize || maxSize > kMaxSize) { - return CanDrawPath::kNo; - } - return CanDrawPath::kYes; + return maxDim <= kMaxDim && kMinSize <= minSize && maxSize <= kMaxSize; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/ops/GrSmallPathRenderer.h b/src/gpu/ops/GrSmallPathRenderer.h index b958baa843..d10c4baa86 100644 --- a/src/gpu/ops/GrSmallPathRenderer.h +++ b/src/gpu/ops/GrSmallPathRenderer.h @@ -31,7 +31,7 @@ private: return GrPathRenderer::kNoSupport_StencilSupport; } - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; bool onDrawPath(const DrawPathArgs&) override; diff --git a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp index 3179ebacc8..4d86efdc0e 100644 --- a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp @@ -31,22 +31,18 @@ GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider* : fResourceProvider(resourceProvider) { } -GrPathRenderer::CanDrawPath -GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { +bool GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { // GrPath doesn't support hairline paths. An arbitrary path effect could produce a hairline // path. if (args.fShape->style().strokeRec().isHairlineStyle() || args.fShape->style().hasNonDashPathEffect()) { - return CanDrawPath::kNo; + return false; } if (args.fHasUserStencilSettings) { - return CanDrawPath::kNo; + return false; } // doesn't do per-path AA, relies on the target having MSAA. - if (GrAAType::kCoverage == args.fAAType) { - return CanDrawPath::kNo; - } - return CanDrawPath::kYes; + return (GrAAType::kCoverage != args.fAAType); } static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const GrShape& shape) { diff --git a/src/gpu/ops/GrStencilAndCoverPathRenderer.h b/src/gpu/ops/GrStencilAndCoverPathRenderer.h index dda0157a5c..c896e61545 100644 --- a/src/gpu/ops/GrStencilAndCoverPathRenderer.h +++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.h @@ -28,7 +28,7 @@ private: return GrPathRenderer::kStencilOnly_StencilSupport; } - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs&) const override; bool onDrawPath(const DrawPathArgs&) override; diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp index 2db4ffcd0d..641a037bbe 100644 --- a/src/gpu/ops/GrTessellatingPathRenderer.cpp +++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp @@ -132,31 +132,27 @@ private: GrTessellatingPathRenderer::GrTessellatingPathRenderer() { } -GrPathRenderer::CanDrawPath -GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { - // This path renderer can draw fill styles, and can do screenspace antialiasing via a one-pixel - // coverage ramp. It can do convex and concave paths, but we'll give simpler algorithms a chance - // to draw the convex ones first. We pass on paths that have styles, though they may come back - // around after applying the styling information to the geometry to create a filled path. In the - // non-AA case, We skip paths that don't have a key since the real advantage of this path +bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { + // This path renderer can draw fill styles, and can do screenspace antialiasing via a + // one-pixel coverage ramp. It can do convex and concave paths, but we'll leave the convex + // ones to simpler algorithms. We pass on paths that have styles, though they may come back + // around after applying the styling information to the geometry to create a filled path. In + // the non-AA case, We skip paths thta don't have a key since the real advantage of this path // renderer comes from caching the tessellated geometry. In the AA case, we do not cache, so we // accept paths without keys. - if (!args.fShape->style().isSimpleFill()) { - return CanDrawPath::kNo; + if (!args.fShape->style().isSimpleFill() || args.fShape->knownToBeConvex()) { + return false; } if (GrAAType::kCoverage == args.fAAType) { SkPath path; args.fShape->asPath(&path); if (path.countVerbs() > 10) { - return CanDrawPath::kNo; + return false; } } else if (!args.fShape->hasUnstyledKey()) { - return CanDrawPath::kNo; + return false; } - if (args.fShape->knownToBeConvex()) { - return CanDrawPath::kAsBackup; - } - return CanDrawPath::kYes; + return true; } namespace { diff --git a/src/gpu/ops/GrTessellatingPathRenderer.h b/src/gpu/ops/GrTessellatingPathRenderer.h index 7dd50fc6eb..d5f2c7af9b 100644 --- a/src/gpu/ops/GrTessellatingPathRenderer.h +++ b/src/gpu/ops/GrTessellatingPathRenderer.h @@ -19,7 +19,7 @@ public: GrTessellatingPathRenderer(); private: - CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; + bool onCanDrawPath(const CanDrawPathArgs& ) const override; StencilSupport onGetStencilSupport(const GrShape&) const override { return GrPathRenderer::kNoSupport_StencilSupport;