Revert "Improve GrPathRendererChain heuristics"
This reverts commit 60f42494f5
.
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 <brianosman@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
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 <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
parent
b3e39f6759
commit
e5ede4b138
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -96,29 +96,18 @@ GrPathRenderer* GrPathRendererChain::getPathRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
GrPathRenderer* bestPathRenderer = nullptr;
|
||||
for (const sk_sp<GrPathRenderer>& 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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -665,14 +665,10 @@ sk_sp<GrGeometryProcessor> 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
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
GrAAConvexPathRenderer();
|
||||
|
||||
private:
|
||||
CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
|
||||
bool onCanDrawPath(const CanDrawPathArgs&) const override;
|
||||
|
||||
bool onDrawPath(const DrawPathArgs&) override;
|
||||
};
|
||||
|
@ -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 <class VertexType>
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
typedef SkTArray<float, true> FloatArray;
|
||||
|
||||
private:
|
||||
CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
|
||||
bool onCanDrawPath(const CanDrawPathArgs&) const override;
|
||||
|
||||
bool onDrawPath(const DrawPathArgs&) override;
|
||||
|
||||
|
@ -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
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
GrAALinearizingConvexPathRenderer();
|
||||
|
||||
private:
|
||||
CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
|
||||
bool onCanDrawPath(const CanDrawPathArgs&) const override;
|
||||
|
||||
bool onDrawPath(const DrawPathArgs&) override;
|
||||
};
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user