Debian Codegraph @

src/gpu/graphite/BuiltInCodeSnippetID.h

raw
1 /*
2 * Copyright 2022 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_BuiltInCodeSnippetID_DEFINED
9 #define skgpu_graphite_BuiltInCodeSnippetID_DEFINED
10
11 #include "include/core/SkTypes.h"
12
13 namespace skgpu::graphite {
14
15 enum class BuiltInCodeSnippetID : int32_t {
16 // This isn't just a signal for a failure during paintparams key creation. It also actually
17 // implements the default behavior for an erroneous draw. That said, Device discards draws that
18 // have a PaintParamsKey referencing an error ID so this behavior is mostly academic.
19 kError,
20
21 // Snippet that passes through prior stage output
22 kPriorOutput,
23
24 // SkShader code snippets
25 kSolidColorShader,
26 kRGBPaintColor,
27 kAlphaOnlyPaintColor,
28 kLinearGradientShader4,
29 kLinearGradientShader8,
30 kLinearGradientShaderTexture,
31 kLinearGradientShaderBuffer,
32 kRadialGradientShader4,
33 kRadialGradientShader8,
34 kRadialGradientShaderTexture,
35 kRadialGradientShaderBuffer,
36 kSweepGradientShader4,
37 kSweepGradientShader8,
38 kSweepGradientShaderTexture,
39 kSweepGradientShaderBuffer,
40 kConicalGradientShader4,
41 kConicalGradientShader8,
42 kConicalGradientShaderTexture,
43 kConicalGradientShaderBuffer,
44
45 kLocalMatrixShader,
46 kLocalMatrixShaderPersp,
47 kImageShader,
48 kImageShaderClamp,
49 kCubicImageShader,
50 kHWImageShader,
51 kYUVImageShader,
52 kCubicYUVImageShader,
53 kHWYUVImageShader,
54 kHWYUVNoSwizzleImageShader,
55 kCoordNormalizeShader,
56 kCoordClampShader,
57 kDitherShader,
58 kPerlinNoiseShader,
59
60 // SkColorFilter code snippets
61 kMatrixColorFilter,
62 kHSLMatrixColorFilter,
63 kTableColorFilter,
64 kGaussianColorFilter,
65
66 // Color space transform snippet and its specializations
67 kColorSpaceXformColorFilter,
68 kColorSpaceXformPremul,
69 kColorSpaceXformSRGB,
70
71 // Emits special variable holding the primitiveColor emitted by a RenderStep
72 kPrimitiveColor,
73
74 // Analytic clip for circular roundrect and AA rect shapes
75 kAnalyticClip,
76
77 // Analytic plus atlas-based clip
78 kAnalyticAndAtlasClip,
79
80 kCompose, // compose 2 children together: outer_1(inner_0(...))
81 kBlendCompose, // compose 3 children together: outer_2(inner_0(...), inner_1(...))
82
83 // SkBlender code snippets
84 kPorterDuffBlender, // Can handle all GetPorterDuffBlendConstants() modes
85 kHSLCBlender, // kHue,kSaturation,kLuminosity, and kColor modes
86 // NOTE: We could offer an in-shader consolidation for overlay+hardlight, and darken+lighten
87 // but for now, those will map to the FixedBlends.
88
89 // Fixed blend modes hard code a specific blend function into the shader tree. This can be
90 // valuable when an internal effect is known to always do a certain blend and we want to
91 // benefit from inlining constants. It is also important for being able to convert the final
92 // blend of the SkPaint into fixed function HW blending, where each HW blend is part of the
93 // pipeline key, so using a known blend mode ID ensures the PaintParamsKey are also different.
94 //
95 // Lastly, for advanced blend modes that require complex shader calculations, we assume they
96 // are used rarely and with intent (i.e. unlikely to share a common shader tree with another
97 // advanced blend if we were to add branching). This keeps the amount of reachable SkSL that
98 // must be compiled for a given pipeline with advanced blends to a minimum.
99 //
100 // NOTE: Pipeline code generation depends on the fixed-function code IDs being contiguous and be
101 // defined last in the enum. They are ordered to match SkBlendMode such that:
102 // (id - kFirstFixedBlend) == SkBlendMode).
103 kFixedBlend_Clear,
104 kFixedBlend_Src,
105 kFixedBlend_Dst,
106 kFixedBlend_SrcOver,
107 kFixedBlend_DstOver,
108 kFixedBlend_SrcIn,
109 kFixedBlend_DstIn,
110 kFixedBlend_SrcOut,
111 kFixedBlend_DstOut,
112 kFixedBlend_SrcATop,
113 kFixedBlend_DstATop,
114 kFixedBlend_Xor,
115
116 kFixedBlend_Plus, // NOTE: Adds shader clamping, not compatible with GetPorterDuffConstants
117 kFixedBlend_Modulate, // NOTE: Uses color channels, incompatible with kPorterDuffBlender
118 kFixedBlend_Screen, // ""
119
120 // With support for advanced blend modes, these can also be handled by HW for the final blend.
121 kFixedBlend_Overlay,
122 kFixedBlend_Darken,
123 kFixedBlend_Lighten,
124 kFixedBlend_ColorDodge,
125 kFixedBlend_ColorBurn,
126 kFixedBlend_HardLight,
127 kFixedBlend_SoftLight,
128 kFixedBlend_Difference,
129 kFixedBlend_Exclusion,
130 kFixedBlend_Multiply,
131
132 kFixedBlend_Hue,
133 kFixedBlend_Saturation,
134 kFixedBlend_Color,
135 kFixedBlend_Luminosity,
136
137 kFirstFixedBlend = kFixedBlend_Clear,
138 kLast = kFixedBlend_Luminosity
139 };
140 static constexpr int kBuiltInCodeSnippetIDCount = static_cast<int>(BuiltInCodeSnippetID::kLast)+1;
141 static constexpr int kFixedBlendIDOffset =
142 static_cast<int>(BuiltInCodeSnippetID::kFirstFixedBlend);
143
144 static_assert(BuiltInCodeSnippetID::kLast == BuiltInCodeSnippetID::kFixedBlend_Luminosity);
145
146 } // namespace skgpu::graphite
147
148 #endif // skgpu_graphite_BuiltInCodeSnippetID_DEFINED