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_precompile_PrecompileShadersPriv_DEFINED 9 #define skgpu_graphite_precompile_PrecompileShadersPriv_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "src/base/SkEnumBitMask.h" 13 #include "src/gpu/graphite/precompile/PaintOptionsPriv.h" 14 15 namespace skgpu::graphite { 16 17 class PrecompileShader; 18 19 enum class PrecompileImageShaderFlags { 20 kNone = 0b00, 21 kExcludeAlpha = 0b01, 22 kExcludeCubic = 0b10 23 }; SK_MAKE_BITMASK_OPS(PrecompileImageShaderFlags)24SK_MAKE_BITMASK_OPS(PrecompileImageShaderFlags) 25 26 //-------------------------------------------------------------------------------------------------- 27 namespace PrecompileShadersPriv { 28 // -- The first 6 factories are used to implement ImageFilters 29 sk_sp<PrecompileShader> Blur(sk_sp<PrecompileShader> wrapped); 30 31 sk_sp<PrecompileShader> Displacement(sk_sp<PrecompileShader> displacement, 32 sk_sp<PrecompileShader> color); 33 34 sk_sp<PrecompileShader> Lighting(sk_sp<PrecompileShader> wrapped); 35 36 sk_sp<PrecompileShader> MatrixConvolution(sk_sp<PrecompileShader> wrapped); 37 38 sk_sp<PrecompileShader> LinearMorphology(sk_sp<PrecompileShader> wrapped); 39 40 sk_sp<PrecompileShader> SparseMorphology(sk_sp<PrecompileShader> wrapped); 41 42 // TODO: This, technically, doesn't need to take an SkSpan since it is only called from 43 // PaintOptions::setClipShaders with a single PrecompileShader. Leaving it be for now in case 44 // the usage is revised. 45 sk_sp<PrecompileShader> CTM(SkSpan<const sk_sp<PrecompileShader>> wrapped); 46 47 // The remaining factories are special cases used to reduce the combinatorics of the 48 // precompilation system. 49 sk_sp<PrecompileShader> Image(SkEnumBitMask<PrecompileImageShaderFlags>); 50 51 sk_sp<PrecompileShader> RawImage(SkEnumBitMask<PrecompileImageShaderFlags>); 52 53 // This factory variant should be used when the existence or non-existence of the local matrix 54 // is known. If 'withLM' is true only the LMShader-wrapped shader will be created while, when 55 // 'withLM' is false, no LMShader will wrap the base shader. 56 sk_sp<PrecompileShader> Picture(bool withLM); 57 58 // TODO: this factory function should go away (it is only used by the PrecompileShaders::Picture 59 // entry point now). 60 sk_sp<PrecompileShader> LocalMatrixBothVariants(SkSpan<const sk_sp<PrecompileShader>> wrapped); 61 62 } // namespace PrecompileShadersPriv 63 64 } // namespace skgpu::graphite 65 66 #endif // skgpu_graphite_precompile_PrecompileShadersPriv_DEFINED 67