Flutter Engine
The Flutter Engine
FactoryFunctions.h
Go to the documentation of this file.
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_FactoryFunctions_DEFINED
9#define skgpu_graphite_FactoryFunctions_DEFINED
10
13#include "include/core/SkSpan.h"
15
16namespace skgpu::graphite {
17
18class PrecompileBase;
19class PrecompileBlender;
20class PrecompileColorFilter;
21class PrecompileImageFilter;
22class PrecompileMaskFilter;
23class PrecompileShader;
24
25// All of these factory functions will be moved elsewhere once the pre-compile API becomes public
26
27namespace PrecompileShaders {
28 // ??
30
31} // namespace PrecompileShaders
32
33// TODO: For all of the PrecompileImageFilter factories, should we have a CropRect parameter or
34// have clients explicitly create a crop PrecompileImageFilter?
35// Note: In order to make analysis more tractable we don't allow options for the internals of an
36// ImageFilter nor in the structure of the DAG.
37namespace PrecompileImageFilters {
38 // This is the Precompile correlate to SkImageFilters::Arithmetic
41
42 // This is the Precompile correlate to SkImageFilters::Blend(SkBlendMode, ...)
46
47 // This is the Precompile correlate to SkImageFilters::Blend(sk_sp<SkBlender>, ...)
51
52 // This is the Precompile correlate to the two SkImageFilters::Blur factories
54
55 // This is the Precompile correlate to SkImageFilters::ColorFilter.
58
59 // This is the Precompile correlate to SkImageFilters::DisplacementMap
61
62 // This is the Precompile correlate to all of SkImageFilters::
63 // DistantLitDiffuse, PointLitDiffuse, SpotLitDiffuse
64 // DistantLitSpecular, PointLitSpecular, SpotLitSpecular
66
67 // This is the Precompile correlate to SkImageFilters::MatrixConvolution
69
70 // This is the Precompile correlate to SkImageFilters::Erode and SkImageFilters::Dilate
72
73} // namespace PrecompileImageFilters
74
75//--------------------------------------------------------------------------------------------------
76// Initially this will go next to SkMaskFilter in include/core/SkMaskFilter.h but the
77// SkMaskFilter::MakeBlur factory should be split out or removed. This namespace will follow
78// where ever that factory goes.
79namespace PrecompileMaskFilters {
80 // TODO: change SkMaskFilter::MakeBlur to match this and SkImageFilters::Blur (skbug.com/13441)
82} // namespace PrecompileMaskFilters
83
84//--------------------------------------------------------------------------------------------------
85// Object that allows passing a SkPrecompileShader, SkPrecompileColorFilter or
86// SkPrecompileBlender as a child
87//
88// This will moved to be on SkRuntimeEffect
90public:
91 PrecompileChildPtr() = default;
95
96 // Asserts that the SkPrecompileBase is either null, or one of the legal derived types
98
99 std::optional<SkRuntimeEffect::ChildType> type() const;
100
101 PrecompileShader* shader() const;
103 PrecompileBlender* blender() const;
104 PrecompileBase* base() const { return fChild.get(); }
105
106private:
108};
109
111
112// TODO: the precompile RuntimeEffects are handling their child options different from the
113// rest of the precompile system!
114
115// These will move to be on SkRuntimeEffect to parallel makeShader, makeColorFilter and
116// makeBlender
119 SkSpan<const PrecompileChildOptions> childOptions = {});
120
123 SkSpan<const PrecompileChildOptions> childOptions = {});
124
127 SkSpan<const PrecompileChildOptions> childOptions = {});
128
129} // namespace skgpu::graphite
130
131#endif // skgpu_graphite_FactoryFunctions_DEFINED
#define SK_API
Definition: SkAPI.h:35
SkBlendMode
Definition: SkBlendMode.h:38
PrecompileShader * shader() const
PrecompileBlender * blender() const
std::optional< SkRuntimeEffect::ChildType > type() const
PrecompileColorFilter * colorFilter() const
SK_API sk_sp< PrecompileImageFilter > Blur(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > ColorFilter(sk_sp< PrecompileColorFilter > colorFilter, sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > MatrixConvolution(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > DisplacementMap(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > Arithmetic(sk_sp< PrecompileImageFilter > background, sk_sp< PrecompileImageFilter > foreground)
SK_API sk_sp< PrecompileImageFilter > Morphology(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > Lighting(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > Blend(SkBlendMode bm, sk_sp< PrecompileImageFilter > background, sk_sp< PrecompileImageFilter > foreground)
SK_API sk_sp< PrecompileMaskFilter > Blur()
SK_API sk_sp< PrecompileShader > YUVImage()
sk_sp< PrecompileBlender > MakePrecompileBlender(sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
sk_sp< PrecompileShader > MakePrecompileShader(sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
sk_sp< PrecompileColorFilter > MakePrecompileColorFilter(sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)