Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
skgpu::ganesh::SmallPathRenderer Class Referencefinal

#include <SmallPathRenderer.h>

Inheritance diagram for skgpu::ganesh::SmallPathRenderer:
skgpu::ganesh::PathRenderer SkRefCnt SkRefCntBase

Public Member Functions

 SmallPathRenderer ()=default
 
const char * name () const override
 
- Public Member Functions inherited from skgpu::ganesh::PathRenderer
 PathRenderer ()=default
 
StencilSupport getStencilSupport (const GrStyledShape &shape) const
 
CanDrawPath canDrawPath (const CanDrawPathArgs &args) const
 
bool drawPath (const DrawPathArgs &args)
 
void stencilPath (const StencilPathArgs &args)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Private Member Functions

StencilSupport onGetStencilSupport (const GrStyledShape &) const override
 
CanDrawPath onCanDrawPath (const CanDrawPathArgs &) const override
 
bool onDrawPath (const DrawPathArgs &) override
 

Additional Inherited Members

- Public Types inherited from skgpu::ganesh::PathRenderer
enum  StencilSupport { kNoSupport_StencilSupport , kStencilOnly_StencilSupport , kNoRestriction_StencilSupport }
 
enum class  CanDrawPath { kNo , kAsBackup , kYes }
 
- Static Protected Member Functions inherited from skgpu::ganesh::PathRenderer
static void GetPathDevBounds (const SkPath &path, SkISize devSize, const SkMatrix &matrix, SkRect *bounds)
 

Detailed Description

Definition at line 19 of file SmallPathRenderer.h.

Constructor & Destructor Documentation

◆ SmallPathRenderer()

skgpu::ganesh::SmallPathRenderer::SmallPathRenderer ( )
default

Member Function Documentation

◆ name()

const char * skgpu::ganesh::SmallPathRenderer::name ( ) const
inlineoverridevirtual

Implements skgpu::ganesh::PathRenderer.

Definition at line 23 of file SmallPathRenderer.h.

23{ return "Small"; }

◆ onCanDrawPath()

PathRenderer::CanDrawPath skgpu::ganesh::SmallPathRenderer::onCanDrawPath ( const CanDrawPathArgs args) const
overrideprivatevirtual

Subclass implementation of canDrawPath()

Implements skgpu::ganesh::PathRenderer.

Definition at line 668 of file SmallPathRenderer.cpp.

668 {
669 if (!args.fCaps->shaderCaps()->fShaderDerivativeSupport) {
670 return CanDrawPath::kNo;
671 }
672 // If the shape has no key then we won't get any reuse.
673 if (!args.fShape->hasUnstyledKey()) {
674 return CanDrawPath::kNo;
675 }
676 // This only supports filled paths, however, the caller may apply the style to make a filled
677 // path and try again.
678 if (!args.fShape->style().isSimpleFill()) {
679 return CanDrawPath::kNo;
680 }
681 // This does non-inverse coverage-based antialiased fills.
682 if (GrAAType::kCoverage != args.fAAType) {
683 return CanDrawPath::kNo;
684 }
685 // TODO: Support inverse fill
686 if (args.fShape->inverseFilled()) {
687 return CanDrawPath::kNo;
688 }
689
690 SkScalar scaleFactors[2] = { 1, 1 };
691 // TODO: handle perspective distortion
692 if (!args.fViewMatrix->hasPerspective() && !args.fViewMatrix->getMinMaxScales(scaleFactors)) {
693 return CanDrawPath::kNo;
694 }
695 // For affine transformations, too much shear can produce artifacts.
696 if (!scaleFactors[0] || scaleFactors[1]/scaleFactors[0] > 4) {
697 return CanDrawPath::kNo;
698 }
699 // Only support paths with bounds within kMaxDim by kMaxDim,
700 // scaled to have bounds within kMaxSize by kMaxSize.
701 // The goal is to accelerate rendering of lots of small paths that may be scaling.
702 SkRect bounds = args.fShape->styledBounds();
703 SkScalar minDim = std::min(bounds.width(), bounds.height());
704 SkScalar maxDim = std::max(bounds.width(), bounds.height());
705 SkScalar minSize = minDim * SkScalarAbs(scaleFactors[0]);
706 SkScalar maxSize = maxDim * SkScalarAbs(scaleFactors[1]);
707 if (maxDim > kMaxDim || kMinSize > minSize || maxSize > kMaxSize) {
708 return CanDrawPath::kNo;
709 }
710
711 return CanDrawPath::kYes;
712}
#define SkScalarAbs(x)
Definition SkScalar.h:39
float SkScalar
Definition extension.cpp:12
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Optional< SkRect > bounds
Definition SkRecords.h:189

◆ onDrawPath()

bool skgpu::ganesh::SmallPathRenderer::onDrawPath ( const DrawPathArgs args)
overrideprivatevirtual

Subclass implementation of drawPath()

Implements skgpu::ganesh::PathRenderer.

Definition at line 714 of file SmallPathRenderer.cpp.

714 {
715 GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(),
716 "SmallPathRenderer::onDrawPath");
717
718 // we've already bailed on inverse filled paths, so this is safe
719 SkASSERT(!args.fShape->isEmpty());
720 SkASSERT(args.fShape->hasUnstyledKey());
721
722 GrOp::Owner op = SmallPathOp::Make(
723 args.fContext, std::move(args.fPaint), *args.fShape, *args.fViewMatrix,
724 args.fGammaCorrect, args.fUserStencilSettings);
725 args.fSurfaceDrawContext->addDrawOp(args.fClip, std::move(op));
726
727 return true;
728}
#define GR_AUDIT_TRAIL_AUTO_FRAME(audit_trail, framename)
#define SkASSERT(cond)
Definition SkAssert.h:116
std::unique_ptr< GrOp > Owner
Definition GrOp.h:72

◆ onGetStencilSupport()

StencilSupport skgpu::ganesh::SmallPathRenderer::onGetStencilSupport ( const GrStyledShape ) const
inlineoverrideprivatevirtual

Subclass overrides if it has any limitations of stenciling support.

Reimplemented from skgpu::ganesh::PathRenderer.

Definition at line 26 of file SmallPathRenderer.h.


The documentation for this class was generated from the following files: