• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 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_FactoryFunctionsPriv_DEFINED
9 #define skgpu_graphite_FactoryFunctionsPriv_DEFINED
10 
11 #include "src/base/SkEnumBitMask.h"
12 #include "src/gpu/graphite/FactoryFunctions.h"
13 
14 namespace skgpu::graphite {
15 
16 class PrecompileShader;
17 
18 enum class PrecompileImageShaderFlags {
19     kNone         = 0b00,
20     kExcludeAlpha = 0b01,
21     kExcludeCubic = 0b10
22 };
SK_MAKE_BITMASK_OPS(PrecompileImageShaderFlags)23 SK_MAKE_BITMASK_OPS(PrecompileImageShaderFlags)
24 
25 //--------------------------------------------------------------------------------------------------
26 namespace PrecompileShadersPriv {
27     sk_sp<PrecompileShader> Blur(sk_sp<PrecompileShader> wrapped);
28 
29     sk_sp<PrecompileShader> Displacement(sk_sp<PrecompileShader> displacement,
30                                          sk_sp<PrecompileShader> color);
31 
32     sk_sp<PrecompileShader> Lighting(sk_sp<PrecompileShader> wrapped);
33 
34     sk_sp<PrecompileShader> MatrixConvolution(sk_sp<PrecompileShader> wrapped);
35 
36     sk_sp<PrecompileShader> LinearMorphology(sk_sp<PrecompileShader> wrapped);
37 
38     sk_sp<PrecompileShader> SparseMorphology(sk_sp<PrecompileShader> wrapped);
39 
40     // TODO: This, technically, doesn't need to take an SkSpan since it is only called from
41     // PaintOptions::setClipShaders with a single PrecompileShader. Leaving it be for now in case
42     // the usage is revised.
43     sk_sp<PrecompileShader> CTM(SkSpan<const sk_sp<PrecompileShader>> wrapped);
44 
45     sk_sp<PrecompileShader> Image(SkEnumBitMask<PrecompileImageShaderFlags>);
46 
47     sk_sp<PrecompileShader> RawImage(SkEnumBitMask<PrecompileImageShaderFlags>);
48 
49     // This factory variant should be used when the existence or non-existence of the local matrix
50     // is known. If 'withLM' is true only the LMShader-wrapped shader will be created while, when
51     // 'withLM' is false, no LMShader will wrap the base shader.
52     sk_sp<PrecompileShader> Picture(bool withLM);
53 
54     // TODO: this factory function should go away (it is only used by the PrecompileShaders::Picture
55     // entry point now).
56     sk_sp<PrecompileShader> LocalMatrixBothVariants(SkSpan<const sk_sp<PrecompileShader>> wrapped);
57 
58 } // namespace PrecompileShadersPriv
59 
60 namespace PrecompileColorFiltersPriv {
61     // These three match those in src/core/SkColorFilterPriv
62     sk_sp<PrecompileColorFilter> Gaussian();
63 
64     sk_sp<PrecompileColorFilter> ColorSpaceXform();
65 
66     sk_sp<PrecompileColorFilter> WithWorkingFormat(
67             SkSpan<const sk_sp<PrecompileColorFilter>> childOptions);
68 
69 } // namespace PrecompileColorFiltersPriv
70 
71 } // namespace skgpu::graphite
72 
73 #endif // skgpu_graphite_FactoryFunctionsPriv_DEFINED
74