8 #ifndef SkImageFilters_DEFINED
9 #define SkImageFilters_DEFINED
24 #include <string_view>
47 struct CropRect :
public std::optional<SkRect> {
65 *
this = *optionalCrop;
71 return this->has_value() == o.has_value() &&
72 (!this->has_value() || this->value() == *o);
249 return Image(std::move(image), r, r, sampling);
292 SkScalar bias,
const SkIPoint& kernelOffset,
328 return Merge(array, 2, cropRect);
354 return Picture(std::move(pic), target);
377 std::string_view childShaderName,
379 return RuntimeShader(builder, 0.f, childShaderName, std::move(input));
395 std::string_view childShaderName,
416 std::string_view childShaderNames[],
419 return RuntimeShader(builder, 0.f, childShaderNames,
434 std::string_view childShaderNames[],
457 return Shader(std::move(shader), Dither::kNo, cropRect);
SkBlendMode
Blends are operators that take in two colors (source, destination) and return a new color.
Definition: SkBlendMode.h:38
Types, consts, functions, and macros for colors.
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:37
SkColorChannel
Describes different color channels one can manipulate.
Definition: SkColor.h:228
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
float SkScalar
Definition: SkScalar.h:14
SkTileMode
Definition: SkTileMode.h:13
@ kDecal
Only draw within the original domain, return transparent-black everywhere else.
SkBlender represents a custom blend function in the Skia pipeline.
Definition: SkBlender.h:19
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:35
Definition: SkImageFilters.h:42
static sk_sp< SkImageFilter > PointLitDiffuse(const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that calculates the diffuse illumination from a point light source,...
Dither
Definition: SkImageFilters.h:438
static sk_sp< SkImageFilter > Crop(const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
Create a filter that applies a crop to the result of the 'input' filter.
static sk_sp< SkImageFilter > SpotLitDiffuse(const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that calculates the diffuse illumination from a spot light source,...
static sk_sp< SkImageFilter > Merge(sk_sp< SkImageFilter > *const filters, int count, const CropRect &cropRect={})
Create a filter that merges the 'count' filters together by drawing their results in order with src-o...
static sk_sp< SkImageFilter > Shader(sk_sp< SkShader > shader, const CropRect &cropRect={})
Create a filter that fills the output with the per-pixel evaluation of the SkShader.
Definition: SkImageFilters.h:456
static sk_sp< SkImageFilter > Picture(sk_sp< SkPicture > pic)
Definition: SkImageFilters.h:352
static sk_sp< SkImageFilter > Magnifier(const SkRect &lensBounds, SkScalar zoomAmount, SkScalar inset, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that fills 'lensBounds' with a magnification of the input.
static sk_sp< SkImageFilter > Empty()
Create a filter that always produces transparent black.
static sk_sp< SkImageFilter > Blend(SkBlendMode mode, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
This filter takes an SkBlendMode and uses it to composite the two filters together.
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Definition: SkImageFilters.h:126
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
Create a filter that transforms the input image by 'matrix'.
static sk_sp< SkImageFilter > DropShadowOnly(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow,...
static sk_sp< SkImageFilter > Crop(const SkRect &rect, sk_sp< SkImageFilter > input)
Definition: SkImageFilters.h:165
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that blurs its input by the separate X and Y sigmas.
static sk_sp< SkImageFilter > DisplacementMap(SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkScalar scale, sk_sp< SkImageFilter > displacement, sk_sp< SkImageFilter > color, const CropRect &cropRect={})
Create a filter that moves each pixel in its color input based on an (x,y) vector encoded in its disp...
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
Create a filter that draws the 'srcRect' portion of image into 'dstRect' using the given filter quali...
static sk_sp< SkImageFilter > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that erodes each input pixel's channel values to the minimum channel value within the...
static sk_sp< SkImageFilter > Tile(const SkRect &src, const SkRect &dst, sk_sp< SkImageFilter > input)
Create a tile image filter.
static sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that applies the color filter to the input filter results.
static sk_sp< SkImageFilter > 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={})
Create a filter that calculates the specular illumination from a spot light source,...
static sk_sp< SkImageFilter > 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={})
Create a filter that applies an NxM image processing kernel to the input image.
static sk_sp< SkImageFilter > Shader(sk_sp< SkShader > shader, Dither dither, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Picture(sk_sp< SkPicture > pic, const SkRect &targetRect)
Create a filter that produces the SkPicture as its output, clipped to both 'targetRect' and the pictu...
static sk_sp< SkImageFilter > RuntimeShader(const SkRuntimeShaderBuilder &builder, std::string_view childShaderNames[], const sk_sp< SkImageFilter > inputs[], int inputCount)
Create a filter that fills the output with the per-pixel evaluation of the SkShader produced by the S...
Definition: SkImageFilters.h:415
static sk_sp< SkImageFilter > Merge(sk_sp< SkImageFilter > first, sk_sp< SkImageFilter > second, const CropRect &cropRect={})
Create a filter that merges the results of the two filters together with src-over blending.
Definition: SkImageFilters.h:325
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that dilates each input pixel's channel values to the max value within the given radi...
static sk_sp< SkImageFilter > Arithmetic(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground, const CropRect &cropRect={})
Create a filter that implements a custom blend mode.
static sk_sp< SkImageFilter > RuntimeShader(const SkRuntimeShaderBuilder &builder, std::string_view childShaderName, sk_sp< SkImageFilter > input)
Create a filter that fills the output with the per-pixel evaluation of the SkShader produced by the S...
Definition: SkImageFilters.h:376
static sk_sp< SkImageFilter > Blend(sk_sp< SkBlender > blender, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
This filter takes an SkBlendMode and uses it to composite the two filters together.
static sk_sp< SkImageFilter > DropShadow(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that draws a drop shadow under the input content.
static sk_sp< SkImageFilter > RuntimeShader(const SkRuntimeShaderBuilder &builder, SkScalar maxSampleRadius, std::string_view childShaderNames[], const sk_sp< SkImageFilter > inputs[], int inputCount)
As above, but 'maxSampleRadius' defines the sampling limit on coordinates provided to all child shade...
static sk_sp< SkImageFilter > DistantLitDiffuse(const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that calculates the diffuse illumination from a distant light source,...
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkSamplingOptions &sampling)
Create a filter that draws the image using the given sampling.
Definition: SkImageFilters.h:246
static sk_sp< SkImageFilter > Offset(SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that offsets the input filter by the given vector.
static sk_sp< SkImageFilter > PointLitSpecular(const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that calculates the specular illumination from a point light source,...
static sk_sp< SkImageFilter > DistantLitSpecular(const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
Create a filter that calculates the specular illumination from a distant light source,...
static sk_sp< SkImageFilter > RuntimeShader(const SkRuntimeShaderBuilder &builder, SkScalar sampleRadius, std::string_view childShaderName, sk_sp< SkImageFilter > input)
As above, but 'sampleRadius' defines the sampling radius of 'childShaderName' relative to the runtime...
static sk_sp< SkImageFilter > Compose(sk_sp< SkImageFilter > outer, sk_sp< SkImageFilter > inner)
Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are treated as t...
SkIRect bounds() const
Returns SkIRect { 0, 0, width(), height() }.
Definition: SkImage.h:301
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
virtual SkRect cullRect() const =0
Returns cull SkRect for this picture, passed in when SkPicture was created.
SkRuntimeShaderBuilder is a utility to simplify creating SkShader objects from SkRuntimeEffects.
Definition: SkRuntimeEffect.h:473
sk_sp< SkDrawLooper > SK_API Make(SkColor4f color, SkColorSpace *cs, SkScalar sigma, SkScalar dx, SkScalar dy)
SkIRect holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:32
Definition: SkImageFilters.h:47
CropRect(const SkIRect &crop)
Definition: SkImageFilters.h:51
CropRect(const std::nullopt_t &)
Definition: SkImageFilters.h:54
CropRect(const SkRect *optionalCrop)
Definition: SkImageFilters.h:63
CropRect(const SkIRect *optionalCrop)
Definition: SkImageFilters.h:58
CropRect(std::nullptr_t)
Definition: SkImageFilters.h:57
bool operator==(const CropRect &o) const
Definition: SkImageFilters.h:70
CropRect()
Definition: SkImageFilters.h:48
CropRect(const std::optional< SkRect > &crop)
Definition: SkImageFilters.h:53
CropRect(const SkRect &crop)
Definition: SkImageFilters.h:52
Definition: SkPoint3.h:14
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
static SkRect Make(const SkISize &size)
Returns constructed SkIRect set to (0, 0, size.width(), size.height()).
Definition: SkRect.h:669
static constexpr SkRect MakeEmpty()
Returns constructed SkRect set to (0, 0, 0, 0).
Definition: SkRect.h:595
Definition: SkSamplingOptions.h:58