Flutter Engine
The Flutter Engine
PathRendererChain.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
10
28
29namespace skgpu::ganesh {
30
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}
71
73 DrawType drawType,
74 PathRenderer::StencilSupport* stencilSupport) {
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}
120
121} // namespace skgpu::ganesh
const char * options
const GrCaps * caps() const
Definition: GrCaps.h:57
void addOnFlushCallbackObject(GrOnFlushCallbackObject *)
GrRecordingContextPriv priv()
static sk_sp< AtlasPathRenderer > Make(GrRecordingContext *rContext)
PathRenderer * getPathRenderer(const PathRenderer::CanDrawPathArgs &, DrawType, PathRenderer::StencilSupport *)
PathRendererChain(GrRecordingContext *, const Options &)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static TessellatorLibtess tess