Flutter Engine
The Flutter Engine
Classes | Functions
SkShaders Namespace Reference

Classes

class  MatrixRec
 

Functions

SK_API sk_sp< SkShaderEmpty ()
 
SK_API sk_sp< SkShaderColor (SkColor)
 
SK_API sk_sp< SkShaderColor (const SkColor4f &, sk_sp< SkColorSpace >)
 
SK_API sk_sp< SkShaderBlend (SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
 
SK_API sk_sp< SkShaderBlend (sk_sp< SkBlender >, sk_sp< SkShader > dst, sk_sp< SkShader > src)
 
SK_API sk_sp< SkShaderCoordClamp (sk_sp< SkShader >, const SkRect &subset)
 
SK_API sk_sp< SkShaderImage (sk_sp< SkImage > image, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &options, const SkMatrix *localMatrix=nullptr)
 
SK_API sk_sp< SkShaderRawImage (sk_sp< SkImage > image, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &options, const SkMatrix *localMatrix=nullptr)
 
SK_API sk_sp< SkShaderMakeFractalNoise (SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize *tileSize=nullptr)
 
SK_API sk_sp< SkShaderMakeTurbulence (SkScalar baseFrequencyX, SkScalar baseFrequencyY, int numOctaves, SkScalar seed, const SkISize *tileSize=nullptr)
 

Function Documentation

◆ Blend() [1/2]

sk_sp< SkShader > SkShaders::Blend ( sk_sp< SkBlender blender,
sk_sp< SkShader dst,
sk_sp< SkShader src 
)

Definition at line 117 of file SkBlendShader.cpp.

119 {
120 using namespace SkKnownRuntimeEffects;
121
122 if (!src || !dst) {
123 return nullptr;
124 }
125 if (!blender) {
126 return SkShaders::Blend(SkBlendMode::kSrcOver, std::move(dst), std::move(src));
127 }
128 if (std::optional<SkBlendMode> mode = as_BB(blender)->asBlendMode()) {
129 return sk_make_sp<SkBlendShader>(mode.value(), std::move(dst), std::move(src));
130 }
131
132 // This isn't a built-in blend mode; we might as well use a runtime effect to evaluate it.
133 const SkRuntimeEffect* blendEffect = GetKnownRuntimeEffect(StableKey::kBlend);
134
135 SkRuntimeEffect::ChildPtr children[] = {std::move(src), std::move(dst), std::move(blender)};
136 return blendEffect->makeShader(/*uniforms=*/{}, children);
137}
@ kSrcOver
r = s + (1-sa)*d
SkBlenderBase * as_BB(SkBlender *blend)
Definition: SkBlenderBase.h:69
sk_sp< SkShader > makeShader(sk_sp< const SkData > uniforms, sk_sp< SkShader > children[], size_t childCount, const SkMatrix *localMatrix=nullptr) const
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228
dst
Definition: cp.py:12

◆ Blend() [2/2]

sk_sp< SkShader > SkShaders::Blend ( SkBlendMode  mode,
sk_sp< SkShader dst,
sk_sp< SkShader src 
)

Definition at line 100 of file SkBlendShader.cpp.

100 {
101 if (!src || !dst) {
102 return nullptr;
103 }
104 switch (mode) {
106 return Color(0);
108 return dst;
110 return src;
111 default:
112 break;
113 }
114 return sk_sp<SkShader>(new SkBlendShader(mode, std::move(dst), std::move(src)));
115}
@ kClear
r = 0
SK_API sk_sp< SkShader > Color(SkColor)

◆ Color() [1/2]

sk_sp< SkShader > SkShaders::Color ( const SkColor4f color,
sk_sp< SkColorSpace space 
)

Definition at line 105 of file SkColorShader.cpp.

105 {
106 if (!SkIsFinite(color.vec(), 4)) {
107 return nullptr;
108 }
109 return sk_make_sp<SkColor4Shader>(color, std::move(space));
110}
static bool SkIsFinite(T x, Pack... values)
DlColor color

◆ Color() [2/2]

sk_sp< SkShader > SkShaders::Color ( SkColor  color)

Definition at line 103 of file SkColorShader.cpp.

103{ return sk_make_sp<SkColorShader>(color); }

◆ CoordClamp()

sk_sp< SkShader > SkShaders::CoordClamp ( sk_sp< SkShader shader,
const SkRect subset 
)

Definition at line 59 of file SkCoordClampShader.cpp.

59 {
60 if (!shader) {
61 return nullptr;
62 }
63 if (!subset.isSorted()) {
64 return nullptr;
65 }
66 return sk_make_sp<SkCoordClampShader>(std::move(shader), subset);
67}
bool isSorted() const
Definition: SkRect.h:705

◆ Empty()

sk_sp< SkShader > SkShaders::Empty ( )

Definition at line 20 of file SkEmptyShader.cpp.

20{ return sk_make_sp<SkEmptyShader>(); }

◆ Image()

sk_sp< SkShader > SkShaders::Image ( sk_sp< SkImage image,
SkTileMode  tmx,
SkTileMode  tmy,
const SkSamplingOptions options,
const SkMatrix localMatrix = nullptr 
)

Definition at line 800 of file SkImageShader.cpp.

803 {
804 return SkImageShader::Make(std::move(image), tmx, tmy, options, localMatrix);
805}
const char * options
static sk_sp< SkShader > Make(sk_sp< SkImage >, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkTileMode tmy
SkTileMode tmx

◆ MakeFractalNoise()

sk_sp< SkShader > SkShaders::MakeFractalNoise ( SkScalar  baseFrequencyX,
SkScalar  baseFrequencyY,
int  numOctaves,
SkScalar  seed,
const SkISize tileSize = nullptr 
)

This will construct Perlin noise of the given type (Fractal Noise or Turbulence).

Both base frequencies (X and Y) have a usual range of (0..1) and must be non-negative.

The number of octaves provided should be fairly small, with a limit of 255 enforced. Each octave doubles the frequency, so 10 octaves would produce noise from baseFrequency * 1, * 2, * 4, ..., * 512, which quickly yields insignificantly small periods and resembles regular unstructured noise rather than Perlin noise.

If tileSize isn't NULL or an empty size, the tileSize parameter will be used to modify the frequencies so that the noise will be tileable for the given tile size. If tileSize is NULL or an empty size, the frequencies will be used as is without modification.

Definition at line 135 of file SkPerlinNoiseShaderImpl.cpp.

139 {
140 if (!valid_input(baseFrequencyX, baseFrequencyY, numOctaves, tileSize, seed)) {
141 return nullptr;
142 }
143
144 if (0 == numOctaves) {
145 // For kFractalNoise, w/o any octaves, the entire shader collapses to:
146 // [0,0,0,0] * 0.5 + 0.5
147 constexpr SkColor4f kTransparentGray = {0.5f, 0.5f, 0.5f, 0.5f};
148
149 return SkShaders::Color(kTransparentGray, /* colorSpace= */ nullptr);
150 }
151
153 baseFrequencyX,
154 baseFrequencyY,
155 numOctaves,
156 seed,
157 tileSize));
158}
static bool valid_input(SkScalar baseX, SkScalar baseY, int numOctaves, const SkISize *tileSize, SkScalar seed)

◆ MakeTurbulence()

sk_sp< SkShader > SkShaders::MakeTurbulence ( SkScalar  baseFrequencyX,
SkScalar  baseFrequencyY,
int  numOctaves,
SkScalar  seed,
const SkISize tileSize = nullptr 
)

Definition at line 160 of file SkPerlinNoiseShaderImpl.cpp.

164 {
165 if (!valid_input(baseFrequencyX, baseFrequencyY, numOctaves, tileSize, seed)) {
166 return nullptr;
167 }
168
169 if (0 == numOctaves) {
170 // For kTurbulence, w/o any octaves, the entire shader collapses to: [0,0,0,0]
171 return SkShaders::Color(SkColors::kTransparent, /* colorSpace= */ nullptr);
172 }
173
175 baseFrequencyX,
176 baseFrequencyY,
177 numOctaves,
178 seed,
179 tileSize));
180}
constexpr SkColor4f kTransparent
Definition: SkColor.h:434

◆ RawImage()

sk_sp< SkShader > SkShaders::RawImage ( sk_sp< SkImage image,
SkTileMode  tmx,
SkTileMode  tmy,
const SkSamplingOptions options,
const SkMatrix localMatrix = nullptr 
)

Definition at line 807 of file SkImageShader.cpp.

810 {
811 return SkImageShader::MakeRaw(std::move(image), tmx, tmy, options, localMatrix);
812}
static sk_sp< SkShader > MakeRaw(sk_sp< SkImage >, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix)