Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Friends | List of all members
SkImageFilter_Base Class Referenceabstract

#include <SkImageFilter_Base.h>

Inheritance diagram for SkImageFilter_Base:
SkImageFilter SkFlattenable SkRefCnt SkRefCntBase SkLocalMatrixImageFilter SkRuntimeImageFilter

Classes

class  Common
 

Public Types

using MatrixCapability = skif::MatrixCapability
 
- Public Types inherited from SkImageFilter
enum  MapDirection { kForward_MapDirection , kReverse_MapDirection }
 
- Public Types inherited from SkFlattenable
enum  Type {
  kSkColorFilter_Type , kSkBlender_Type , kSkDrawable_Type , kSkDrawLooper_Type ,
  kSkImageFilter_Type , kSkMaskFilter_Type , kSkPathEffect_Type , kSkShader_Type
}
 
typedef sk_sp< SkFlattenable >(* Factory) (SkReadBuffer &)
 

Public Member Functions

skif::FilterResult filterImage (const skif::Context &context) const
 
sk_sp< SkImagemakeImageWithFilter (sk_sp< skif::Backend > backend, sk_sp< SkImage > src, const SkIRect &subset, const SkIRect &clipBounds, SkIRect *outSubset, SkIPoint *offset) const
 
skif::LayerSpace< SkIRectgetInputBounds (const skif::Mapping &mapping, const skif::DeviceSpace< SkIRect > &desiredOutput, std::optional< skif::ParameterSpace< SkRect > > knownContentBounds) const
 
std::optional< skif::DeviceSpace< SkIRect > > getOutputBounds (const skif::Mapping &mapping, const skif::ParameterSpace< SkRect > &contentBounds) const
 
bool affectsTransparentBlack () const
 
bool usesSource () const
 
MatrixCapability getCTMCapability () const
 
uint32_t uniqueID () const
 
SkFlattenable::Type getFlattenableType () const override
 
- Public Member Functions inherited from SkImageFilter
SkIRect filterBounds (const SkIRect &src, const SkMatrix &ctm, MapDirection, const SkIRect *inputRect=nullptr) const
 
bool isColorFilterNode (SkColorFilter **filterPtr) const
 
bool asColorFilter (SkColorFilter **filterPtr) const
 
bool asAColorFilter (SkColorFilter **filterPtr) const
 
int countInputs () const
 
const SkImageFiltergetInput (int i) const
 
virtual SkRect computeFastBounds (const SkRect &bounds) const
 
bool canComputeFastBounds () const
 
sk_sp< SkImageFiltermakeWithLocalMatrix (const SkMatrix &matrix) const
 
- Public Member Functions inherited from SkFlattenable
 SkFlattenable ()
 
virtual Factory getFactory () const =0
 
virtual const char * getTypeName () const =0
 
virtual void flatten (SkWriteBuffer &) const
 
virtual Type getFlattenableType () const =0
 
sk_sp< SkDataserialize (const SkSerialProcs *=nullptr) const
 
size_t serialize (void *memory, size_t memory_size, const SkSerialProcs *=nullptr) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static SkFlattenable::Type GetFlattenableType ()
 
static std::pair< sk_sp< SkImageFilter >, std::optional< SkRect > > Unflatten (SkReadBuffer &buffer)
 
- Static Public Member Functions inherited from SkImageFilter
static sk_sp< SkImageFilterDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
- Static Public Member Functions inherited from SkFlattenable
static Factory NameToFactory (const char name[])
 
static const char * FactoryToName (Factory)
 
static void Register (const char name[], Factory)
 
static sk_sp< SkFlattenableDeserialize (Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
 

Protected Member Functions

 SkImageFilter_Base (sk_sp< SkImageFilter > const *inputs, int inputCount, std::optional< bool > usesSrc={})
 
 ~SkImageFilter_Base () override
 
void flatten (SkWriteBuffer &) const override
 
skif::LayerSpace< SkIRectgetChildInputLayerBounds (int index, const skif::Mapping &mapping, const skif::LayerSpace< SkIRect > &desiredOutput, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const
 
std::optional< skif::LayerSpace< SkIRect > > getChildOutputLayerBounds (int index, const skif::Mapping &mapping, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const
 
skif::FilterResult getChildOutput (int index, const skif::Context &ctx) const
 
- Protected Member Functions inherited from SkImageFilter
sk_sp< SkImageFilterrefMe () const
 

Private Member Functions

virtual bool onIsColorFilterNode (SkColorFilter **) const
 
virtual MatrixCapability onGetCTMCapability () const
 
virtual bool onAffectsTransparentBlack () const
 
virtual bool ignoreInputsAffectsTransparentBlack () const
 
virtual skif::FilterResult onFilterImage (const skif::Context &context) const =0
 
virtual skif::LayerSpace< SkIRectonGetInputLayerBounds (const skif::Mapping &mapping, const skif::LayerSpace< SkIRect > &desiredOutput, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const =0
 
virtual std::optional< skif::LayerSpace< SkIRect > > onGetOutputLayerBounds (const skif::Mapping &mapping, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const =0
 

Friends

class SkImageFilter
 
class SkGraphics
 

Detailed Description

Definition at line 23 of file SkImageFilter_Base.h.

Member Typedef Documentation

◆ MatrixCapability

This call returns the maximum "kind" of CTM for a filter and all of its (non-null) inputs.

Definition at line 127 of file SkImageFilter_Base.h.

Constructor & Destructor Documentation

◆ SkImageFilter_Base()

SkImageFilter_Base::SkImageFilter_Base ( sk_sp< SkImageFilter > const *  inputs,
int  inputCount,
std::optional< bool >  usesSrc = {} 
)
protected

Definition at line 148 of file SkImageFilter.cpp.

151 : fUsesSrcInput(usesSrc.has_value() ? *usesSrc : false)
152 , fUniqueID(next_image_filter_unique_id()) {
153 fInputs.reset(inputCount);
154
155 for (int i = 0; i < inputCount; ++i) {
156 if (!usesSrc.has_value() && (!inputs[i] || as_IFB(inputs[i])->usesSource())) {
157 fUsesSrcInput = true;
158 }
159 fInputs[i] = inputs[i];
160 }
161}
static int32_t next_image_filter_unique_id()
static SkImageFilter_Base * as_IFB(SkImageFilter *filter)
void reset(int count)
Definition: SkTemplates.h:195

◆ ~SkImageFilter_Base()

SkImageFilter_Base::~SkImageFilter_Base ( )
overrideprotected

Definition at line 163 of file SkImageFilter.cpp.

163 {
165}
static sk_sp< SkImageFilterCache > Get(CreateIfNecessary=CreateIfNecessary::kYes)
virtual void purgeByImageFilter(const SkImageFilter *)=0

Member Function Documentation

◆ affectsTransparentBlack()

bool SkImageFilter_Base::affectsTransparentBlack ( ) const

Definition at line 102 of file SkImageFilter.cpp.

102 {
103 if (this->onAffectsTransparentBlack()) {
104 return true;
105 } else if (this->ignoreInputsAffectsTransparentBlack()) {
106 // TODO(skbug.com/14611): Automatically infer this from output bounds being finite
107 return false;
108 }
109 for (int i = 0; i < this->countInputs(); i++) {
110 const SkImageFilter* input = this->getInput(i);
111 if (input && as_IFB(input)->affectsTransparentBlack()) {
112 return true;
113 }
114 }
115 return false;
116}
virtual bool onAffectsTransparentBlack() const
virtual bool ignoreInputsAffectsTransparentBlack() const
bool affectsTransparentBlack() const
const SkImageFilter * getInput(int i) const
int countInputs() const

◆ filterImage()

skif::FilterResult SkImageFilter_Base::filterImage ( const skif::Context context) const

Request a new filtered image to be created from the src image. The returned skif::Image provides both the pixel data and the origin point that it should be drawn at, relative to the layer space defined by the provided context.

If the result image cannot be created, or the result would be transparent black, returns a skif::Image that has a null special image, in which its origin should be ignored.

TODO: Right now the imagefilters sometimes return empty result bitmaps/ specialimages. That doesn't seem quite right.

Definition at line 231 of file SkImageFilter.cpp.

231 {
232 context.markVisitedImageFilter();
233
235 if (context.desiredOutput().isEmpty() || !context.mapping().layerMatrix().isFinite()) {
236 return result;
237 }
238
239 // Some image filters that operate on the source image still affect transparent black, so if
240 // there is clipping, we may have optimized away the source image as an empty input, but still
241 // need to run the filter on it. This means `fUsesSrcInput` is not equivalent to the source
242 // being non-null.
243 const bool srcInKey = fUsesSrcInput && context.source();
244 uint32_t srcGenID = srcInKey ? context.source().image()->uniqueID() : SK_InvalidUniqueID;
245 const SkIRect srcSubset = srcInKey ? context.source().image()->subset() : SkIRect::MakeWH(0, 0);
246
247 SkImageFilterCacheKey key(fUniqueID,
248 context.mapping().layerMatrix(),
249 SkIRect(context.desiredOutput()),
250 srcGenID, srcSubset);
251 if (context.backend()->cache() && context.backend()->cache()->get(key, &result)) {
252 context.markCacheHit();
253 return result;
254 }
255
256 result = this->onFilterImage(context);
257
258 if (context.backend()->cache()) {
259 context.backend()->cache()->set(key, this, result);
260 }
261
262 return result;
263}
static constexpr uint32_t SK_InvalidUniqueID
Definition: SkTypes.h:196
virtual bool get(const SkImageFilterCacheKey &key, skif::FilterResult *result) const =0
virtual void set(const SkImageFilterCacheKey &key, const SkImageFilter *filter, const skif::FilterResult &result)=0
virtual skif::FilterResult onFilterImage(const skif::Context &context) const =0
bool isFinite() const
Definition: SkMatrix.h:1834
uint32_t uniqueID() const
const SkIRect & subset() const
SkImageFilterCache * cache() const
void markCacheHit() const
const Backend * backend() const
const LayerSpace< SkIRect > & desiredOutput() const
const FilterResult & source() const
const Mapping & mapping() const
void markVisitedImageFilter() const
const SkSpecialImage * image() const
const SkMatrix & layerMatrix() const
GAsyncResult * result
Definition: SkRect.h:32
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56

◆ flatten()

void SkImageFilter_Base::flatten ( SkWriteBuffer ) const
overrideprotectedvirtual

Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).

DEPRECATED public : will move to protected ... use serialize() instead

Reimplemented from SkFlattenable.

Reimplemented in SkLocalMatrixImageFilter, and SkRuntimeImageFilter.

Definition at line 220 of file SkImageFilter.cpp.

220 {
221 buffer.writeInt(fInputs.count());
222 for (int i = 0; i < fInputs.count(); i++) {
223 const SkImageFilter* input = this->getInput(i);
224 buffer.writeBool(input != nullptr);
225 if (input != nullptr) {
226 buffer.writeFlattenable(input);
227 }
228 }
229}
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
Definition: switches.h:126

◆ getChildInputLayerBounds()

skif::LayerSpace< SkIRect > SkImageFilter_Base::getChildInputLayerBounds ( int  index,
const skif::Mapping mapping,
const skif::LayerSpace< SkIRect > &  desiredOutput,
std::optional< skif::LayerSpace< SkIRect > >  contentBounds 
) const
protected

Definition at line 348 of file SkImageFilter.cpp.

352 {
353 // The required input for childFilter filter, or 'contentBounds' intersected with
354 // 'desiredOutput' if the filter is null and the source image is used (i.e. the identity filter)
355 const SkImageFilter* childFilter = this->getInput(index);
356 if (childFilter) {
357 return as_IFB(childFilter)->onGetInputLayerBounds(mapping, desiredOutput, contentBounds);
358 } else {
359 // NOTE: We don't calculate the intersection between content and root desired output because
360 // the desired output can expand or contract as it propagates through the filter graph to
361 // the leaves that would actually sample from the source content.
362 skif::LayerSpace<SkIRect> visibleContent = desiredOutput;
363 if (contentBounds && !visibleContent.intersect(*contentBounds)) {
365 } else {
366 // This will be equal to 'desiredOutput' if the contentBounds are unknown.
367 return visibleContent;
368 }
369 }
370}
virtual skif::LayerSpace< SkIRect > onGetInputLayerBounds(const skif::Mapping &mapping, const skif::LayerSpace< SkIRect > &desiredOutput, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const =0
bool intersect(const LayerSpace< SkIRect > &r)
SK_API sk_sp< SkShader > Empty()

◆ getChildOutput()

skif::FilterResult SkImageFilter_Base::getChildOutput ( int  index,
const skif::Context ctx 
) const
protected

Definition at line 383 of file SkImageFilter.cpp.

383 {
384 const SkImageFilter* input = this->getInput(index);
385 return input ? as_IFB(input)->filterImage(ctx) : ctx.source();
386}
skif::FilterResult filterImage(const skif::Context &context) const

◆ getChildOutputLayerBounds()

std::optional< skif::LayerSpace< SkIRect > > SkImageFilter_Base::getChildOutputLayerBounds ( int  index,
const skif::Mapping mapping,
std::optional< skif::LayerSpace< SkIRect > >  contentBounds 
) const
protected

Definition at line 372 of file SkImageFilter.cpp.

375 {
376 // The output for just childFilter filter, or 'contentBounds' if the filter is null and
377 // the source image is used (i.e. the identity filter applied to the source).
378 const SkImageFilter* childFilter = this->getInput(index);
379 return childFilter ? as_IFB(childFilter)->onGetOutputLayerBounds(mapping, contentBounds)
380 : contentBounds;
381}
virtual std::optional< skif::LayerSpace< SkIRect > > onGetOutputLayerBounds(const skif::Mapping &mapping, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const =0

◆ getCTMCapability()

SkImageFilter_Base::MatrixCapability SkImageFilter_Base::getCTMCapability ( ) const

Definition at line 337 of file SkImageFilter.cpp.

337 {
339 const int count = this->countInputs();
340 for (int i = 0; i < count; ++i) {
341 if (const SkImageFilter_Base* input = as_IFB(this->getInput(i))) {
342 result = std::min(result, input->getCTMCapability());
343 }
344 }
345 return result;
346}
int count
Definition: FontMgrTest.cpp:50
skif::MatrixCapability MatrixCapability
virtual MatrixCapability onGetCTMCapability() const
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ GetFlattenableType()

static SkFlattenable::Type SkImageFilter_Base::GetFlattenableType ( )
inlinestatic

Definition at line 132 of file SkImageFilter_Base.h.

132 {
133 return kSkImageFilter_Type;
134 }

◆ getFlattenableType()

SkFlattenable::Type SkImageFilter_Base::getFlattenableType ( ) const
inlineoverridevirtual

Implements SkFlattenable.

Definition at line 136 of file SkImageFilter_Base.h.

136 {
137 return kSkImageFilter_Type;
138 }

◆ getInputBounds()

skif::LayerSpace< SkIRect > SkImageFilter_Base::getInputBounds ( const skif::Mapping mapping,
const skif::DeviceSpace< SkIRect > &  desiredOutput,
std::optional< skif::ParameterSpace< SkRect > >  knownContentBounds 
) const

Calculate the smallest-possible required layer bounds that would provide sufficient information to correctly compute the image filter for every pixel in the desired output bounds. The 'desiredOutput' is intended to represent either the root render target bounds, or the device-space bounds of the current clip. If the bounds of the content that will be drawn into the layer is known, 'knownContentBounds' should be provided, since it can be used to restrict the size of the layer if the image filter DAG does not affect transparent black.

The returned rect is in the layer space defined by 'mapping', so it directly represents the size and location of the SkDevice created to rasterize the content prior to invoking the image filter (assuming its CTM and basis matrix are configured to match 'mapping').

While this operation transforms an device-space output bounds to a layer-space input bounds, it is not necessarily the inverse of getOutputBounds(). For instance, a blur needs to have an outset margin when reading pixels at the edge (to satisfy its kernel), thus it expands its required input rect to include every pixel that contributes to the desired output rect.

Parameters
mappingThe coordinate space mapping that defines both the transformation between local and layer, and layer to root device space, that will be used when the filter is later invoked.
desiredOutputThe desired output boundary that needs to be covered by the filter's output (assuming that the filter is then invoked with a suitable input)
knownContentBoundsOptional, the known layer-space bounds of the non-transparent content that would be rasterized in the source input image. Assumes unbounded content when not provided.
Returns
The layer-space bounding box to use for an SkDevice when drawing the source image.

Definition at line 302 of file SkImageFilter.cpp.

305 {
306 // Map both the device-space desired coverage area and the known content bounds to layer space
307 skif::LayerSpace<SkIRect> desiredBounds = mapping.deviceToLayer(desiredOutput);
308
309 // If we have no known content bounds, leave 'contentBounds' uninstantiated to represent
310 // infinite possible content.
311 std::optional<skif::LayerSpace<SkIRect>> contentBounds;
312 if (knownContentBounds) {
313 contentBounds = mapping.paramToLayer(*knownContentBounds).roundOut();
314 }
315
316 // Process the layer-space desired output with the filter DAG to determine required input
317 return this->onGetInputLayerBounds(mapping, desiredBounds, contentBounds);
318}
const SkMatrix & deviceToLayer() const
LayerSpace< T > paramToLayer(const ParameterSpace< T > &paramGeometry) const

◆ getOutputBounds()

std::optional< skif::DeviceSpace< SkIRect > > SkImageFilter_Base::getOutputBounds ( const skif::Mapping mapping,
const skif::ParameterSpace< SkRect > &  contentBounds 
) const

Calculate the device-space bounds of the output of this filter DAG, if it were to process an image layer covering the 'contentBounds'. The 'mapping' defines how the content will be transformed to layer space when it is drawn, and how the output filter image is then transformed to the final device space (i.e. it specifies the mapping between the root device space and the parameter space of the initially provided content).

While this operation transforms a parameter-space input bounds to an device-space output bounds, it is not necessarily the inverse of getInputBounds(). For instance, a blur needs to have an outset margin when reading pixels at the edge (to satisfy its kernel), so it will generate a result larger than its input (so that the blur is visible) and, thus, expands its output to include every pixel that it will touch.

If the returned optional does not have a value, the caller should interpret this to mean that the output of the image filter will fill the entirety of whatever clipped device it's drawn into.

Parameters
mappingThe coordinate space mapping that defines both the transformation between local and layer, and layer to root device space, that will be used when the filter is later invoked.
contentBoundsThe local-space bounds of the non-transparent content that would be drawn into the source image prior to filtering with this DAG, i.e. the same as 'knownContentBounds' in getInputBounds().
Returns
The root device-space bounding box of the filtered image, were it applied to content contained by 'contentBounds' and then drawn with 'mapping' to the root device (w/o any additional clipping).

Definition at line 320 of file SkImageFilter.cpp.

322 {
323 // Map the input content into the layer space where filtering will occur
324 skif::LayerSpace<SkRect> layerContent = mapping.paramToLayer(contentBounds);
325 // Determine the filter DAGs output bounds in layer space
326 std::optional<skif::LayerSpace<SkIRect>> filterOutput =
327 this->onGetOutputLayerBounds(mapping, layerContent.roundOut());
328 if (filterOutput) {
329 // Map all the way to device space
330 return mapping.layerToDevice(*filterOutput);
331 } else {
332 // Infinite layer output is infinite device-space output too
333 return {};
334 }
335}
LayerSpace< SkIRect > roundOut() const
const SkMatrix & layerToDevice() const

◆ ignoreInputsAffectsTransparentBlack()

virtual bool SkImageFilter_Base::ignoreInputsAffectsTransparentBlack ( ) const
inlineprivatevirtual

Return true if affectsTransparentBlack() should only be based on onAffectsTransparentBlack() and ignore the transparency behavior of child input filters.

Definition at line 240 of file SkImageFilter_Base.h.

240{ return false; }

◆ makeImageWithFilter()

sk_sp< SkImage > SkImageFilter_Base::makeImageWithFilter ( sk_sp< skif::Backend backend,
sk_sp< SkImage src,
const SkIRect subset,
const SkIRect clipBounds,
SkIRect outSubset,
SkIPoint offset 
) const

Create a filtered version of the 'src' image using this filter. This is basically a wrapper around filterImage that prepares the skif::Context to filter the 'src' image directly, for implementing the SkImages::MakeWithFilter API calls.

Definition at line 265 of file SkImageFilter.cpp.

270 {
271 if (!outSubset || !offset || !src->bounds().contains(subset)) {
272 return nullptr;
273 }
274
275 auto srcSpecialImage = backend->makeImage(subset, src);
276 if (!srcSpecialImage) {
277 return nullptr;
278 }
279
281 const skif::Context context{std::move(backend),
283 skif::LayerSpace<SkIRect>(clipBounds),
284 skif::FilterResult(std::move(srcSpecialImage),
286 src->imageInfo().colorSpace(),
287 &stats};
288
290 stats.reportStats();
291
292 if (!result) {
293 return nullptr;
294 }
295
296 SkASSERT(clipBounds.contains(SkIRect::MakeXYWH(offset->fX, offset->fY,
297 result->width(), result->height())));
298 *outSubset = result->subset();
299 return result->asImage();
300}
const char * backend
#define SkASSERT(cond)
Definition: SkAssert.h:116
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
sk_sp< SkSpecialImage > imageAndOffset(const Context &ctx, SkIPoint *offset) const
dictionary stats
Definition: malisc.py:20
SeparatedVector2 offset
constexpr SkIPoint topLeft() const
Definition: SkRect.h:151
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463

◆ onAffectsTransparentBlack()

virtual bool SkImageFilter_Base::onAffectsTransparentBlack ( ) const
inlineprivatevirtual

Return true if this filter would transform transparent black pixels to a color other than transparent black. When false, optimizations can be taken to discard regions known to be transparent black and thus process fewer pixels.

Definition at line 234 of file SkImageFilter_Base.h.

234{ return false; }

◆ onFilterImage()

virtual skif::FilterResult SkImageFilter_Base::onFilterImage ( const skif::Context context) const
privatepure virtual

This is the virtual which should be overridden by the derived class to perform image filtering. Subclasses are responsible for recursing to their input filters, although the filterInput() function is provided to handle all necessary details of this.

If the image cannot be created (either because of an error or if the result would be empty because it was clipped out), this should return a filtered Image with a null SkSpecialImage. In these situations, callers that do not affect transparent black can end early, since the "transparent" implicit image would be unchanged. Callers that affect transparent black need to safely handle these null and empty images and return an image filling the context's clip bounds as if its input filtered image were transparent black.

◆ onGetCTMCapability()

virtual MatrixCapability SkImageFilter_Base::onGetCTMCapability ( ) const
inlineprivatevirtual

Return the most complex matrix type this filter can support (mapping from its parameter space to a layer space). If this returns anything less than kComplex, the filter only needs to worry about mapping from parameter to layer using a matrix that is constrained in that way (eg, scale+translate).

Definition at line 225 of file SkImageFilter_Base.h.

◆ onGetInputLayerBounds()

virtual skif::LayerSpace< SkIRect > SkImageFilter_Base::onGetInputLayerBounds ( const skif::Mapping mapping,
const skif::LayerSpace< SkIRect > &  desiredOutput,
std::optional< skif::LayerSpace< SkIRect > >  contentBounds 
) const
privatepure virtual

Calculates the necessary input layer size in order for the final output of the filter to cover the desired output bounds. The provided 'desiredOutput' represents the requested input bounds for this node's parent filter node, i.e. this function answers "what does this node require for input in order to satisfy (as its own output), the input needs of its parent?".

'contentBounds' represents the bounds of the non-transparent content that will form the source image when the filter graph is invoked. If it's not instantiated, implementations should treat the content as extending infinitely. However, since the output is known and bounded, implementations should still be able to determine a finite input bounds under these circumstances.

Unlike the public getInputBounds(), all internal bounds calculations are done in the shared layer space defined by 'mapping'.

◆ onGetOutputLayerBounds()

virtual std::optional< skif::LayerSpace< SkIRect > > SkImageFilter_Base::onGetOutputLayerBounds ( const skif::Mapping mapping,
std::optional< skif::LayerSpace< SkIRect > >  contentBounds 
) const
privatepure virtual

Calculates the output bounds that this filter node would touch when processing an input sized to 'contentBounds'. This function is responsible for recursing to its child image filters and accounting for what they output. It is up to the filter to determine how to aggregate the outputs of its children.

'contentBounds' represents the bounds of the non-transparent content that will form the source image when the filter graph is invoked. If it's not instantiated, implementations should treat the content as extending infinitely. However, since the output is known and bounded, implementations should still be able to determine a finite input bounds under these circumstances.

If the non-transparent output extends infinitely, subclasses should return an uninstantiated optional. Implementations must also be able to handle when their children return such unbounded "outputs" and react accordingly.

Unlike the public getOutputBounds(), all internal bounds calculations are done in the shared layer space defined by 'mapping'.

◆ onIsColorFilterNode()

virtual bool SkImageFilter_Base::onIsColorFilterNode ( SkColorFilter **  ) const
inlineprivatevirtual

Return true (and returns a ref'd colorfilter) if this node in the DAG is just a colorfilter w/o cropping constraints.

Definition at line 217 of file SkImageFilter_Base.h.

217{ return false; }

◆ Unflatten()

std::pair< sk_sp< SkImageFilter >, std::optional< SkRect > > SkImageFilter_Base::Unflatten ( SkReadBuffer buffer)
static

Definition at line 168 of file SkImageFilter.cpp.

168 {
169 Common common;
170 if (!common.unflatten(buffer, 1)) {
171 return {nullptr, std::nullopt};
172 } else {
173 return {common.getInput(0), common.cropRect()};
174 }
175}
Definition: common.py:1

◆ uniqueID()

uint32_t SkImageFilter_Base::uniqueID ( ) const
inline

Definition at line 130 of file SkImageFilter_Base.h.

130{ return fUniqueID; }

◆ usesSource()

bool SkImageFilter_Base::usesSource ( ) const
inline

Definition at line 122 of file SkImageFilter_Base.h.

122{ return fUsesSrcInput; }

Friends And Related Function Documentation

◆ SkGraphics

friend class SkGraphics
friend

Definition at line 205 of file SkImageFilter_Base.h.

◆ SkImageFilter

friend class SkImageFilter
friend

Definition at line 203 of file SkImageFilter_Base.h.


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