Skia
2D Graphics Library
|
Base class for image filters. More...
#include <SkImageFilter.h>
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 SkImageFilter * | getInput (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< SkImageFilter > | makeWithLocalMatrix (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< SkData > | serialize (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< SkImageFilter > | Deserialize (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< SkFlattenable > | Deserialize (Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr) |
Protected Member Functions | |
sk_sp< SkImageFilter > | refMe () const |
Friends | |
class | SkImageFilter_Base |
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.
|
inherited |
|
inherited |
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.
|
inline |
bool SkImageFilter::canComputeFastBounds | ( | ) | const |
int SkImageFilter::countInputs | ( | ) | const |
Returns the number of inputs this filter will accept (some inputs can be NULL).
|
inlinestatic |
|
staticinherited |
|
staticinherited |
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.
|
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.
|
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.
|
pure virtualinherited |
Implemented in SkDrawLooper, and SkDrawable.
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.
|
pure virtualinherited |
Returns the name of the object's class.
Implemented in SkDrawable.
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).
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.
|
staticinherited |
|
inlineinherited |
Increment the reference count.
Must be balanced by a call to unref().
|
inlineprotected |
|
staticinherited |
|
inherited |
|
inherited |
|
inlineinherited |
May return true if the caller is the only owner.
Ensures that all previous owner's actions are complete.
|
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.
|
friend |