Skia
2D Graphics Library
SkImageFilter Class Referenceabstract

Base class for image filters. More...

#include <SkImageFilter.h>

Inheritance diagram for SkImageFilter:

Public Types

enum  MapDirection { kForward_MapDirection , kReverse_MapDirection }
 
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

SkIRect filterBounds (const SkIRect &src, const SkMatrix &ctm, MapDirection, const SkIRect *inputRect=nullptr) const
 Map a device-space rect recursively forward or backward through the filter DAG. More...
 
bool isColorFilterNode (SkColorFilter **filterPtr) const
 Returns whether this image filter is a color filter and puts the color filter into the "filterPtr" parameter if it can. More...
 
bool asColorFilter (SkColorFilter **filterPtr) const
 
bool asAColorFilter (SkColorFilter **filterPtr) const
 Returns true (and optionally returns a ref'd filter) if this imagefilter can be completely replaced by the returned colorfilter. More...
 
int countInputs () const
 Returns the number of inputs this filter will accept (some inputs can be NULL). More...
 
const SkImageFiltergetInput (int i) const
 Returns the input filter at a given index, or NULL if no input is connected. More...
 
virtual SkRect computeFastBounds (const SkRect &bounds) const
 
bool canComputeFastBounds () const
 
sk_sp< SkImageFiltermakeWithLocalMatrix (const SkMatrix &matrix) const
 If this filter can be represented by another filter + a localMatrix, return that filter, else return null. More...
 
virtual Factory getFactory () const =0
 Implement this to return a factory function pointer that can be called to recreate your class given a buffer (previously written to by your override of flatten(). More...
 
virtual const char * getTypeName () const =0
 Returns the name of the object's class. More...
 
virtual void flatten (SkWriteBuffer &) const
 Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()). More...
 
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
 
bool unique () const
 May return true if the caller is the only owner. More...
 
void ref () const
 Increment the reference count. More...
 
void unref () const
 Decrement the reference count. More...
 

Static Public Member Functions

static sk_sp< SkImageFilterDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
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

sk_sp< SkImageFilterrefMe () const
 

Friends

class SkImageFilter_Base
 

Detailed Description

Base class for image filters.

If one is installed in the paint, then all drawing occurs as usual, but it is as if the drawing happened into an offscreen (before the xfermode is applied). This offscreen bitmap will then be handed to the imagefilter, who in turn creates a new bitmap which is what will finally be drawn to the device (using the original xfermode).

The local space of image filters matches the local space of the drawn geometry. For instance if there is rotation on the canvas, the blur will be computed along those rotated axes and not in the device space. In order to achieve this result, the actual drawing of the geometry may happen in an unrotated coordinate system so that the filtered image can be computed more easily, and then it will be post transformed to match what would have been produced if the geometry were drawn with the total canvas matrix to begin with.

Member Typedef Documentation

◆ Factory

typedef sk_sp<SkFlattenable>(* SkFlattenable::Factory) (SkReadBuffer &)
inherited

Member Enumeration Documentation

◆ MapDirection

Enumerator
kForward_MapDirection 
kReverse_MapDirection 

◆ Type

enum SkFlattenable::Type
inherited
Enumerator
kSkColorFilter_Type 
kSkBlender_Type 
kSkDrawable_Type 
kSkDrawLooper_Type 
kSkImageFilter_Type 
kSkMaskFilter_Type 
kSkPathEffect_Type 
kSkShader_Type 

Member Function Documentation

◆ asAColorFilter()

bool SkImageFilter::asAColorFilter ( SkColorFilter **  filterPtr) const

Returns true (and optionally returns a ref'd filter) if this imagefilter can be completely replaced by the returned colorfilter.

i.e. the two effects will affect drawing in the same way.

◆ asColorFilter()

bool SkImageFilter::asColorFilter ( SkColorFilter **  filterPtr) const
inline

◆ canComputeFastBounds()

bool SkImageFilter::canComputeFastBounds ( ) const

◆ computeFastBounds()

virtual SkRect SkImageFilter::computeFastBounds ( const SkRect bounds) const
virtual

◆ countInputs()

int SkImageFilter::countInputs ( ) const

Returns the number of inputs this filter will accept (some inputs can be NULL).

◆ Deserialize() [1/2]

static sk_sp<SkImageFilter> SkImageFilter::Deserialize ( const void *  data,
size_t  size,
const SkDeserialProcs procs = nullptr 
)
inlinestatic

◆ Deserialize() [2/2]

static sk_sp<SkFlattenable> SkFlattenable::Deserialize ( Type  ,
const void *  data,
size_t  length,
const SkDeserialProcs procs = nullptr 
)
staticinherited

◆ FactoryToName()

static const char* SkFlattenable::FactoryToName ( Factory  )
staticinherited

◆ filterBounds()

SkIRect SkImageFilter::filterBounds ( const SkIRect src,
const SkMatrix ctm,
MapDirection  ,
const SkIRect inputRect = nullptr 
) const

Map a device-space rect recursively forward or backward through the filter DAG.

kForward_MapDirection is used to determine which pixels of the destination canvas a source image rect would touch after filtering. kReverse_MapDirection is used to determine which rect of the source image would be required to fill the given rect (typically, clip bounds). Used for clipping and temp-buffer allocations, so the result need not be exact, but should never be smaller than the real answer. The default implementation recursively unions all input bounds, or returns the source rect if no inputs.

In kReverse mode, 'inputRect' is the device-space bounds of the input pixels. In kForward mode it should always be null. If 'inputRect' is null in kReverse mode the resulting answer may be incorrect.

◆ flatten()

virtual void SkFlattenable::flatten ( SkWriteBuffer &  ) const
inlinevirtualinherited

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 in SkLayerDrawLooper.

◆ getFactory()

virtual Factory SkFlattenable::getFactory ( ) const
pure virtualinherited

Implement this to return a factory function pointer that can be called to recreate your class given a buffer (previously written to by your override of flatten().

Implemented in SkDrawable.

◆ getFlattenableType()

virtual Type SkFlattenable::getFlattenableType ( ) const
pure virtualinherited

Implemented in SkDrawLooper, and SkDrawable.

◆ getInput()

const SkImageFilter* SkImageFilter::getInput ( int  i) const

Returns the input filter at a given index, or NULL if no input is connected.

The indices used are filter-specific.

◆ getTypeName()

virtual const char* SkFlattenable::getTypeName ( ) const
pure virtualinherited

Returns the name of the object's class.

Implemented in SkDrawable.

◆ isColorFilterNode()

bool SkImageFilter::isColorFilterNode ( SkColorFilter **  filterPtr) const

Returns whether this image filter is a color filter and puts the color filter into the "filterPtr" parameter if it can.

Does nothing otherwise. If this returns false, then the filterPtr is unchanged. If this returns true, then if filterPtr is not null, it must be set to a ref'd colorfitler (i.e. it may not be set to NULL).

◆ makeWithLocalMatrix()

sk_sp<SkImageFilter> SkImageFilter::makeWithLocalMatrix ( const SkMatrix matrix) const

If this filter can be represented by another filter + a localMatrix, return that filter, else return null.

◆ NameToFactory()

static Factory SkFlattenable::NameToFactory ( const char  name[])
staticinherited

◆ ref()

void SkRefCntBase::ref ( ) const
inlineinherited

Increment the reference count.

Must be balanced by a call to unref().

◆ refMe()

sk_sp<SkImageFilter> SkImageFilter::refMe ( ) const
inlineprotected

◆ Register()

static void SkFlattenable::Register ( const char  name[],
Factory   
)
staticinherited

◆ serialize() [1/2]

sk_sp<SkData> SkFlattenable::serialize ( const SkSerialProcs = nullptr) const
inherited

◆ serialize() [2/2]

size_t SkFlattenable::serialize ( void *  memory,
size_t  memory_size,
const SkSerialProcs = nullptr 
) const
inherited

◆ unique()

bool SkRefCntBase::unique ( ) const
inlineinherited

May return true if the caller is the only owner.

Ensures that all previous owner's actions are complete.

◆ unref()

void SkRefCntBase::unref ( ) const
inlineinherited

Decrement the reference count.

If the reference count is 1 before the decrement, then delete the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.

Friends And Related Function Documentation

◆ SkImageFilter_Base

friend class SkImageFilter_Base
friend

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