Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | List of all members
skgpu::ganesh::PathRendererChain Class Reference

#include <PathRendererChain.h>

Inheritance diagram for skgpu::ganesh::PathRendererChain:
SkNoncopyable

Classes

struct  Options
 

Public Types

enum class  DrawType { kColor , kStencil , kStencilAndColor }
 

Public Member Functions

 PathRendererChain (GrRecordingContext *, const Options &)
 
PathRenderergetPathRenderer (const PathRenderer::CanDrawPathArgs &, DrawType, PathRenderer::StencilSupport *)
 
skgpu::ganesh::AtlasPathRenderergetAtlasPathRenderer ()
 
PathRenderergetTessellationPathRenderer ()
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Detailed Description

Keeps track of an ordered list of path renderers. When a path needs to be drawn this list is scanned to find the most preferred renderer. To add your path renderer to the list implement the GrPathRenderer::AddPathRenderers function.

Definition at line 28 of file PathRendererChain.h.

Member Enumeration Documentation

◆ DrawType

Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR returned by getPathRenderer

Enumerator
kColor 
kStencil 
kStencilAndColor 

Definition at line 38 of file PathRendererChain.h.

38 {
39 kColor, // draw to the color buffer, no AA
40 kStencil, // draw just to the stencil buffer
41 kStencilAndColor, // draw the stencil and color buffer, no AA
42 };
@ kColor
hue and saturation of source with luminosity of destination

Constructor & Destructor Documentation

◆ PathRendererChain()

skgpu::ganesh::PathRendererChain::PathRendererChain ( GrRecordingContext context,
const Options options 
)

Definition at line 31 of file PathRendererChain.cpp.

31 {
32 const GrCaps& caps = *context->priv().caps();
33 if (options.fGpuPathRenderers & GpuPathRenderers::kDashLine) {
34 fChain.push_back(sk_make_sp<ganesh::DashLinePathRenderer>());
35 }
36 if (options.fGpuPathRenderers & GpuPathRenderers::kAAConvex) {
37 fChain.push_back(sk_make_sp<AAConvexPathRenderer>());
38 }
39 if (options.fGpuPathRenderers & GpuPathRenderers::kAAHairline) {
40 fChain.push_back(sk_make_sp<AAHairLinePathRenderer>());
41 }
42 if (options.fGpuPathRenderers & GpuPathRenderers::kAALinearizing) {
43 fChain.push_back(sk_make_sp<AALinearizingConvexPathRenderer>());
44 }
45 if (options.fGpuPathRenderers & GpuPathRenderers::kAtlas) {
46 if (auto atlasPathRenderer = AtlasPathRenderer::Make(context)) {
47 fAtlasPathRenderer = atlasPathRenderer.get();
48 context->priv().addOnFlushCallbackObject(atlasPathRenderer.get());
49 fChain.push_back(std::move(atlasPathRenderer));
50 }
51 }
52#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
53 if (options.fGpuPathRenderers & GpuPathRenderers::kSmall) {
54 fChain.push_back(sk_make_sp<SmallPathRenderer>());
55 }
56 if (options.fGpuPathRenderers & GpuPathRenderers::kTriangulating) {
57 fChain.push_back(sk_make_sp<TriangulatingPathRenderer>());
58 }
59#endif
60 if (options.fGpuPathRenderers & GpuPathRenderers::kTessellation) {
62 auto tess = sk_make_sp<TessellationPathRenderer>();
63 fTessellationPathRenderer = tess.get();
64 fChain.push_back(std::move(tess));
65 }
66 }
67
68 // We always include the default path renderer (as well as SW), so we can draw any path
69 fChain.push_back(sk_make_sp<DefaultPathRenderer>());
70}
const char * options
const GrCaps * caps() const
Definition: GrCaps.h:57
void addOnFlushCallbackObject(GrOnFlushCallbackObject *)
GrRecordingContextPriv priv()
static sk_sp< AtlasPathRenderer > Make(GrRecordingContext *rContext)
static TessellatorLibtess tess

Member Function Documentation

◆ getAtlasPathRenderer()

skgpu::ganesh::AtlasPathRenderer * skgpu::ganesh::PathRendererChain::getAtlasPathRenderer ( )
inline

Returns a direct pointer to the atlas path renderer, or null if it is not in the chain.

Definition at line 54 of file PathRendererChain.h.

54{ return fAtlasPathRenderer; }

◆ getPathRenderer()

PathRenderer * skgpu::ganesh::PathRendererChain::getPathRenderer ( const PathRenderer::CanDrawPathArgs args,
DrawType  drawType,
PathRenderer::StencilSupport stencilSupport 
)

Returns a GrPathRenderer compatible with the request if one is available. If the caller is drawing the path to the stencil buffer then stencilSupport can be used to determine whether the path can be rendered with arbitrary stencil rules or not. See comments on StencilSupport in GrPathRenderer.h.

Definition at line 72 of file PathRendererChain.cpp.

74 {
79 PathRenderer::StencilSupport minStencilSupport;
80 if (DrawType::kStencil == drawType) {
82 } else if (DrawType::kStencilAndColor == drawType) {
84 } else {
86 }
87 if (minStencilSupport != PathRenderer::kNoSupport_StencilSupport) {
88 // We don't support (and shouldn't need) stenciling of non-fill paths.
89 if (!args.fShape->style().isSimpleFill()) {
90 return nullptr;
91 }
92 }
93
94 PathRenderer* bestPathRenderer = nullptr;
95 for (const sk_sp<PathRenderer>& pr : fChain) {
97 if (PathRenderer::kNoSupport_StencilSupport != minStencilSupport) {
98 support = pr->getStencilSupport(*args.fShape);
99 if (support < minStencilSupport) {
100 continue;
101 }
102 }
103 PathRenderer::CanDrawPath canDrawPath = pr->canDrawPath(args);
104 if (PathRenderer::CanDrawPath::kNo == canDrawPath) {
105 continue;
106 }
107 if (PathRenderer::CanDrawPath::kAsBackup == canDrawPath && bestPathRenderer) {
108 continue;
109 }
110 if (stencilSupport) {
111 *stencilSupport = support;
112 }
113 bestPathRenderer = pr.get();
114 if (PathRenderer::CanDrawPath::kYes == canDrawPath) {
115 break;
116 }
117 }
118 return bestPathRenderer;
119}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ getTessellationPathRenderer()

PathRenderer * skgpu::ganesh::PathRendererChain::getTessellationPathRenderer ( )
inline

Returns a direct pointer to the tessellation path renderer, or null if it is not in the chain.

Definition at line 58 of file PathRendererChain.h.

58 {
59 return fTessellationPathRenderer;
60 }

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