Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
VelloRenderer.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
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 skgpu_graphite_compute_VelloRenderer_DEFINED
9#define skgpu_graphite_compute_VelloRenderer_DEFINED
10
12#include "include/core/SkPath.h"
17
18#include <memory>
19
20namespace skgpu::graphite {
21
22class Caps;
23class DispatchGroup;
24class Recorder;
25class TextureProxy;
26class Transform;
27
28// Encodes Bezier path fills, shapes, and clips. Once populated, this data structure can be used
29// with the full compositing and coverage mask generating pipelines. The latter only uses the red
30// color channel information.
31//
32// All color type parameters are expected to be unpremultiplied and in the sRGB color space.
33class VelloScene final {
34public:
35 VelloScene();
36
37 void reset();
38
39 void solidFill(const SkPath&,
40 const SkColor4f&,
41 const SkPathFillType,
42 const Transform& transform);
43
44 void solidStroke(const SkPath&,
45 const SkColor4f&,
46 const SkStrokeRec&,
47 const Transform& transform);
48
49 void pushClipLayer(const SkPath& shape, const Transform& transform);
50 void popClipLayer();
51
52private:
53 friend class VelloRenderer;
54
55 // Disallow copy
56 VelloScene(const VelloScene&) = delete;
57 VelloScene& operator=(const VelloScene&) = delete;
58
59 ::rust::Box<::vello_cpp::Encoding> fEncoding;
60 SkDEBUGCODE(int fLayers = 0;)
61};
62
63enum class VelloAaConfig {
65 kMSAA16,
66 kMSAA8,
67};
68
69// A VelloRenderer that is specialized for rendering coverage masks. The renderer only supports
70// paths and clipping and omits the full vello imaging model (e.g. gradients and images).
71//
72// VelloRenderer requires `kAlpha_8_SkColorType` as the target color type on platforms that
73// support the `R8Unorm` storage texture view format. Otherwise, the texture format must be
74// `kRGBA_8888_SkColorType`.
75class VelloRenderer final {
76public:
77 explicit VelloRenderer(const Caps*);
79
80 struct RenderParams {
81 // Dimensions of the fine rasterization target
82 uint32_t fWidth;
83 uint32_t fHeight;
84
85 // The background color used during blending.
87
88 // The antialiasing method.
90 };
91
92 // Run the full pipeline which supports compositing colors with different blend styles. Does
93 // nothing if `scene` or target render dimensions are empty.
94 //
95 // The color type of `target` must be `kAlpha_8_SkColorType` on platforms that support R8Unorm
96 // storage textures. Otherwise, it must be `kRGBA_8888_SkColorType`.
97 std::unique_ptr<DispatchGroup> renderScene(const RenderParams&,
98 const VelloScene&,
100 Recorder*) const;
101
102private:
103 // Pipelines
104 VelloBackdropDynStep fBackdrop;
105 VelloBboxClearStep fBboxClear;
106 VelloBinningStep fBinning;
107 VelloClipLeafStep fClipLeaf;
108 VelloClipReduceStep fClipReduce;
109 VelloCoarseStep fCoarse;
110 VelloDrawLeafStep fDrawLeaf;
111 VelloDrawReduceStep fDrawReduce;
112 VelloFlattenStep fFlatten;
113 VelloPathCountStep fPathCount;
114 VelloPathCountSetupStep fPathCountSetup;
115 VelloPathTilingStep fPathTiling;
116 VelloPathTilingSetupStep fPathTilingSetup;
117 VelloPathtagReduceStep fPathtagReduce;
118 VelloPathtagReduce2Step fPathtagReduce2;
119 VelloPathtagScan1Step fPathtagScan1;
120 VelloPathtagScanLargeStep fPathtagScanLarge;
121 VelloPathtagScanSmallStep fPathtagScanSmall;
122 VelloTileAllocStep fTileAlloc;
123
124 // Fine rasterization stage variants:
125 std::unique_ptr<ComputeStep> fFineArea;
126 std::unique_ptr<ComputeStep> fFineMsaa16;
127 std::unique_ptr<ComputeStep> fFineMsaa8;
128};
129
130} // namespace skgpu::graphite
131
132#endif // skgpu_graphite_compute_VelloRenderer_DEFINED
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
SkPathFillType
Definition SkPathTypes.h:11
std::unique_ptr< DispatchGroup > renderScene(const RenderParams &, const VelloScene &, sk_sp< TextureProxy > target, Recorder *) const
void pushClipLayer(const SkPath &shape, const Transform &transform)
void solidStroke(const SkPath &, const SkColor4f &, const SkStrokeRec &, const Transform &transform)
void solidFill(const SkPath &, const SkColor4f &, const SkPathFillType, const Transform &transform)
uint32_t * target
skgpu::graphite::Transform Transform
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition p3.cpp:47