/src/skia/src/gpu/ganesh/PathRendererChain.h
Line | Count | Source |
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 | | #ifndef PathRendererChain_DEFINED |
9 | | #define PathRendererChain_DEFINED |
10 | | |
11 | | #include "src/gpu/ganesh/PathRenderer.h" |
12 | | |
13 | | #include "include/core/SkTypes.h" |
14 | | #include "include/private/base/SkNoncopyable.h" |
15 | | #include "include/private/base/SkTArray.h" |
16 | | #include "include/private/gpu/ganesh/GrTypesPriv.h" |
17 | | |
18 | | namespace skgpu::ganesh { |
19 | | |
20 | | class AtlasPathRenderer; |
21 | | |
22 | | /** |
23 | | * Keeps track of an ordered list of path renderers. When a path needs to be |
24 | | * drawn this list is scanned to find the most preferred renderer. To add your |
25 | | * path renderer to the list implement the GrPathRenderer::AddPathRenderers |
26 | | * function. |
27 | | */ |
28 | | class PathRendererChain : public SkNoncopyable { |
29 | | public: |
30 | | struct Options { |
31 | | bool fAllowPathMaskCaching = false; |
32 | | GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault; |
33 | | }; |
34 | | PathRendererChain(GrRecordingContext*, const Options&); |
35 | | |
36 | | /** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR |
37 | | returned by getPathRenderer */ |
38 | | enum class DrawType { |
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 | | }; |
43 | | |
44 | | /** Returns a GrPathRenderer compatible with the request if one is available. If the caller |
45 | | is drawing the path to the stencil buffer then stencilSupport can be used to determine |
46 | | whether the path can be rendered with arbitrary stencil rules or not. See comments on |
47 | | StencilSupport in GrPathRenderer.h. */ |
48 | | PathRenderer* getPathRenderer(const PathRenderer::CanDrawPathArgs&, |
49 | | DrawType, |
50 | | PathRenderer::StencilSupport*); |
51 | | |
52 | | /** Returns a direct pointer to the atlas path renderer, or null if it is not in the |
53 | | chain. */ |
54 | 9.78k | skgpu::ganesh::AtlasPathRenderer* getAtlasPathRenderer() { return fAtlasPathRenderer; } |
55 | | |
56 | | /** Returns a direct pointer to the tessellation path renderer, or null if it is not in the |
57 | | chain. */ |
58 | 14.6k | PathRenderer* getTessellationPathRenderer() { |
59 | 14.6k | return fTessellationPathRenderer; |
60 | 14.6k | } |
61 | | |
62 | | private: |
63 | | enum { |
64 | | kPreAllocCount = 8, |
65 | | }; |
66 | | skia_private::STArray<kPreAllocCount, sk_sp<PathRenderer>> fChain; |
67 | | AtlasPathRenderer* fAtlasPathRenderer = nullptr; |
68 | | PathRenderer* fTessellationPathRenderer = nullptr; |
69 | | }; |
70 | | |
71 | | } // namespace skgpu::ganesh |
72 | | |
73 | | #endif // PathRendererChain_DEFINED |