40enum class MorphDirection {
kX,
kY };
75 static constexpr int kMaxRadii = 256;
83 bounds.outset(this->radii(mapping));
90 if (fType == MorphType::kDilate) {
131static constexpr int kMaxLinearRadius = 14;
134 MorphDirection direction,
136 SkASSERT(radius <= kMaxLinearRadius);
142 builder.child(
"child") = std::move(input);
144 builder.uniform(
"flip") = (
type == MorphType::kDilate) ? 1.f : -1.f;
145 builder.uniform(
"radius") = (int32_t) radius;
156 MorphDirection direction,
163 builder.child(
"child") = std::move(input);
166 builder.uniform(
"flip") = (
type == MorphType::kDilate) ? 1.f : -1.f;
172 MorphType
type, MorphDirection
dir,
int radius) {
175 auto axisDelta = [
dir](
int step) {
178 dir == MorphDirection::kY ?
step : 0});
183 sampleBounds.
outset(axisDelta(radius));
186 int appliedRadius = 0;
187 while (radius > appliedRadius) {
195 appliedRadius == 0 ?
std::min(kMaxLinearRadius, radius)
196 :
std::
min(radius - appliedRadius, appliedRadius);
199 if (appliedRadius + stepRadius < radius) {
201 auto outputBounds = sampleBounds;
202 outputBounds.
inset(axisDelta(stepRadius));
207 builder.add(childOutput, sampleBounds, ShaderFlags::kSampledRepeatedly);
210 if (appliedRadius == 0) {
211 return make_linear_morphology(
inputs[0],
type,
dir, stepRadius);
213 return make_sparse_morphology(
inputs[0],
type,
dir, stepRadius);
218 appliedRadius += stepRadius;
230 return make_morphology(MorphType::kDilate, {radiusX, radiusY}, std::move(input), cropRect);
236 return make_morphology(MorphType::kErode, {radiusX, radiusY}, std::move(input), cropRect);
250 MorphType filterType =
buffer.read32LE(MorphType::kLastType);
252 if (filterType == MorphType::kDilate) {
254 }
else if (filterType == MorphType::kErode) {
265 buffer.writeInt(
static_cast<int>(fType));
292 MorphDirection::kY, radii.
height());
301 return this->getChildInputLayerBounds(0, mapping, requiredInput, contentBounds);
304std::optional<skif::LayerSpace<SkIRect>> SkMorphologyImageFilter::onGetOutputLayerBounds(
307 auto childOutput = this->getChildOutputLayerBounds(0, mapping, contentBounds);
309 return this->kernelOutputBounds(mapping, *childOutput);
315SkRect SkMorphologyImageFilter::computeFastBounds(
const SkRect&
src)
const {
318 if (fType == MorphType::kDilate) {
static int step(int x, SkScalar min, SkScalar max)
#define SK_FLATTENABLE_HOOKS(type)
#define SK_REGISTER_FLATTENABLE(type)
#define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount)
void SkRegisterMorphologyImageFilterFlattenables()
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 > Erode(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Crop(const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
static sk_sp< SkImageFilter > Dilate(SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
const LayerSpace< SkIRect > & desiredOutput() const
Context withNewDesiredOutput(const LayerSpace< SkIRect > &desiredOutput) const
const Mapping & mapping() const
LayerSpace< SkIRect > layerBounds() const
void outset(const LayerSpace< SkISize > &delta)
bool intersect(const LayerSpace< SkIRect > &r)
void inset(const LayerSpace< SkISize > &delta)
LayerSpace< T > paramToLayer(const ParameterSpace< T > ¶mGeometry) const
static float min(float r, float g, float b)
const SkRuntimeEffect * GetKnownRuntimeEffect(StableKey stableKey)
Optional< SkRect > bounds
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
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