Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Protected Member Functions | Private Member Functions | List of all members
skgpu::ganesh::PathRenderer Class Referenceabstract

#include <PathRenderer.h>

Inheritance diagram for skgpu::ganesh::PathRenderer:
SkRefCnt SkRefCntBase skgpu::ganesh::AAConvexPathRenderer skgpu::ganesh::AAHairLinePathRenderer skgpu::ganesh::AALinearizingConvexPathRenderer skgpu::ganesh::AtlasPathRenderer skgpu::ganesh::DashLinePathRenderer skgpu::ganesh::DefaultPathRenderer skgpu::ganesh::SmallPathRenderer skgpu::ganesh::SoftwarePathRenderer skgpu::ganesh::TessellationPathRenderer skgpu::ganesh::TriangulatingPathRenderer

Classes

struct  CanDrawPathArgs
 
struct  DrawPathArgs
 
struct  StencilPathArgs
 

Public Types

enum  StencilSupport { kNoSupport_StencilSupport , kStencilOnly_StencilSupport , kNoRestriction_StencilSupport }
 
enum class  CanDrawPath { kNo , kAsBackup , kYes }
 

Public Member Functions

 PathRenderer ()=default
 
virtual const char * name () const =0
 
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
 

Static Protected Member Functions

static void GetPathDevBounds (const SkPath &path, SkISize devSize, const SkMatrix &matrix, SkRect *bounds)
 

Private Member Functions

virtual StencilSupport onGetStencilSupport (const GrStyledShape &) const
 
virtual bool onDrawPath (const DrawPathArgs &args)=0
 
virtual CanDrawPath onCanDrawPath (const CanDrawPathArgs &args) const =0
 
virtual void onStencilPath (const StencilPathArgs &)
 

Detailed Description

Base class for drawing paths into a OpsTask.

Definition at line 36 of file PathRenderer.h.

Member Enumeration Documentation

◆ CanDrawPath

Enumerator
kNo 
kAsBackup 
kYes 

Definition at line 75 of file PathRenderer.h.

75 {
76 kNo,
77 kAsBackup, // i.e. This renderer is better than SW fallback if no others can draw the path.
78 kYes
79 };

◆ StencilSupport

A caller may wish to use a path renderer to draw a path into the stencil buffer. However, the path renderer itself may require use of the stencil buffer. Also a path renderer may use a GrProcessor coverage stage that sets coverage to zero to eliminate pixels that are covered by bounding geometry but outside the path. These exterior pixels would still be rendered into the stencil.

A PathRenderer can provide three levels of support for stenciling paths: 1) kNoRestriction: This is the most general. The caller passes a GrPaint and calls drawPath(). The path is rendered exactly as the draw state indicates including support for simultaneous color and stenciling with arbitrary stenciling rules. Pixels partially covered by AA paths are affected by the stencil settings. 2) kStencilOnly: The path renderer cannot apply arbitrary stencil rules nor shade and stencil simultaneously. The path renderer does support the stencilPath() function which performs no color writes and writes a non-zero stencil value to pixels covered by the path. 3) kNoSupport: This path renderer cannot be used to stencil the path.

Enumerator
kNoSupport_StencilSupport 
kStencilOnly_StencilSupport 
kNoRestriction_StencilSupport 

Definition at line 60 of file PathRenderer.h.

Constructor & Destructor Documentation

◆ PathRenderer()

skgpu::ganesh::PathRenderer::PathRenderer ( )
default

Member Function Documentation

◆ canDrawPath()

CanDrawPath skgpu::ganesh::PathRenderer::canDrawPath ( const CanDrawPathArgs args) const
inline

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.

Definition at line 113 of file PathRenderer.h.

113 {
114 SkDEBUGCODE(args.validate();)
115 return this->onCanDrawPath(args);
116 }
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
virtual CanDrawPath onCanDrawPath(const CanDrawPathArgs &args) const =0
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ drawPath()

bool skgpu::ganesh::PathRenderer::drawPath ( const DrawPathArgs args)

Draws the path into the draw target. If getStencilSupport() would return kNoRestriction then the subclass must respect the stencil settings.

Definition at line 47 of file PathRenderer.cpp.

47 {
48#ifdef SK_DEBUG
49 args.validate();
50 CanDrawPathArgs canArgs;
51 canArgs.fCaps = args.fContext->priv().caps();
52 canArgs.fProxy = args.fSurfaceDrawContext->asRenderTargetProxy();
53 canArgs.fClipConservativeBounds = args.fClipConservativeBounds;
54 canArgs.fViewMatrix = args.fViewMatrix;
55 canArgs.fShape = args.fShape;
56 canArgs.fPaint = &args.fPaint;
57 canArgs.fSurfaceProps = &args.fSurfaceDrawContext->surfaceProps();
58 canArgs.fAAType = args.fAAType;
59 canArgs.validate();
60
61 canArgs.fHasUserStencilSettings = !args.fUserStencilSettings->isUnused();
62 SkASSERT(CanDrawPath::kNo != this->canDrawPath(canArgs));
63 if (!args.fUserStencilSettings->isUnused()) {
65 args.fShape->asPath(&path);
66 SkASSERT(args.fShape->style().isSimpleFill());
68 }
69#endif
70 return this->onDrawPath(args);
71}
#define SkASSERT(cond)
Definition SkAssert.h:116
CanDrawPath canDrawPath(const CanDrawPathArgs &args) const
StencilSupport getStencilSupport(const GrStyledShape &shape) const
virtual bool onDrawPath(const DrawPathArgs &args)=0
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ GetPathDevBounds()

void skgpu::ganesh::PathRenderer::GetPathDevBounds ( const SkPath path,
SkISize  devSize,
const SkMatrix matrix,
SkRect bounds 
)
staticprotected

Definition at line 73 of file PathRenderer.cpp.

76 {
77 if (path.isInverseFillType()) {
78 *bounds = SkRect::Make(devSize);
79 return;
80 }
81 *bounds = path.getBounds();
82 matrix.mapRect(bounds);
83}
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
Optional< SkRect > bounds
Definition SkRecords.h:189
static SkRect Make(const SkISize &size)
Definition SkRect.h:669

◆ getStencilSupport()

PathRenderer::StencilSupport skgpu::ganesh::PathRenderer::getStencilSupport ( const GrStyledShape shape) const

This function is to get the stencil support for a particular path. The path's fill must not be an inverse type. The path will always be filled and not stroked.

Parameters
shapethe shape that will be drawn. Must be simple fill styled and non-inverse filled.

Definition at line 39 of file PathRenderer.cpp.

39 {
40 SkDEBUGCODE(SkPath path;)
41 SkDEBUGCODE(shape.asPath(&path);)
42 SkASSERT(shape.style().isSimpleFill());
43 SkASSERT(!path.isInverseFillType());
44 return this->onGetStencilSupport(shape);
45}
bool isSimpleFill() const
Definition GrStyle.h:114
void asPath(SkPath *out) const
const GrStyle & style() const
virtual StencilSupport onGetStencilSupport(const GrStyledShape &) const

◆ name()

virtual const char * skgpu::ganesh::PathRenderer::name ( ) const
pure virtual

◆ onCanDrawPath()

virtual CanDrawPath skgpu::ganesh::PathRenderer::onCanDrawPath ( const CanDrawPathArgs args) const
privatepure virtual

◆ onDrawPath()

virtual bool skgpu::ganesh::PathRenderer::onDrawPath ( const DrawPathArgs args)
privatepure virtual

◆ onGetStencilSupport()

virtual StencilSupport skgpu::ganesh::PathRenderer::onGetStencilSupport ( const GrStyledShape ) const
inlineprivatevirtual

◆ onStencilPath()

void skgpu::ganesh::PathRenderer::onStencilPath ( const StencilPathArgs args)
privatevirtual

Subclass implementation of stencilPath(). Subclass must override iff it ever returns kStencilOnly in onGetStencilSupport().

Reimplemented in skgpu::ganesh::DefaultPathRenderer, and skgpu::ganesh::TessellationPathRenderer.

Definition at line 85 of file PathRenderer.cpp.

85 {
86 static constexpr GrUserStencilSettings kIncrementStencil(
88 0xffff,
90 0xffff,
93 0xffff>()
94 );
95
97 DrawPathArgs drawArgs{args.fContext,
98 std::move(paint),
99 &kIncrementStencil,
100 args.fSurfaceDrawContext,
101 nullptr, // clip
102 args.fClipConservativeBounds,
103 args.fViewMatrix,
104 args.fShape,
105 (GrAA::kYes == args.fDoStencilMSAA) ? GrAAType::kMSAA : GrAAType::kNone,
106 false};
107 this->drawPath(drawArgs);
108}
GrAAType
bool drawPath(const DrawPathArgs &args)
const Paint & paint
static constexpr Init< Ref, Test, TestMask, PassOp, FailOp, WriteMask > StaticInit()

◆ stencilPath()

void skgpu::ganesh::PathRenderer::stencilPath ( const StencilPathArgs args)
inline

Draws the path to the stencil buffer. Assume the writable stencil bits are already initialized to zero. The pixels inside the path will have non-zero stencil values afterwards.

Definition at line 167 of file PathRenderer.h.

167 {
168 SkDEBUGCODE(args.validate();)
170 this->onStencilPath(args);
171 }
virtual void onStencilPath(const StencilPathArgs &)

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