40 SkMagnifierImageFilter(
const SkRect& lensBounds,
46 , fLensBounds(lensBounds)
47 , fZoomAmount(zoomAmount)
89 zoomAmount <= 0.f ||
inset < 0.f ||
99 if (zoomAmount > 1.f) {
125 buffer.readRect(&lensBounds);
135 buffer.writeScalar(fZoomAmount);
136 buffer.writeScalar(fInset);
137 buffer.writeSampling(fSampling);
151 builder.child(
"src") = std::move(input);
155 builder.uniform(
"zoomXform") =
SkV4{zoomXform.
rc(0, 2), zoomXform.
rc(1, 2),
156 zoomXform.
rc(0, 0), zoomXform.
rc(1, 1)};
188 zoomCenter = expectedChildOutput.
clamp(zoomCenter);
195 SkASSERT(this->getCTMCapability() == MatrixCapability::kScaleTranslate);
196 float invZoom = 1.f / fZoomAmount;
206 lensBounds.
left() * invZoom + zoomCenter.
x()*(1.f - invZoom),
207 lensBounds.
top() * invZoom + zoomCenter.
y()*(1.f - invZoom),
208 lensBounds.
right() * invZoom + zoomCenter.
x()*(1.f - invZoom),
209 lensBounds.
bottom()* invZoom + zoomCenter.
y()*(1.f - invZoom)}};
215 if (!expectedChildOutput.
contains(visibleLensBounds)) {
218 srcRect = zoomXform.mapRect(visibleLensBounds);
220 if (expectedChildOutput.
width() >= srcRect.width() &&
221 expectedChildOutput.
height() >= srcRect.height()) {
222 float left = srcRect.left() < expectedChildOutput.
left() ?
223 expectedChildOutput.
left() :
224 std::min(srcRect.right(), expectedChildOutput.
right()) - srcRect.width();
225 float top = srcRect.top() < expectedChildOutput.
top() ?
226 expectedChildOutput.
top() :
227 std::min(srcRect.bottom(), expectedChildOutput.
bottom()) - srcRect.height();
249 return childOutput.
applyTransform(context, invZoomXform, fSampling)
256 {}, ShaderFlags::kNonTrivialSampling, fSampling);
276 return this->getChildInputLayerBounds(0, mapping, requiredInput, contentBounds);
279std::optional<skif::LayerSpace<SkIRect>> SkMagnifierImageFilter::onGetOutputLayerBounds(
283 auto output = this->getChildOutputLayerBounds(0, mapping, contentBounds);
293SkRect SkMagnifierImageFilter::computeFastBounds(
const SkRect&
src)
const {
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
#define SK_FLATTENABLE_HOOKS(type)
#define SK_REGISTER_FLATTENABLE(type)
static bool SkIsFinite(T x, Pack... values)
#define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount)
void SkRegisterMagnifierImageFilterFlattenable()
static sk_sp< SkShader > make_magnifier_shader(sk_sp< SkShader > input, const skif::LayerSpace< SkRect > &lensBounds, const skif::LayerSpace< SkMatrix > &zoomXform, const skif::LayerSpace< SkSize > &inset)
static bool left(const SkPoint &p0, const SkPoint &p1)
sk_sp< T > sk_ref_sp(T *obj)
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 > Magnifier(const SkRect &lensBounds, SkScalar zoomAmount, SkScalar inset, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Crop(const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
const LayerSpace< SkIRect > & desiredOutput() const
const FilterResult & source() const
Context withNewDesiredOutput(const LayerSpace< SkIRect > &desiredOutput) const
const Mapping & mapping() const
FilterResult applyCrop(const Context &ctx, const LayerSpace< SkIRect > &crop, SkTileMode tileMode=SkTileMode::kDecal) const
LayerSpace< SkIRect > layerBounds() const
FilterResult applyTransform(const Context &ctx, const LayerSpace< SkMatrix > &transform, const SkSamplingOptions &sampling) const
bool intersect(const LayerSpace< SkIRect > &r)
float rc(int row, int col) const
LayerSpace< SkIRect > roundOut() const
bool contains(const LayerSpace< SkRect > &r) const
LayerSpace< SkPoint > center() const
LayerSpace< SkPoint > clamp(LayerSpace< SkPoint > pt) const
bool intersect(const LayerSpace< SkRect > &r)
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
SkSamplingOptions sampling
SK_API sk_sp< SkShader > Empty()
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
static SkRect inset(const SkRect &r)
static constexpr SkRect MakeEmpty()
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
constexpr float height() const
constexpr float width() const