diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkColorFilter.h | 12 | ||||
-rw-r--r-- | include/core/SkXfermode.h | 25 | ||||
-rw-r--r-- | include/effects/SkAvoidXfermode.h | 14 | ||||
-rw-r--r-- | include/effects/SkColorMatrixFilter.h | 17 | ||||
-rw-r--r-- | include/effects/SkPixelXorXfermode.h | 5 |
5 files changed, 40 insertions, 33 deletions
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h index aee60196f6..3e9aee8573 100644 --- a/include/core/SkColorFilter.h +++ b/include/core/SkColorFilter.h @@ -72,8 +72,8 @@ public: * which is virtual. */ SkColor filterColor(SkColor); - - + + /** 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). @@ -103,7 +103,7 @@ public: protected: SkColorFilter() {} SkColorFilter(SkFlattenableReadBuffer& rb) : INHERITED(rb) {} - + private: typedef SkFlattenable INHERITED; }; @@ -123,17 +123,17 @@ public: virtual void shadeSpan16(int x, int y, uint16_t result[], int count); virtual void beginSession(); virtual void endSession(); - + protected: SkFilterShader(SkFlattenableReadBuffer& ); virtual void flatten(SkFlattenableWriteBuffer& ); virtual Factory getFactory() { return CreateProc; } private: - static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { return SkNEW_ARGS(SkFilterShader, (buffer)); } SkShader* fShader; SkColorFilter* fFilter; - + typedef SkShader INHERITED; }; diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h index 0f2efbdbcd..4d46bb919a 100644 --- a/include/core/SkXfermode.h +++ b/include/core/SkXfermode.h @@ -40,7 +40,7 @@ public: const SkAlpha aa[]); virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[]); - + /** Enum of possible coefficients to describe some xfermodes */ enum Coeff { @@ -54,18 +54,18 @@ public: kISA_Coeff, /** inverse src alpha (i.e. 1 - sa) */ kDA_Coeff, /** dst alpha */ kIDA_Coeff, /** inverse dst alpha (i.e. 1 - da) */ - + kCoeffCount }; - + /** If the xfermode can be expressed as an equation using the coefficients in Coeff, then asCoeff() returns true, and sets (if not null) src and dst accordingly. - + result = src_coeff * src_color + dst_coeff * dst_color; - + As examples, here are some of the porterduff coefficients - + MODE SRC_COEFF DST_COEFF clear zero zero src one zero @@ -80,7 +80,7 @@ public: * if the xfermode is NULL, and if so, treats its as kSrcOver_Mode. */ static bool AsCoeff(SkXfermode*, Coeff* src, Coeff* dst); - + /** List of predefined xfermodes. The algebra for the modes uses the following symbols: Sa, Sc - source alpha and color @@ -149,7 +149,7 @@ public: 16bit proc, and this will return NULL. */ static SkXfermodeProc16 GetProc16(Mode mode, SkColor srcColor); - + /** * If the specified mode can be represented by a pair of Coeff, then return * true and set (if not NULL) the corresponding coeffs. If the mode is @@ -162,15 +162,15 @@ public: static bool IsMode(SkXfermode* xfer, Mode* mode) { return AsMode(xfer, mode); } - + protected: SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} - + /** The default implementation of xfer32/xfer16/xferA8 in turn call this method, 1 color at a time (upscaled to a SkPMColor). The default implmentation of this method just returns dst. If performance is important, your subclass should override xfer32/xfer16/xferA8 directly. - + This method will not be called directly by the client, so it need not be implemented if your subclass has overridden xfer32/xfer16/xferA8 */ @@ -213,7 +213,7 @@ protected: private: SkXfermodeProc fProc; - + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { return SkNEW_ARGS(SkProcXfermode, (buffer)); } @@ -221,4 +221,3 @@ private: }; #endif - diff --git a/include/effects/SkAvoidXfermode.h b/include/effects/SkAvoidXfermode.h index 9af4a4b58e..b52e6f52eb 100644 --- a/include/effects/SkAvoidXfermode.h +++ b/include/effects/SkAvoidXfermode.h @@ -33,14 +33,14 @@ public: /** This xfermode draws, or doesn't draw, based on the destination's distance from an op-color. - + There are two modes, and each mode interprets a tolerance value. - + Avoid: In this mode, drawing is allowed only on destination pixels that are different from the op-color. Tolerance near 0: avoid any colors even remotely similar to the op-color Tolerance near 255: avoid only colors nearly identical to the op-color - + Target: In this mode, drawing only occurs on destination pixels that are similar to the op-color Tolerance near 0: draw only on colors that are nearly identical to the op-color @@ -62,6 +62,10 @@ public: virtual Factory getFactory(); virtual void flatten(SkFlattenableWriteBuffer&); + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(SkAvoidXfermode, (buffer)); + } + protected: SkAvoidXfermode(SkFlattenableReadBuffer&); @@ -69,9 +73,9 @@ private: SkColor fOpColor; uint32_t fDistMul; // x.14 Mode fMode; - + static SkFlattenable* Create(SkFlattenableReadBuffer&); - + typedef SkXfermode INHERITED; }; diff --git a/include/effects/SkColorMatrixFilter.h b/include/effects/SkColorMatrixFilter.h index f9194df6db..d8ef81cdec 100644 --- a/include/effects/SkColorMatrixFilter.h +++ b/include/effects/SkColorMatrixFilter.h @@ -25,15 +25,15 @@ public: SkColorMatrixFilter(); explicit SkColorMatrixFilter(const SkColorMatrix&); SkColorMatrixFilter(const SkScalar array[20]); - + void setMatrix(const SkColorMatrix&); void setArray(const SkScalar array[20]); - + // overrides from SkColorFilter virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]); virtual void filterSpan16(const uint16_t src[], int count, uint16_t[]); virtual uint32_t getFlags(); - + // overrides for SkFlattenable virtual void flatten(SkFlattenableWriteBuffer& buffer); @@ -43,14 +43,15 @@ public: int32_t fResult[4]; }; + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer); + protected: // overrides for SkFlattenable virtual Factory getFactory(); - + SkColorMatrixFilter(SkFlattenableReadBuffer& buffer); - + private: - static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer); typedef void (*Proc)(State*, unsigned r, unsigned g, unsigned b, unsigned a); @@ -58,9 +59,9 @@ private: Proc fProc; State fState; uint32_t fFlags; - + void setup(const SkScalar array[20]); - + typedef SkColorFilter INHERITED; }; diff --git a/include/effects/SkPixelXorXfermode.h b/include/effects/SkPixelXorXfermode.h index 369e0e5444..1957c9e706 100644 --- a/include/effects/SkPixelXorXfermode.h +++ b/include/effects/SkPixelXorXfermode.h @@ -32,6 +32,10 @@ public: virtual Factory getFactory(); virtual void flatten(SkFlattenableWriteBuffer&); + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(SkPixelXorXfermode, (buffer)); + } + protected: // override from SkXfermode virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst); @@ -47,4 +51,3 @@ private: }; #endif - |