Flutter Engine
The Flutter Engine
Classes | Public Types | Static Public Member Functions | List of all members
SkImageFilters Class Reference

#include <SkImageFilters.h>

Classes

struct  CropRect
 

Public Types

enum class  Dither : bool { kNo = false , kYes = true }
 

Static Public Member Functions

static sk_sp< SkImageFilterArithmetic (SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterBlend (SkBlendMode mode, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterBlend (sk_sp< SkBlender > blender, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterBlur (SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterBlur (SkScalar sigmaX, SkScalar sigmaY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterColorFilter (sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterCompose (sk_sp< SkImageFilter > outer, sk_sp< SkImageFilter > inner)
 
static sk_sp< SkImageFilterCrop (const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
 
static sk_sp< SkImageFilterCrop (const SkRect &rect, sk_sp< SkImageFilter > input)
 
static sk_sp< SkImageFilterDisplacementMap (SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkScalar scale, sk_sp< SkImageFilter > displacement, sk_sp< SkImageFilter > color, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterDropShadow (SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterDropShadowOnly (SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterEmpty ()
 
static sk_sp< SkImageFilterImage (sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
 
static sk_sp< SkImageFilterImage (sk_sp< SkImage > image, const SkSamplingOptions &sampling)
 
static sk_sp< SkImageFilterMagnifier (const SkRect &lensBounds, SkScalar zoomAmount, SkScalar inset, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterMatrixConvolution (const SkISize &kernelSize, const SkScalar kernel[], SkScalar gain, SkScalar bias, const SkIPoint &kernelOffset, SkTileMode tileMode, bool convolveAlpha, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterMatrixTransform (const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
 
static sk_sp< SkImageFilterMerge (sk_sp< SkImageFilter > *const filters, int count, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterMerge (sk_sp< SkImageFilter > first, sk_sp< SkImageFilter > second, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterOffset (SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterPicture (sk_sp< SkPicture > pic, const SkRect &targetRect)
 
static sk_sp< SkImageFilterPicture (sk_sp< SkPicture > pic)
 
static sk_sp< SkImageFilterRuntimeShader (const SkRuntimeShaderBuilder &builder, std::string_view childShaderName, sk_sp< SkImageFilter > input)
 
static sk_sp< SkImageFilterRuntimeShader (const SkRuntimeShaderBuilder &builder, SkScalar sampleRadius, std::string_view childShaderName, sk_sp< SkImageFilter > input)
 
static sk_sp< SkImageFilterRuntimeShader (const SkRuntimeShaderBuilder &builder, std::string_view childShaderNames[], const sk_sp< SkImageFilter > inputs[], int inputCount)
 
static sk_sp< SkImageFilterRuntimeShader (const SkRuntimeShaderBuilder &builder, SkScalar maxSampleRadius, std::string_view childShaderNames[], const sk_sp< SkImageFilter > inputs[], int inputCount)
 
static sk_sp< SkImageFilterShader (sk_sp< SkShader > shader, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterShader (sk_sp< SkShader > shader, Dither dither, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterTile (const SkRect &src, const SkRect &dst, sk_sp< SkImageFilter > input)
 
static sk_sp< SkImageFilterDilate (SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterErode (SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterDistantLitDiffuse (const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterPointLitDiffuse (const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterSpotLitDiffuse (const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterDistantLitSpecular (const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterPointLitSpecular (const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterSpotLitSpecular (const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 

Detailed Description

Definition at line 42 of file SkImageFilters.h.

Member Enumeration Documentation

◆ Dither

enum class SkImageFilters::Dither : bool
strong
Enumerator
kNo 
kYes 

Definition at line 438 of file SkImageFilters.h.

438 : bool {
439 kNo = false,
440 kYes = true
441 };
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.

Member Function Documentation

◆ Arithmetic()

sk_sp< SkImageFilter > SkImageFilters::Arithmetic ( SkScalar  k1,
SkScalar  k2,
SkScalar  k3,
SkScalar  k4,
bool  enforcePMColor,
sk_sp< SkImageFilter background,
sk_sp< SkImageFilter foreground,
const CropRect cropRect = {} 
)
static

Create a filter that implements a custom blend mode. Each output pixel is the result of combining the corresponding background and foreground pixels using the 4 coefficients: k1 * foreground * background + k2 * foreground + k3 * background + k4

Parameters
k1,k2,k3,k4The four coefficients used to combine the foreground and background.
enforcePMColorIf true, the RGB channels will be clamped to the calculated alpha.
backgroundThe background content, using the source bitmap when this is null.
foregroundThe foreground content, using the source bitmap when this is null.
cropRectOptional rectangle that crops the inputs and output.

Definition at line 151 of file SkBlendImageFilter.cpp.

158 {
159 auto blender = SkBlenders::Arithmetic(k1, k2, k3, k4, enforcePMColor);
160 if (!blender) {
161 // Arithmetic() returns null on an error, not to optimize src-over
162 return nullptr;
163 }
164 return make_blend(std::move(blender),
165 std::move(background),
166 std::move(foreground),
167 cropRect,
168 // Carry arithmetic coefficients and premul behavior into image filter for
169 // serialization and bounds analysis
170 SkV4{k1, k2, k3, k4},
171 enforcePMColor);
172}
static sk_sp< SkBlender > Arithmetic(float k1, float k2, float k3, float k4, bool enforcePremul)
Definition: SkBlenders.cpp:20
Definition: SkM44.h:98

◆ Blend() [1/2]

sk_sp< SkImageFilter > SkImageFilters::Blend ( sk_sp< SkBlender blender,
sk_sp< SkImageFilter background,
sk_sp< SkImageFilter foreground = nullptr,
const CropRect cropRect = {} 
)
static

This filter takes an SkBlendMode and uses it to composite the two filters together.

Parameters
blenderThe blender that defines the compositing operation
backgroundThe Dst pixels used in blending, if null the source bitmap is used.
foregroundThe Src pixels used in blending, if null the source bitmap is used. @cropRect Optional rectangle to crop input and output.

Definition at line 144 of file SkBlendImageFilter.cpp.

147 {
148 return make_blend(std::move(blender), std::move(background), std::move(foreground), cropRect);
149}

◆ Blend() [2/2]

sk_sp< SkImageFilter > SkImageFilters::Blend ( SkBlendMode  mode,
sk_sp< SkImageFilter background,
sk_sp< SkImageFilter foreground = nullptr,
const CropRect cropRect = {} 
)
static

This filter takes an SkBlendMode and uses it to composite the two filters together.

Parameters
modeThe blend mode that defines the compositing operation
backgroundThe Dst pixels used in blending, if null the source bitmap is used.
foregroundThe Src pixels used in blending, if null the source bitmap is used. @cropRect Optional rectangle to crop input and output.

Definition at line 134 of file SkBlendImageFilter.cpp.

137 {
138 return make_blend(SkBlender::Mode(mode),
139 std::move(background),
140 std::move(foreground),
141 cropRect);
142}
static sk_sp< SkBlender > Mode(SkBlendMode mode)
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

◆ Blur() [1/2]

static sk_sp< SkImageFilter > SkImageFilters::Blur ( SkScalar  sigmaX,
SkScalar  sigmaY,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
inlinestatic

Definition at line 126 of file SkImageFilters.h.

127 {}) {
128 return Blur(sigmaX, sigmaY, SkTileMode::kDecal, std::move(input), cropRect);
129 }
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})

◆ Blur() [2/2]

sk_sp< SkImageFilter > SkImageFilters::Blur ( SkScalar  sigmaX,
SkScalar  sigmaY,
SkTileMode  tileMode,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that blurs its input by the separate X and Y sigmas. The provided tile mode is used when the blur kernel goes outside the input image.

Parameters
sigmaXThe Gaussian sigma value for blurring along the X axis.
sigmaYThe Gaussian sigma value for blurring along the Y axis.
tileModeThe tile mode applied at edges . TODO (michaelludwig) - kMirror is not supported yet
inputThe input filter that is blurred, uses source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

Definition at line 107 of file SkBlurImageFilter.cpp.

109 {
110 if (!SkIsFinite(sigmaX, sigmaY) || sigmaX < 0.f || sigmaY < 0.f) {
111 // Non-finite or negative sigmas are error conditions. We allow 0 sigma for X and/or Y
112 // for 1D blurs; onFilterImage() will detect when no visible blurring would occur based on
113 // the Context mapping.
114 return nullptr;
115 }
116
117 // Temporarily allow tiling with no crop rect
118 if (tileMode != SkTileMode::kDecal && !cropRect) {
119 return sk_make_sp<SkBlurImageFilter>(SkSize{sigmaX, sigmaY}, tileMode, std::move(input));
120 }
121
122 // The 'tileMode' behavior is not well-defined if there is no crop. We only apply it if
123 // there is a provided 'cropRect'.
124 sk_sp<SkImageFilter> filter = std::move(input);
125 if (tileMode != SkTileMode::kDecal && cropRect) {
126 // Historically the input image was restricted to the cropRect when tiling was not
127 // kDecal, so that the kernel evaluated the tiled edge conditions, while a kDecal crop
128 // only affected the output.
129 filter = SkImageFilters::Crop(*cropRect, tileMode, std::move(filter));
130 }
131
132 filter = sk_make_sp<SkBlurImageFilter>(SkSize{sigmaX, sigmaY}, std::move(filter));
133 if (cropRect) {
134 // But regardless of the tileMode, the output is always decal cropped
135 filter = SkImageFilters::Crop(*cropRect, SkTileMode::kDecal, std::move(filter));
136 }
137 return filter;
138}
static bool SkIsFinite(T x, Pack... values)
static sk_sp< SkImageFilter > Crop(const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
Definition: SkSize.h:52

◆ ColorFilter()

sk_sp< SkImageFilter > SkImageFilters::ColorFilter ( sk_sp< SkColorFilter cf,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that applies the color filter to the input filter results.

Parameters
cfThe color filter that transforms the input image.
inputThe input filter, or uses the source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

Definition at line 72 of file SkColorFilterImageFilter.cpp.

74 {
75 if (cf) {
76 SkColorFilter* inputCF;
77 // This is an optimization, as it collapses the hierarchy by just combining the two
78 // colorfilters into a single one, which the new imagefilter will wrap.
79 // NOTE: FilterResults are capable of composing non-adjacent CF nodes together. We could
80 // remove this optimization at construction time, but may as well do the work just once.
81 if (input && input->isColorFilterNode(&inputCF)) {
82 cf = cf->makeComposed(sk_sp<SkColorFilter>(inputCF));
83 input = sk_ref_sp(input->getInput(0));
84 }
85 }
86
87 sk_sp<SkImageFilter> filter = std::move(input);
88 if (cf) {
89 filter = sk_sp<SkImageFilter>(
90 new SkColorFilterImageFilter(std::move(cf), std::move(filter)));
91 }
92 if (cropRect) {
93 filter = SkImageFilters::Crop(*cropRect, std::move(filter));
94 }
95 return filter;
96}
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
sk_sp< SkColorFilter > makeComposed(sk_sp< SkColorFilter > inner) const
bool isColorFilterNode(SkColorFilter **filterPtr) const
const SkImageFilter * getInput(int i) const

◆ Compose()

sk_sp< SkImageFilter > SkImageFilters::Compose ( sk_sp< SkImageFilter outer,
sk_sp< SkImageFilter inner 
)
static

Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are treated as the source bitmap passed to 'outer', i.e. result = outer(inner(source)).

Parameters
outerThe outer filter that evaluates the results of inner.
innerThe inner filter that produces the input to outer.

Definition at line 66 of file SkComposeImageFilter.cpp.

67 {
68 if (!outer) {
69 return inner;
70 }
71 if (!inner) {
72 return outer;
73 }
74 sk_sp<SkImageFilter> inputs[2] = { std::move(outer), std::move(inner) };
75 return sk_sp<SkImageFilter>(new SkComposeImageFilter(inputs));
76}

◆ Crop() [1/2]

static sk_sp< SkImageFilter > SkImageFilters::Crop ( const SkRect rect,
sk_sp< SkImageFilter input 
)
inlinestatic

Definition at line 165 of file SkImageFilters.h.

165 {
166 return Crop(rect, SkTileMode::kDecal, std::move(input));
167 }
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ Crop() [2/2]

sk_sp< SkImageFilter > SkImageFilters::Crop ( const SkRect rect,
SkTileMode  tileMode,
sk_sp< SkImageFilter input 
)
static

Create a filter that applies a crop to the result of the 'input' filter. Pixels within the crop rectangle are unmodified from what 'input' produced. Pixels outside of crop match the provided SkTileMode (defaulting to kDecal).

NOTE: The optional CropRect argument for many of the factories is equivalent to creating the filter without a CropRect and then wrapping it in ::Crop(rect, kDecal). Explicitly adding Crop filters lets you control their tiling and use different geometry for the input and the output of another filter.

Parameters
rectThe cropping geometry
tileModeThe tilemode applied to pixels outside of 'crop'
inputThe input filter that is cropped, uses source image if this is null

Definition at line 99 of file SkCropImageFilter.cpp.

101 {
102 if (!SkIsValidRect(rect)) {
103 return nullptr;
104 }
105 return sk_sp<SkImageFilter>(new SkCropImageFilter(rect, tileMode, std::move(input)));
106}
static bool SkIsValidRect(const SkRect &rect)

◆ Dilate()

sk_sp< SkImageFilter > SkImageFilters::Dilate ( SkScalar  radiusX,
SkScalar  radiusY,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that dilates each input pixel's channel values to the max value within the given radii along the x and y axes.

Parameters
radiusXThe distance to dilate along the x axis to either side of each pixel.
radiusYThe distance to dilate along the y axis to either side of each pixel.
inputThe image filter that is dilated, using source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

Definition at line 227 of file SkMorphologyImageFilter.cpp.

229 {
230 return make_morphology(MorphType::kDilate, {radiusX, radiusY}, std::move(input), cropRect);
231}

◆ DisplacementMap()

sk_sp< SkImageFilter > SkImageFilters::DisplacementMap ( SkColorChannel  xChannelSelector,
SkColorChannel  yChannelSelector,
SkScalar  scale,
sk_sp< SkImageFilter displacement,
sk_sp< SkImageFilter color,
const CropRect cropRect = {} 
)
static

Create a filter that moves each pixel in its color input based on an (x,y) vector encoded in its displacement input filter. Two color components of the displacement image are mapped into a vector as scale * (color[xChannel], color[yChannel]), where the channel selectors are one of R, G, B, or A.

Parameters
xChannelSelectorRGBA channel that encodes the x displacement per pixel.
yChannelSelectorRGBA channel that encodes the y displacement per pixel.
scaleScale applied to displacement extracted from image.
displacementThe filter defining the displacement image, or null to use source.
colorThe filter providing the color pixels to be displaced. If null, it will use the source.
cropRectOptional rectangle that crops the color input and output.

Definition at line 144 of file SkDisplacementMapImageFilter.cpp.

146 {
147 if (!channel_selector_type_is_valid(xChannelSelector) ||
148 !channel_selector_type_is_valid(yChannelSelector)) {
149 return nullptr;
150 }
151
152 sk_sp<SkImageFilter> inputs[2] = { std::move(displacement), std::move(color) };
153 sk_sp<SkImageFilter> filter(new SkDisplacementMapImageFilter(xChannelSelector, yChannelSelector,
154 scale, inputs));
155 if (cropRect) {
156 filter = SkImageFilters::Crop(*cropRect, std::move(filter));
157 }
158 return filter;
159}
DlColor color
const Scalar scale

◆ DistantLitDiffuse()

sk_sp< SkImageFilter > SkImageFilters::DistantLitDiffuse ( const SkPoint3 direction,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  kd,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the diffuse illumination from a distant light source, interpreting the alpha channel of the input as the height profile of the surface (to approximate normal vectors).

Parameters
directionThe direction to the distance light.
lightColorThe color of the diffuse light source.
surfaceScaleScale factor to transform from alpha values to physical height.
kdDiffuse reflectance coefficient.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

Definition at line 314 of file SkLightingImageFilter.cpp.

316 {
317 return make_lighting(Light::Distant(lightColor, direction),
318 Material::Diffuse(kd, surfaceScale),
319 std::move(input), cropRect);
320}

◆ DistantLitSpecular()

sk_sp< SkImageFilter > SkImageFilters::DistantLitSpecular ( const SkPoint3 direction,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  ks,
SkScalar  shininess,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the specular illumination from a distant light source, interpreting the alpha channel of the input as the height profile of the surface (to approximate normal vectors).

Parameters
directionThe direction to the distance light.
lightColorThe color of the specular light source.
surfaceScaleScale factor to transform from alpha values to physical height.
ksSpecular reflectance coefficient.
shininessThe specular exponent determining how shiny the surface is.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

Definition at line 341 of file SkLightingImageFilter.cpp.

343 {
344 return make_lighting(Light::Distant(lightColor, direction),
345 Material::Specular(ks, shininess, surfaceScale),
346 std::move(input), cropRect);
347}

◆ DropShadow()

sk_sp< SkImageFilter > SkImageFilters::DropShadow ( SkScalar  dx,
SkScalar  dy,
SkScalar  sigmaX,
SkScalar  sigmaY,
SkColor  color,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that draws a drop shadow under the input content. This filter produces an image that includes the inputs' content.

Parameters
dxThe X offset of the shadow.
dyThe Y offset of the shadow.
sigmaXThe blur radius for the shadow, along the X axis.
sigmaYThe blur radius for the shadow, along the Y axis.
colorThe color of the drop shadow.
inputThe input filter, or will use the source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

Definition at line 97 of file SkDropShadowImageFilter.cpp.

99 {
100 return make_drop_shadow_graph({dx, dy}, {sigmaX, sigmaY}, color, /*shadowOnly=*/false,
101 std::move(input), cropRect);
102}
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208

◆ DropShadowOnly()

sk_sp< SkImageFilter > SkImageFilters::DropShadowOnly ( SkScalar  dx,
SkScalar  dy,
SkScalar  sigmaX,
SkScalar  sigmaY,
SkColor  color,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow, except that the resulting image does not include the input content. This allows the shadow and input to be composed by a filter DAG in a more flexible manner.

Parameters
dxThe X offset of the shadow.
dyThe Y offset of the shadow.
sigmaXThe blur radius for the shadow, along the X axis.
sigmaYThe blur radius for the shadow, along the Y axis.
colorThe color of the drop shadow.
inputThe input filter, or will use the source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

Definition at line 104 of file SkDropShadowImageFilter.cpp.

106 {
107 return make_drop_shadow_graph({dx, dy}, {sigmaX, sigmaY}, color, /*shadowOnly=*/true,
108 std::move(input), cropRect);
109}

◆ Empty()

sk_sp< SkImageFilter > SkImageFilters::Empty ( )
static

Create a filter that always produces transparent black.

Definition at line 110 of file SkCropImageFilter.cpp.

110 {
112}
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595

◆ Erode()

sk_sp< SkImageFilter > SkImageFilters::Erode ( SkScalar  radiusX,
SkScalar  radiusY,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that erodes each input pixel's channel values to the minimum channel value within the given radii along the x and y axes.

Parameters
radiusXThe distance to erode along the x axis to either side of each pixel.
radiusYThe distance to erode along the y axis to either side of each pixel.
inputThe image filter that is eroded, using source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

Definition at line 233 of file SkMorphologyImageFilter.cpp.

235 {
236 return make_morphology(MorphType::kErode, {radiusX, radiusY}, std::move(input), cropRect);
237}

◆ Image() [1/2]

sk_sp< SkImageFilter > SkImageFilters::Image ( sk_sp< SkImage image,
const SkRect srcRect,
const SkRect dstRect,
const SkSamplingOptions sampling 
)
static

Create a filter that draws the 'srcRect' portion of image into 'dstRect' using the given filter quality. Similar to SkCanvas::drawImageRect. The returned image filter evaluates to transparent black if 'image' is null.

Parameters
imageThe image that is output by the filter, subset by 'srcRect'.
srcRectThe source pixels sampled into 'dstRect'
dstRectThe local rectangle to draw the image into.
samplingThe sampling to use when drawing the image.

Definition at line 77 of file SkImageImageFilter.cpp.

80 {
81 if (srcRect.isEmpty() || dstRect.isEmpty() || !image) {
82 // There is no content to draw, so the filter should produce transparent black
83 return SkImageFilters::Empty();
84 } else {
85 SkRect imageBounds = SkRect::Make(image->dimensions());
86 if (imageBounds.contains(srcRect)) {
87 // No change to srcRect and dstRect needed
88 return sk_sp<SkImageFilter>(new SkImageImageFilter(
89 std::move(image), srcRect, dstRect, sampling));
90 } else {
91 SkMatrix srcToDst = SkMatrix::RectToRect(srcRect, dstRect);
92 if (!imageBounds.intersect(srcRect)) {
93 // No overlap, so draw empty
94 return SkImageFilters::Empty();
95 }
96
97 // Adjust dstRect to match the updated src (which is stored in imageBounds)
98 SkRect mappedBounds = srcToDst.mapRect(imageBounds);
99 if (mappedBounds.isEmpty()) {
100 return SkImageFilters::Empty();
101 }
102 return sk_sp<SkImageFilter>(new SkImageImageFilter(
103 std::move(image), imageBounds, mappedBounds, sampling));
104 }
105 }
106}
static sk_sp< SkImageFilter > Empty()
SkISize dimensions() const
Definition: SkImage.h:297
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition: SkMatrix.h:157
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkMatrix.cpp:1141
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkSamplingOptions sampling
Definition: SkRecords.h:337
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
bool intersect(const SkRect &r)
Definition: SkRect.cpp:114
bool contains(SkScalar x, SkScalar y) const
Definition: extension.cpp:19
bool isEmpty() const
Definition: SkRect.h:693

◆ Image() [2/2]

static sk_sp< SkImageFilter > SkImageFilters::Image ( sk_sp< SkImage image,
const SkSamplingOptions sampling 
)
inlinestatic

Create a filter that draws the image using the given sampling. Similar to SkCanvas::drawImage. The returned image filter evaluates to transparent black if 'image' is null.

Parameters
imageThe image that is output by the filter.
samplingThe sampling to use when drawing the image.

Definition at line 246 of file SkImageFilters.h.

246 {
247 if (image) {
249 return Image(std::move(image), r, r, sampling);
250 } else {
251 return nullptr;
252 }
253 }
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
SkIRect bounds() const
Definition: SkImage.h:303

◆ Magnifier()

sk_sp< SkImageFilter > SkImageFilters::Magnifier ( const SkRect lensBounds,
SkScalar  zoomAmount,
SkScalar  inset,
const SkSamplingOptions sampling,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that fills 'lensBounds' with a magnification of the input.

Parameters
lensBoundsThe outer bounds of the magnifier effect
zoomAmountThe amount of magnification applied to the input image
insetThe size or width of the fish-eye distortion around the magnified content
samplingThe SkSamplingOptions applied to the input image when magnified
inputThe input filter that is magnified; if null the source bitmap is used
cropRectOptional rectangle that crops the input and output.

Definition at line 82 of file SkMagnifierImageFilter.cpp.

87 {
88 if (lensBounds.isEmpty() || !lensBounds.isFinite() ||
89 zoomAmount <= 0.f || inset < 0.f ||
90 !SkIsFinite(zoomAmount, inset)) {
91 return nullptr; // invalid
92 }
93 // The magnifier automatically restricts its output based on the size of the image it receives
94 // as input, so 'cropRect' only applies to its input.
95 if (cropRect) {
96 input = SkImageFilters::Crop(*cropRect, std::move(input));
97 }
98
99 if (zoomAmount > 1.f) {
100 return sk_sp<SkImageFilter>(new SkMagnifierImageFilter(lensBounds, zoomAmount, inset,
101 sampling, std::move(input)));
102 } else {
103 // Zooming with a value less than 1 is technically a downscaling, which "works" but the
104 // non-linear distortion behaves unintuitively. At zoomAmount = 1, this filter is an
105 // expensive identity function so treat zoomAmount <= 1 as a no-op.
106 return input;
107 }
108}
static SkRect inset(const SkRect &r)
bool isFinite() const
Definition: SkRect.h:711

◆ MatrixConvolution()

sk_sp< SkImageFilter > SkImageFilters::MatrixConvolution ( const SkISize kernelSize,
const SkScalar  kernel[],
SkScalar  gain,
SkScalar  bias,
const SkIPoint kernelOffset,
SkTileMode  tileMode,
bool  convolveAlpha,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that applies an NxM image processing kernel to the input image. This can be used to produce effects such as sharpening, blurring, edge detection, etc.

Parameters
kernelSizeThe kernel size in pixels, in each dimension (N by M).
kernelThe image processing kernel. Must contain N * M elements, in row order.
gainA scale factor applied to each pixel after convolution. This can be used to normalize the kernel, if it does not already sum to 1.
biasA bias factor added to each pixel after convolution.
kernelOffsetAn offset applied to each pixel coordinate before convolution. This can be used to center the kernel over the image (e.g., a 3x3 kernel should have an offset of {1, 1}).
tileModeHow accesses outside the image are treated. TODO (michaelludwig) - kMirror is not supported yet
convolveAlphaIf true, all channels are convolved. If false, only the RGB channels are convolved, and alpha is copied from the source image.
inputThe input image filter, if null the source bitmap is used instead.
cropRectOptional rectangle to which the output processing will be limited.

Definition at line 228 of file SkMatrixConvolutionImageFilter.cpp.

236 {
237 if (kernelSize.width() < 1 || kernelSize.height() < 1) {
238 return nullptr;
239 }
240 if (SkSafeMath::Mul(kernelSize.width(), kernelSize.height()) > kLargeKernelSize) {
241 return nullptr;
242 }
243 if (!kernel) {
244 return nullptr;
245 }
246 if ((kernelOffset.fX < 0) || (kernelOffset.fX >= kernelSize.fWidth) ||
247 (kernelOffset.fY < 0) || (kernelOffset.fY >= kernelSize.fHeight)) {
248 return nullptr;
249 }
250
251 // The 'tileMode' behavior is not well-defined if there is no crop, so we only apply it if
252 // there is a provided 'cropRect'.
253 sk_sp<SkImageFilter> filter = std::move(input);
254 if (cropRect && tileMode != SkTileMode::kDecal) {
255 // Historically the input image was restricted to the cropRect when tiling was not kDecal
256 // so that the kernel evaluated the tiled edge conditions, while a kDecal crop only affected
257 // the output.
258 filter = SkImageFilters::Crop(*cropRect, tileMode, std::move(filter));
259 }
260 filter = sk_sp<SkImageFilter>(new SkMatrixConvolutionImageFilter(
261 kernelSize, kernel, gain, bias, kernelOffset, convolveAlpha, &filter));
262 if (cropRect) {
263 // But regardless of the tileMode, the output is decal cropped.
264 filter = SkImageFilters::Crop(*cropRect, SkTileMode::kDecal, std::move(filter));
265 }
266 return filter;
267}
static size_t Mul(size_t x, size_t y)
Definition: SkSafeMath.cpp:16
int32_t fX
x-axis value
Definition: SkPoint_impl.h:29
int32_t fY
y-axis value
Definition: SkPoint_impl.h:30
int32_t fHeight
Definition: SkSize.h:18
int32_t fWidth
Definition: SkSize.h:17
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37

◆ MatrixTransform()

sk_sp< SkImageFilter > SkImageFilters::MatrixTransform ( const SkMatrix matrix,
const SkSamplingOptions sampling,
sk_sp< SkImageFilter input 
)
static

Create a filter that transforms the input image by 'matrix'. This matrix transforms the local space, which means it effectively happens prior to any transformation coming from the SkCanvas initiating the filtering.

Parameters
matrixThe matrix to apply to the original content.
samplingHow the image will be sampled when it is transformed
inputThe image filter to transform, or null to use the source image.

Definition at line 77 of file SkMatrixTransformImageFilter.cpp.

79 {
80 return sk_sp<SkImageFilter>(new SkMatrixTransformImageFilter(transform,
82 std::move(input)));
83}
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47

◆ Merge() [1/2]

sk_sp< SkImageFilter > SkImageFilters::Merge ( sk_sp< SkImageFilter > *const  filters,
int  count,
const CropRect cropRect = {} 
)
static

Create a filter that merges the 'count' filters together by drawing their results in order with src-over blending.

Parameters
filtersThe input filter array to merge, which must have 'count' elements. Any null filter pointers will use the source bitmap instead.
countThe number of input filters to be merged.
cropRectOptional rectangle that crops all input filters and the output.

Definition at line 55 of file SkMergeImageFilter.cpp.

56 {
57 if (count <= 0 || !filters) {
58 return SkImageFilters::Empty();
59 }
60
61 sk_sp<SkImageFilter> filter{new SkMergeImageFilter(filters, count)};
62 if (cropRect) {
63 filter = SkImageFilters::Crop(*cropRect, std::move(filter));
64 }
65 return filter;
66}
int count
Definition: FontMgrTest.cpp:50

◆ Merge() [2/2]

static sk_sp< SkImageFilter > SkImageFilters::Merge ( sk_sp< SkImageFilter first,
sk_sp< SkImageFilter second,
const CropRect cropRect = {} 
)
inlinestatic

Create a filter that merges the results of the two filters together with src-over blending.

Parameters
firstThe first input filter, or the source bitmap if this is null.
secondThe second input filter, or the source bitmap if this null.
cropRectOptional rectangle that crops the inputs and output.

Definition at line 325 of file SkImageFilters.h.

326 {}) {
327 sk_sp<SkImageFilter> array[] = { std::move(first), std::move(second) };
328 return Merge(array, 2, cropRect);
329 }
static sk_sp< SkImageFilter > Merge(sk_sp< SkImageFilter > *const filters, int count, const CropRect &cropRect={})

◆ Offset()

sk_sp< SkImageFilter > SkImageFilters::Offset ( SkScalar  dx,
SkScalar  dy,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that offsets the input filter by the given vector.

Parameters
dxThe x offset in local space that the image is shifted.
dyThe y offset in local space that the image is shifted.
inputThe input that will be moved, if null the source bitmap is used instead.
cropRectOptional rectangle to crop the input and output.

Definition at line 85 of file SkMatrixTransformImageFilter.cpp.

87 {
88 // The legacy ::Offset() implementation rounded its offset vector to layer-space pixels, which
89 // is roughly equivalent to using nearest-neighbor sampling with the translation matrix.
93 std::move(input));
94 // The legacy 'cropRect' applies only to the output of the offset filter.
95 if (cropRect) {
96 offset = SkImageFilters::Crop(*cropRect, std::move(offset));
97 }
98 return offset;
99}
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
SeparatedVector2 offset

◆ Picture() [1/2]

static sk_sp< SkImageFilter > SkImageFilters::Picture ( sk_sp< SkPicture pic)
inlinestatic

Definition at line 352 of file SkImageFilters.h.

352 {
353 SkRect target = pic ? pic->cullRect() : SkRect::MakeEmpty();
354 return Picture(std::move(pic), target);
355 }
static sk_sp< SkImageFilter > Picture(sk_sp< SkPicture > pic, const SkRect &targetRect)
virtual SkRect cullRect() const =0
uint32_t * target

◆ Picture() [2/2]

sk_sp< SkImageFilter > SkImageFilters::Picture ( sk_sp< SkPicture pic,
const SkRect targetRect 
)
static

Create a filter that produces the SkPicture as its output, clipped to both 'targetRect' and the picture's internal cull rect.

If 'pic' is null, the returned image filter produces transparent black.

Parameters
picThe picture that is drawn for the filter output.
targetRectThe drawing region for the picture.

Definition at line 66 of file SkPictureImageFilter.cpp.

66 {
67 if (pic) {
68 SkRect cullRect = pic->cullRect();
69 if (cullRect.intersect(targetRect)) {
70 return sk_sp<SkImageFilter>(new SkPictureImageFilter(std::move(pic), cullRect));
71 }
72 }
73 return SkImageFilters::Empty();
74}

◆ PointLitDiffuse()

sk_sp< SkImageFilter > SkImageFilters::PointLitDiffuse ( const SkPoint3 location,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  kd,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the diffuse illumination from a point light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors).

Parameters
locationThe location of the point light.
lightColorThe color of the diffuse light source.
surfaceScaleScale factor to transform from alpha values to physical height.
kdDiffuse reflectance coefficient.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

Definition at line 322 of file SkLightingImageFilter.cpp.

324 {
325 return make_lighting(Light::Point(lightColor, location),
326 Material::Diffuse(kd, surfaceScale),
327 std::move(input), cropRect);
328}
TPoint< Scalar > Point
Definition: point.h:322

◆ PointLitSpecular()

sk_sp< SkImageFilter > SkImageFilters::PointLitSpecular ( const SkPoint3 location,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  ks,
SkScalar  shininess,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the specular illumination from a point light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors).

Parameters
locationThe location of the point light.
lightColorThe color of the specular light source.
surfaceScaleScale factor to transform from alpha values to physical height.
ksSpecular reflectance coefficient.
shininessThe specular exponent determining how shiny the surface is.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

Definition at line 349 of file SkLightingImageFilter.cpp.

351 {
352 return make_lighting(Light::Point(lightColor, location),
353 Material::Specular(ks, shininess, surfaceScale),
354 std::move(input), cropRect);
355}

◆ RuntimeShader() [1/4]

sk_sp< SkImageFilter > SkImageFilters::RuntimeShader ( const SkRuntimeShaderBuilder builder,
SkScalar  maxSampleRadius,
std::string_view  childShaderNames[],
const sk_sp< SkImageFilter inputs[],
int  inputCount 
)
static

As above, but 'maxSampleRadius' defines the sampling limit on coordinates provided to all child shaders. Like the single-child variant with a sample radius, this can be used to inform Skia that the runtime shader guarantees that all dynamic children (defined in childShaderNames) will be evaluated with coordinates at most 'maxSampleRadius' away from the coordinate provided to the runtime shader itself.

This requires a GPU backend or SkSL to be compiled in.

Definition at line 116 of file SkRuntimeImageFilter.cpp.

120 {
121 if (maxSampleRadius < 0.f) {
122 return nullptr; // invalid sample radius
123 }
124
125 auto child_is_shader = [](const SkRuntimeEffect::Child* child) {
126 return child && child->type == SkRuntimeEffect::ChildType::kShader;
127 };
128
129 for (int i = 0; i < inputCount; i++) {
130 std::string_view name = childShaderNames[i];
131 // All names must be non-empty, and present as a child shader in the effect:
132 if (name.empty() || !child_is_shader(builder.effect()->findChild(name))) {
133 return nullptr;
134 }
135
136 // We don't allow duplicates, either:
137 for (int j = 0; j < i; j++) {
138 if (name == childShaderNames[j]) {
139 return nullptr;
140 }
141 }
142 }
143
144 return sk_sp<SkImageFilter>(new SkRuntimeImageFilter(builder, maxSampleRadius, childShaderNames,
145 inputs, inputCount));
146}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ RuntimeShader() [2/4]

sk_sp< SkImageFilter > SkImageFilters::RuntimeShader ( const SkRuntimeShaderBuilder builder,
SkScalar  sampleRadius,
std::string_view  childShaderName,
sk_sp< SkImageFilter input 
)
static

As above, but 'sampleRadius' defines the sampling radius of 'childShaderName' relative to the runtime shader produced by 'builder'. If greater than 0, the coordinate passed to childShader.eval() will be up to 'sampleRadius' away (maximum absolute offset in 'x' or 'y') from the coordinate passed into the runtime shader.

This allows Skia to provide sampleable values for the image filter without worrying about boundary conditions.

This requires a GPU backend or SkSL to be compiled in.

Definition at line 99 of file SkRuntimeImageFilter.cpp.

102 {
103 // If no childShaderName is provided, check to see if we can implicitly assign it to the only
104 // child in the effect.
105 if (childShaderName.empty()) {
106 auto children = builder.effect()->children();
107 if (children.size() != 1) {
108 return nullptr;
109 }
110 childShaderName = children.front().name;
111 }
112
113 return SkImageFilters::RuntimeShader(builder, sampleRadius, &childShaderName, &input, 1);
114}
static sk_sp< SkImageFilter > RuntimeShader(const SkRuntimeShaderBuilder &builder, std::string_view childShaderName, sk_sp< SkImageFilter > input)

◆ RuntimeShader() [3/4]

static sk_sp< SkImageFilter > SkImageFilters::RuntimeShader ( const SkRuntimeShaderBuilder builder,
std::string_view  childShaderName,
sk_sp< SkImageFilter input 
)
inlinestatic

Create a filter that fills the output with the per-pixel evaluation of the SkShader produced by the SkRuntimeShaderBuilder. The shader is defined in the image filter's local coordinate system, so it will automatically be affected by SkCanvas' transform.

This variant assumes that the runtime shader samples 'childShaderName' with the same input coordinate passed to to shader.

This requires a GPU backend or SkSL to be compiled in.

Parameters
builderThe builder used to produce the runtime shader, that will in turn fill the result image
childShaderNameThe name of the child shader defined in the builder that will be bound to the input param (or the source image if the input param is null). If empty, the builder can have exactly one child shader, which automatically binds the input param.
inputThe image filter that will be provided as input to the runtime shader. If null the implicit source image is used instead

Definition at line 376 of file SkImageFilters.h.

378 {
379 return RuntimeShader(builder, /*sampleRadius=*/0.f, childShaderName, std::move(input));
380 }

◆ RuntimeShader() [4/4]

static sk_sp< SkImageFilter > SkImageFilters::RuntimeShader ( const SkRuntimeShaderBuilder builder,
std::string_view  childShaderNames[],
const sk_sp< SkImageFilter inputs[],
int  inputCount 
)
inlinestatic

Create a filter that fills the output with the per-pixel evaluation of the SkShader produced by the SkRuntimeShaderBuilder. The shader is defined in the image filter's local coordinate system, so it will automatically be affected by SkCanvas' transform.

This requires a GPU backend or SkSL to be compiled in.

Parameters
builderThe builder used to produce the runtime shader, that will in turn fill the result image
childShaderNamesThe names of the child shaders defined in the builder that will be bound to the input params (or the source image if the input param is null). If any name is null, or appears more than once, factory fails and returns nullptr.
inputsThe image filters that will be provided as input to the runtime shader. If any are null, the implicit source image is used instead.
inputCountHow many entries are present in 'childShaderNames' and 'inputs'.

Definition at line 415 of file SkImageFilters.h.

418 {
419 return RuntimeShader(builder, /*maxSampleRadius=*/0.f, childShaderNames,
420 inputs, inputCount);
421 }

◆ Shader() [1/2]

static sk_sp< SkImageFilter > SkImageFilters::Shader ( sk_sp< SkShader shader,
const CropRect cropRect = {} 
)
inlinestatic

Create a filter that fills the output with the per-pixel evaluation of the SkShader. The shader is defined in the image filter's local coordinate system, so will automatically be affected by SkCanvas' transform.

Like Image() and Picture(), this is a leaf filter that can be used to introduce inputs to a complex filter graph, but should generally be combined with a filter that as at least one null input to use the implicit source image.

Returns an image filter that evaluates to transparent black if 'shader' is null.

Parameters
shaderThe shader that fills the result image

Definition at line 456 of file SkImageFilters.h.

456 {}) {
457 return Shader(std::move(shader), Dither::kNo, cropRect);
458 }
static sk_sp< SkImageFilter > Shader(sk_sp< SkShader > shader, const CropRect &cropRect={})

◆ Shader() [2/2]

sk_sp< SkImageFilter > SkImageFilters::Shader ( sk_sp< SkShader shader,
Dither  dither,
const CropRect cropRect = {} 
)
static

Definition at line 70 of file SkShaderImageFilter.cpp.

72 {
73 if (!shader) {
74 return SkImageFilters::Empty();
75 }
76
77 sk_sp<SkImageFilter> filter{new SkShaderImageFilter(std::move(shader), dither)};
78 if (cropRect) {
79 filter = SkImageFilters::Crop(*cropRect, std::move(filter));
80 }
81 return filter;
82}

◆ SpotLitDiffuse()

sk_sp< SkImageFilter > SkImageFilters::SpotLitDiffuse ( const SkPoint3 location,
const SkPoint3 target,
SkScalar  falloffExponent,
SkScalar  cutoffAngle,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  kd,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the diffuse illumination from a spot light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors). The spot light is restricted to be within 'cutoffAngle' of the vector between the location and target.

Parameters
locationThe location of the spot light.
targetThe location that the spot light is point towards
falloffExponentExponential falloff parameter for illumination outside of cutoffAngle
cutoffAngleMaximum angle from lighting direction that receives full light
lightColorThe color of the diffuse light source.
surfaceScaleScale factor to transform from alpha values to physical height.
kdDiffuse reflectance coefficient.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

Definition at line 330 of file SkLightingImageFilter.cpp.

333 {
334 SkPoint3 dir = target - location;
335 float cosCutoffAngle = SkScalarCos(SkDegreesToRadians(cutoffAngle));
336 return make_lighting(Light::Spot(lightColor, location, dir, falloffExponent, cosCutoffAngle),
337 Material::Diffuse(kd, surfaceScale),
338 std::move(input), cropRect);
339}
#define SkDegreesToRadians(degrees)
Definition: SkScalar.h:77
#define SkScalarCos(radians)
Definition: SkScalar.h:46
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145

◆ SpotLitSpecular()

sk_sp< SkImageFilter > SkImageFilters::SpotLitSpecular ( const SkPoint3 location,
const SkPoint3 target,
SkScalar  falloffExponent,
SkScalar  cutoffAngle,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  ks,
SkScalar  shininess,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the specular illumination from a spot light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors). The spot light is restricted to be within 'cutoffAngle' of the vector between the location and target.

Parameters
locationThe location of the spot light.
targetThe location that the spot light is point towards
falloffExponentExponential falloff parameter for illumination outside of cutoffAngle
cutoffAngleMaximum angle from lighting direction that receives full light
lightColorThe color of the specular light source.
surfaceScaleScale factor to transform from alpha values to physical height.
ksSpecular reflectance coefficient.
shininessThe specular exponent determining how shiny the surface is.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

Definition at line 357 of file SkLightingImageFilter.cpp.

360 {
361 SkPoint3 dir = target - location;
362 float cosCutoffAngle = SkScalarCos(SkDegreesToRadians(cutoffAngle));
363 return make_lighting(Light::Spot(lightColor, location, dir, falloffExponent, cosCutoffAngle),
364 Material::Specular(ks, shininess, surfaceScale),
365 std::move(input), cropRect);
366}

◆ Tile()

sk_sp< SkImageFilter > SkImageFilters::Tile ( const SkRect src,
const SkRect dst,
sk_sp< SkImageFilter input 
)
static

Create a tile image filter.

Parameters
srcDefines the pixels to tile
dstDefines the pixel region that the tiles will be drawn to
inputThe input that will be tiled, if null the source bitmap is used instead.

Definition at line 114 of file SkCropImageFilter.cpp.

116 {
117 // The Tile filter is simply a crop to 'src' with a kRepeat tile mode wrapped in a crop to 'dst'
118 // with a kDecal tile mode.
120 filter = SkImageFilters::Crop(dst, SkTileMode::kDecal, std::move(filter));
121 return filter;
122}
dst
Definition: cp.py:12

The documentation for this class was generated from the following files: