Skia
2DGraphicsLibrary
|
SkXfermode is the base class for objects that are called to implement custom "transfer-modes" in the drawing pipeline. More...
#include <SkXfermode.h>
Public Types | |
enum | Coeff { kZero_Coeff, kOne_Coeff, kSC_Coeff, kISC_Coeff, kDC_Coeff, kIDC_Coeff, kSA_Coeff, kISA_Coeff, kDA_Coeff, kIDA_Coeff, kCoeffCount } |
Enum of possible coefficients to describe some xfermodes. More... | |
enum | Mode { kClear_Mode, kSrc_Mode, kDst_Mode, kSrcOver_Mode, kDstOver_Mode, kSrcIn_Mode, kDstIn_Mode, kSrcOut_Mode, kDstOut_Mode, kSrcATop_Mode, kDstATop_Mode, kXor_Mode, kPlus_Mode, kModulate_Mode, kScreen_Mode, kLastCoeffMode = kScreen_Mode, kOverlay_Mode, kDarken_Mode, kLighten_Mode, kColorDodge_Mode, kColorBurn_Mode, kHardLight_Mode, kSoftLight_Mode, kDifference_Mode, kExclusion_Mode, kMultiply_Mode, kLastSeparableMode = kMultiply_Mode, kHue_Mode, kSaturation_Mode, kColor_Mode, kLuminosity_Mode, kLastMode = kLuminosity_Mode } |
List of predefined xfermodes. More... | |
enum | SrcColorOpacity { kOpaque_SrcColorOpacity = 0, kTransparentBlack_SrcColorOpacity = 1, kTransparentAlpha_SrcColorOpacity = 2, kUnknown_SrcColorOpacity = 3 } |
enum | D32Flags { kSrcIsOpaque_D32Flag = 1 << 0, kSrcIsSingle_D32Flag = 1 << 1, kDstIsSRGB_D32Flag = 1 << 2 } |
enum | F16Flags { kSrcIsOpaque_F16Flag = 1 << 0, kSrcIsSingle_F16Flag = 1 << 1 } |
enum | LCDFlags { kSrcIsOpaque_LCDFlag = 1 << 0, kSrcIsSingle_LCDFlag = 1 << 1, kDstIsSRGB_LCDFlag = 1 << 2 } |
typedef void(* | D32Proc )(const SkXfermode *, uint32_t dst[], const SkPM4f src[], int count, const SkAlpha coverage[]) |
typedef void(* | F16Proc )(const SkXfermode *, uint64_t dst[], const SkPM4f src[], int count, const SkAlpha coverage[]) |
typedef void(* | LCD32Proc )(uint32_t *dst, const SkPM4f *src, int count, const uint16_t lcd[]) |
typedef void(* | LCDF16Proc )(uint64_t *dst, const SkPM4f *src, int count, const uint16_t lcd[]) |
Public Types inherited from SkFlattenable | |
enum | Type { kSkColorFilter_Type, kSkDrawable_Type, kSkDrawLooper_Type, kSkImageFilter_Type, kSkMaskFilter_Type, kSkPathEffect_Type, kSkPixelRef_Type, kSkRasterizer_Type, kSkShader_Type, kSkUnused_Type, kSkXfermode_Type, kSkNormalSource_Type } |
typedef sk_sp< SkFlattenable >(* | Factory )(SkReadBuffer &) |
Public Member Functions | |
virtual void | xfer32 (SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]) const |
virtual void | xfer16 (uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[]) const |
virtual void | xferA8 (SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[]) const |
virtual bool | asMode (Mode *mode) const |
If the xfermode is one of the modes in the Mode enum, then asMode() returns true and sets (if not null) mode accordingly. More... | |
SkBlendMode | blend () const |
virtual SkXfermodeProc4f | getProc4f () const |
bool | appendStages (SkRasterPipeline *) const |
virtual bool | supportsCoverageAsAlpha () const |
Returns whether or not the xfer mode can support treating coverage as alpha. | |
virtual bool | isOpaque (SrcColorOpacity opacityType) const |
Returns whether or not the result of the draw with the xfer mode will be opaque or not. More... | |
virtual sk_sp < GrFragmentProcessor > | makeFragmentProcessorForImageFilter (sk_sp< GrFragmentProcessor > dst) const |
Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentProcessor. More... | |
virtual sk_sp< GrXPFactory > | asXPFactory () const |
A subclass must implement this factory function to work with the GPU backend. More... | |
virtual bool | isArithmetic (SkArithmeticParams *) 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 const char * | ModeName (Mode) |
Gets the name of the Mode as a string. | |
static const char * | ModeName (SkBlendMode mode) |
static bool | AsMode (const SkXfermode *, Mode *mode) |
The same as calling xfermode->asMode(mode), except that this also checks if the xfermode is NULL, and if so, treats it as kSrcOver_Mode. | |
static bool | AsMode (const sk_sp< SkXfermode > &xfer, Mode *mode) |
static bool | IsMode (const SkXfermode *xfer, Mode mode) |
Returns true if the xfermode claims to be the specified Mode. More... | |
static bool | IsMode (const sk_sp< SkXfermode > &xfer, Mode mode) |
static sk_sp< SkXfermode > | Make (Mode) |
Return an SkXfermode object for the specified mode. | |
static SkXfermode * | Peek (SkBlendMode mode) |
Skia maintains global xfermode objects corresponding to each BlendMode. More... | |
static sk_sp< SkXfermode > | Make (SkBlendMode bm) |
static SkXfermodeProc | GetProc (Mode mode) |
Return a function pointer to a routine that applies the specified porter-duff transfer mode. | |
static SkXfermodeProc4f | GetProc4f (Mode) |
static bool | ModeAsCoeff (Mode mode, Coeff *src, Coeff *dst) |
If the specified mode can be represented by a pair of Coeff, then return true and set (if not NULL) the corresponding coeffs. More... | |
static bool | SupportsCoverageAsAlpha (const SkXfermode *xfer) |
The same as calling xfermode->supportsCoverageAsAlpha(), except that this also checks if the xfermode is NULL, and if so, treats it as kSrcOver_Mode. | |
static bool | SupportsCoverageAsAlpha (const sk_sp< SkXfermode > &xfer) |
static bool | IsOpaque (const SkXfermode *xfer, SrcColorOpacity opacityType) |
The same as calling xfermode->isOpaque(...), except that this also checks if the xfermode is NULL, and if so, treats it as kSrcOver_Mode. | |
static bool | IsOpaque (const sk_sp< SkXfermode > &xfer, SrcColorOpacity opacityType) |
static bool | IsOpaque (SkBlendMode, SrcColorOpacity) |
static D32Proc | GetD32Proc (SkXfermode *, uint32_t flags) |
static D32Proc | GetD32Proc (const sk_sp< SkXfermode > &xfer, uint32_t flags) |
static F16Proc | GetF16Proc (SkXfermode *, uint32_t flags) |
static F16Proc | GetF16Proc (const sk_sp< SkXfermode > &xfer, uint32_t flags) |
static LCD32Proc | GetLCD32Proc (uint32_t flags) |
static LCDF16Proc | GetLCDF16Proc (uint32_t) |
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 | |
virtual SkPMColor | xferColor (SkPMColor src, SkPMColor dst) const |
The default implementation of xfer32/xfer16/xferA8 in turn call this method, 1 color at a time (upscaled to a SkPMColor). More... | |
virtual D32Proc | onGetD32Proc (uint32_t flags) const |
virtual F16Proc | onGetF16Proc (uint32_t flags) const |
virtual bool | onAppendStages (SkRasterPipeline *) 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 | |
enum | { kModeCount = kLastMode + 1 } |
typedef SkFlattenable | INHERITED |
SkXfermode is the base class for objects that are called to implement custom "transfer-modes" in the drawing pipeline.
The static function Create(Modes) can be called to return an instance of any of the predefined subclasses as specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, then objects drawn with that paint have the xfermode applied.
All subclasses are required to be reentrant-safe : it must be legal to share the same instance between several threads.
enum SkXfermode::Coeff |
Enum of possible coefficients to describe some xfermodes.
enum SkXfermode::Mode |
List of predefined xfermodes.
The algebra for the modes uses the following symbols: Sa, Sc - source alpha and color Da, Dc - destination alpha and color (before compositing) [a, c] - Resulting (alpha, color) values For these equations, the colors are in premultiplied state. If no xfermode is specified, kSrcOver is assumed. The modes are ordered by those that can be expressed as a pair of Coeffs, followed by those that aren't Coeffs but have separable r,g,b computations, and finally those that are not separable.
|
virtual |
If the xfermode is one of the modes in the Mode enum, then asMode() returns true and sets (if not null) mode accordingly.
Otherwise it returns false and ignores the mode parameter.
|
virtual |
A subclass must implement this factory function to work with the GPU backend.
The xfermode will return a factory for which the caller will get a ref. It is up to the caller to install it. XferProcessors cannot use a background texture.
|
static |
Returns true if the xfermode claims to be the specified Mode.
This works correctly even if the xfermode is NULL (which equates to kSrcOver.) Thus you can say this without checking for a null...
If (SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kDstOver_Mode)) { ... }
|
virtual |
Returns whether or not the result of the draw with the xfer mode will be opaque or not.
The input to this call is an enum describing known information about the opacity of the src color that will be given to the xfer mode.
|
virtual |
Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentProcessor.
The input to the returned FP is the src color. The dst color is provided by the dst param which becomes a child FP of the returned FP. It is legal for the function to return a null output. This indicates that the output of the blend is simply the src color.
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 not representable as a pair of Coeffs, return false and ignore the src and dst parameters.
|
inlinestatic |
Skia maintains global xfermode objects corresponding to each BlendMode.
This returns a ptr to that global xfermode (or null if the mode is srcover). Thus the caller may use the returned ptr, but it should leave its refcnt untouched.
The default implementation of xfer32/xfer16/xferA8 in turn call this method, 1 color at a time (upscaled to a SkPMColor).
The default implementation 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