Skia
2DGraphicsLibrary
|
ColorFilters are optional objects in the drawing pipeline. More...
#include <SkColorFilter.h>
Public Types | |
enum | Flags { kAlphaUnchanged_Flag = 1 << 0 } |
Public Types inherited from SkFlattenable | |
enum | Type { kSkColorFilter_Type, kSkDrawable_Type, kSkDrawLooper_Type, kSkImageFilter_Type, kSkMaskFilter_Type, kSkPathEffect_Type, kSkPixelRef_Type, kSkRasterizer_Type, kSkShaderBase_Type, kSkUnused_Type, kSkUnused_Xfermode_Type, kSkNormalSource_Type } |
typedef sk_sp< SkFlattenable >(* | Factory )(SkReadBuffer &) |
Public Member Functions | |
virtual bool | asColorMode (SkColor *color, SkBlendMode *bmode) const |
If the filter can be represented by a source color plus Mode, this returns true, and sets (if not NULL) the color and mode appropriately. More... | |
virtual bool | asColorMatrix (SkScalar matrix[20]) const |
If the filter can be represented by a 5x4 matrix, this returns true, and sets the matrix appropriately. More... | |
virtual bool | asComponentTable (SkBitmap *table) const |
If the filter can be represented by per-component table, return true, and if table is not null, copy the bitmap containing the table into it. More... | |
virtual void | filterSpan (const SkPMColor src[], int count, SkPMColor result[]) const =0 |
Called with a scanline of colors, as if there was a shader installed. More... | |
void | appendStages (SkRasterPipeline *, SkColorSpace *, SkArenaAlloc *, bool shaderIsOpaque) const |
virtual uint32_t | getFlags () const |
Returns the flags for this filter. More... | |
virtual sk_sp< SkColorFilter > | makeComposed (sk_sp< SkColorFilter >) const |
If this subclass can optimally createa composition with the inner filter, return it as a new filter (which the caller must unref() when it is done). More... | |
SkColor | filterColor (SkColor) const |
Apply this colorfilter to the specified SkColor. More... | |
SkColor4f | filterColor4f (const SkColor4f &) const |
Filters a single color. | |
virtual sk_sp < GrFragmentProcessor > | asFragmentProcessor (GrContext *, SkColorSpace *dstColorSpace) const |
A subclass may implement this factory function to work with the GPU backend. More... | |
bool | affectsTransparentBlack () const |
Public Member Functions inherited from SkFlattenable | |
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(). | |
virtual const char * | getTypeName () const |
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()). | |
Public Member Functions inherited from SkRefCntBase | |
SkRefCntBase () | |
Default construct, initializing the reference count to 1. | |
virtual | ~SkRefCntBase () |
Destruct, asserting that the reference count is 1. | |
int32_t | getRefCnt () const |
Return the reference count. More... | |
void | validate () 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< SkColorFilter > | MakeModeFilter (SkColor c, SkBlendMode mode) |
Create a colorfilter that uses the specified color and mode. More... | |
static sk_sp< SkColorFilter > | MakeComposeFilter (sk_sp< SkColorFilter > outer, sk_sp< SkColorFilter > inner) |
Construct a colorfilter whose effect is to first apply the inner filter and then apply the outer filter to the result of the inner's. More... | |
static sk_sp< SkColorFilter > | MakeMatrixFilterRowMajor255 (const SkScalar array[20]) |
Construct a color filter that transforms a color by a 4x5 matrix. More... | |
Static Public Member Functions inherited from SkFlattenable | |
static Factory | NameToFactory (const char name[]) |
static const char * | FactoryToName (Factory) |
static bool | NameToType (const char name[], Type *type) |
static void | Register (const char name[], Factory, Type) |
Protected Member Functions | |
sk_sp< SkColorFilter > | makeColorSpace (SkColorSpaceXformer *xformer) const |
virtual sk_sp< SkColorFilter > | onMakeColorSpace (SkColorSpaceXformer *) const |
Protected Member Functions inherited from SkRefCntBase | |
void | internal_dispose_restore_refcnt_to_1 () const |
Allow subclasses to call this if they've overridden internal_dispose so they can reset fRefCnt before the destructor is called or if they choose not to call the destructor (e.g. More... | |
Private Types | |
typedef SkFlattenable | INHERITED |
Private Member Functions | |
virtual int | privateComposedFilterCount () const |
virtual void | onAppendStages (SkRasterPipeline *, SkColorSpace *, SkArenaAlloc *, bool shaderIsOpaque) const =0 |
Friends | |
class | SkColorSpaceXformer |
class | SkComposeColorFilter |
ColorFilters are optional objects in the drawing pipeline.
When present in a paint, they are called with the "src" colors, and return new colors, which are then passed onto the next stage (either ImageFilter or Xfermode).
All subclasses are required to be reentrant-safe : it must be legal to share the same instance between several threads.
enum SkColorFilter::Flags |
|
virtual |
If the filter can be represented by a 5x4 matrix, this returns true, and sets the matrix appropriately.
If not, this returns false and ignores the parameter.
|
virtual |
If the filter can be represented by a source color plus Mode, this returns true, and sets (if not NULL) the color and mode appropriately.
If not, this returns false and ignores the parameters.
|
virtual |
If the filter can be represented by per-component table, return true, and if table is not null, copy the bitmap containing the table into it.
The table bitmap will be in SkBitmap::kA8_Config. Each row corresponding to each component in ARGB order. e.g. row[0] == alpha, row[1] == red, etc. To transform a color, you (logically) perform the following:
a' = *table.getAddr8(a, 0); r' = *table.getAddr8(r, 1); g' = *table.getAddr8(g, 2); b' = *table.getAddr8(b, 3);
The original component value is the horizontal index for a given row, and the stored value at that index is the new value for that component.
|
virtual |
A subclass may implement this factory function to work with the GPU backend.
It returns a GrFragmentProcessor that implemets the color filter in GPU shader code.
The fragment processor receives a premultiplied input color and produces a premultiplied output color.
A null return indicates that the color filter isn't implemented for the GPU backend.
Apply this colorfilter to the specified SkColor.
This routine handles converting to SkPMColor, calling the filter, and then converting back to SkColor. This method is not virtual, but will call filterSpan() which is virtual.
|
pure virtual |
Called with a scanline of colors, as if there was a shader installed.
The implementation writes out its filtered version into result[]. Note: shader and result may be the same buffer.
src | array of colors, possibly generated by a shader |
count | the number of entries in the src[] and result[] arrays |
result | written by the filter |
Implemented in SkLumaColorFilter.
|
inlinevirtual |
Returns the flags for this filter.
Override in subclasses to return custom flags.
|
inlinevirtual |
If this subclass can optimally createa composition with the inner filter, return it as a new filter (which the caller must unref() when it is done).
If no such optimization is known, return NULL.
e.g. result(color) == this_filter(inner(color))
|
static |
Construct a colorfilter whose effect is to first apply the inner filter and then apply the outer filter to the result of the inner's.
The reference counts for outer and inner are incremented.
Due to internal limits, it is possible that this will return NULL, so the caller must always check.
|
static |
Construct a color filter that transforms a color by a 4x5 matrix.
The matrix is in row- major order and the translation column is specified in unnormalized, 0...255, space.
|
static |
Create a colorfilter that uses the specified color and mode.
If the Mode is DST, this function will return NULL (since that mode will have no effect on the result).
c | The source color used with the specified mode |
mode | The blend that is applied to each color in the colorfilter's filterSpan[16,32] methods |