37 static constexpr int kDisplacement = 0;
38 static constexpr int kColor = 1;
131 builder.child(
"displMap") = std::move(displacement);
134 builder.uniform(
"xSelect") = channelSelector(xChannel);
135 builder.uniform(
"ySelect") = channelSelector(yChannel);
147 if (!channel_selector_type_is_valid(xChannelSelector) ||
148 !channel_selector_type_is_valid(yChannelSelector)) {
153 sk_sp<SkImageFilter> filter(
new SkDisplacementMapImageFilter(xChannelSelector, yChannelSelector,
166 SkDisplacementMapImageFilter::CreateProc);
182 buffer.writeInt((
int) fXChannel);
183 buffer.writeInt((
int) fYChannel);
184 buffer.writeScalar(fScale);
233 if (!displacementOutput) {
239 return colorOutput.
applyTransform(ctx, constantDisplacement, kDisplacementSampling);
247 builder.add(displacementOutput, outputBounds);
250 ShaderFlags::kNonTrivialSampling,
251 kDisplacementSampling);
255 scale, fXChannel, fYChannel);
267 requiredInput = this->getChildInputLayerBounds(
kColor, mapping, requiredInput, contentBounds);
270 requiredInput.
join(this->getChildInputLayerBounds(
271 kDisplacement, mapping, desiredOutput, contentBounds));
272 return requiredInput;
275std::optional<skif::LayerSpace<SkIRect>> SkDisplacementMapImageFilter::onGetOutputLayerBounds(
278 auto colorOutput = this->getChildOutputLayerBounds(
kColor, mapping, contentBounds);
280 return this->outsetByMaxDisplacement(mapping, *colorOutput);
286SkRect SkDisplacementMapImageFilter::computeFastBounds(
const SkRect&
src)
const {
289 float maxDisplacement = 0.5f *
SkScalarAbs(fScale);
290 return colorBounds.
makeOutset(maxDisplacement, maxDisplacement);
static constexpr SkColor kColor
@ kColor
hue and saturation of source with luminosity of destination
constexpr SkColor SK_ColorTRANSPARENT
void SkRegisterDisplacementMapImageFilterFlattenable()
#define SK_FLATTENABLE_HOOKS(type)
#define SK_REGISTER_FLATTENABLE(type)
#define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount)
sk_sp< T > sk_ref_sp(T *obj)
static void Register(const char name[], Factory)
virtual skif::LayerSpace< SkIRect > onGetInputLayerBounds(const skif::Mapping &mapping, const skif::LayerSpace< SkIRect > &desiredOutput, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const =0
void flatten(SkWriteBuffer &) const override
virtual std::optional< skif::LayerSpace< SkIRect > > onGetOutputLayerBounds(const skif::Mapping &mapping, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const =0
virtual skif::FilterResult onFilterImage(const skif::Context &context) const =0
virtual SkRect computeFastBounds(const SkRect &bounds) const
static sk_sp< SkImageFilter > DisplacementMap(SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkScalar scale, sk_sp< SkImageFilter > displacement, sk_sp< SkImageFilter > color, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Crop(const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Context withNewColorSpace(SkColorSpace *cs) const
const LayerSpace< SkIRect > & desiredOutput() const
Context withNewDesiredOutput(const LayerSpace< SkIRect > &desiredOutput) const
const Mapping & mapping() const
LayerSpace< SkIRect > layerBounds() const
FilterResult applyTransform(const Context &ctx, const LayerSpace< SkMatrix > &transform, const SkSamplingOptions &sampling) const
bool intersect(const LayerSpace< SkIRect > &r)
void join(const LayerSpace< SkIRect > &r)
LayerSpace< SkISize > ceil() const
LayerSpace< T > paramToLayer(const ParameterSpace< T > ¶mGeometry) const
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
Optional< SkRect > bounds
SK_API sk_sp< SkShader > Color(SkColor)
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 buffer
SkRect makeOutset(float dx, float dy) const