• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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. Currently it just draws solid
18     // magenta.
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     kImageShader,
47     kCubicImageShader,
48     kHWImageShader,
49     kYUVImageShader,
50     kCubicYUVImageShader,
51     kCoordClampShader,
52     kDitherShader,
53     kPerlinNoiseShader,
54     kRuntimeShader,
55 
56     // SkColorFilter code snippets
57     kMatrixColorFilter,
58     kTableColorFilter,
59     kGaussianColorFilter,
60     kColorSpaceXformColorFilter,
61 
62     // SkBlender code snippets
63     kBlendShader,
64     kBlendModeBlender,
65     kCoeffBlender,
66 
67     // Emits special variable holding the primitiveColor emitted by a RenderStep
68     kPrimitiveColor,
69 
70     // Dest Read code snippets
71     kDstReadSample,
72     kDstReadFetch,
73 
74     // Clip shader snippet
75     // TODO(b/238763003): Avoid incorporating clip shaders into the actual shader code.
76     kClipShader,
77 
78     kCompose,
79 
80     // Fixed-function blend modes are used for the final blend with the dst buffer's color when the
81     // SkPaint is using a coefficient-based SkBlendMode. The actual coefficients are extracted into
82     // the SkBlendInfo associated with each pipeline, but a unique code snippet ID is assigned so
83     // that the pipeline keys remain distinct. They are ordered to match SkBlendMode such
84     // that (id - kFirstFixedFunctionBlendMode) == SkBlendMode).
85     //
86     // NOTE: Pipeline code generation depends on the fixed-function code IDs being contiguous and
87     // be defined last in the enum.
88     kFixedFunctionClearBlendMode,
89     kFixedFunctionSrcBlendMode,
90     kFixedFunctionDstBlendMode,
91     kFixedFunctionSrcOverBlendMode,
92     kFixedFunctionDstOverBlendMode,
93     kFixedFunctionSrcInBlendMode,
94     kFixedFunctionDstInBlendMode,
95     kFixedFunctionSrcOutBlendMode,
96     kFixedFunctionDstOutBlendMode,
97     kFixedFunctionSrcATopBlendMode,
98     kFixedFunctionDstATopBlendMode,
99     kFixedFunctionXorBlendMode,
100     kFixedFunctionPlusBlendMode,
101     kFixedFunctionModulateBlendMode,
102     kFixedFunctionScreenBlendMode,
103 
104     kFirstFixedFunctionBlendMode = kFixedFunctionClearBlendMode,
105     kLast = kFixedFunctionScreenBlendMode
106 };
107 static constexpr int kBuiltInCodeSnippetIDCount = static_cast<int>(BuiltInCodeSnippetID::kLast)+1;
108 static constexpr int kFixedFunctionBlendModeIDOffset =
109         static_cast<int>(BuiltInCodeSnippetID::kFirstFixedFunctionBlendMode);
110 
111 static_assert(BuiltInCodeSnippetID::kLast == BuiltInCodeSnippetID::kFixedFunctionScreenBlendMode);
112 
113 }  // namespace skgpu::graphite
114 
115 #endif // skgpu_graphite_BuiltInCodeSnippetID_DEFINED
116