Flutter Engine
The Flutter Engine
|
#include <SkImageFilter_Base.h>
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< SkImage > | makeImageWithFilter (sk_sp< skif::Backend > backend, sk_sp< SkImage > src, const SkIRect &subset, const SkIRect &clipBounds, SkIRect *outSubset, SkIPoint *offset) const |
skif::LayerSpace< SkIRect > | getInputBounds (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 SkImageFilter * | getInput (int i) const |
virtual SkRect | computeFastBounds (const SkRect &bounds) const |
bool | canComputeFastBounds () const |
sk_sp< SkImageFilter > | makeWithLocalMatrix (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< SkData > | serialize (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< SkImageFilter > | Deserialize (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< SkFlattenable > | Deserialize (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< SkIRect > | getChildInputLayerBounds (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< SkImageFilter > | refMe () 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< SkIRect > | onGetInputLayerBounds (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 |
Definition at line 23 of file SkImageFilter_Base.h.
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.
|
protected |
Definition at line 148 of file SkImageFilter.cpp.
|
overrideprotected |
Definition at line 163 of file SkImageFilter.cpp.
bool SkImageFilter_Base::affectsTransparentBlack | ( | ) | const |
Definition at line 102 of file SkImageFilter.cpp.
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.
|
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.
|
protected |
Definition at line 348 of file SkImageFilter.cpp.
|
protected |
Definition at line 383 of file SkImageFilter.cpp.
|
protected |
Definition at line 372 of file SkImageFilter.cpp.
SkImageFilter_Base::MatrixCapability SkImageFilter_Base::getCTMCapability | ( | ) | const |
Definition at line 337 of file SkImageFilter.cpp.
|
inlinestatic |
Definition at line 132 of file SkImageFilter_Base.h.
|
inlineoverridevirtual |
Implements SkFlattenable.
Definition at line 136 of file SkImageFilter_Base.h.
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.
mapping | The 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. |
desiredOutput | The desired output boundary that needs to be covered by the filter's output (assuming that the filter is then invoked with a suitable input) |
knownContentBounds | Optional, 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. |
Definition at line 302 of file SkImageFilter.cpp.
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.
mapping | The 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. |
contentBounds | The 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(). |
Definition at line 320 of file SkImageFilter.cpp.
|
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.
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.
|
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.
|
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.
|
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.
|
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'.
|
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'.
|
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.
|
static |
Definition at line 168 of file SkImageFilter.cpp.
|
inline |
Definition at line 130 of file SkImageFilter_Base.h.
|
inline |
Definition at line 122 of file SkImageFilter_Base.h.
|
friend |
Definition at line 205 of file SkImageFilter_Base.h.
|
friend |
Definition at line 203 of file SkImageFilter_Base.h.