SkXfermode Class Reference

#include <SkXfermode.h>

Inherits SkFlattenable.

Inherited by SkAvoidXfermode, SkPixelXorXfermode, and SkProcXfermode.

Collaboration diagram for SkXfermode:
Collaboration graph
[legend]

List of all members.

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  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, kMultiply_Mode, kScreen_Mode, kOverlay_Mode,
  kDarken_Mode, kLighten_Mode, kColorDodge_Mode, kColorBurn_Mode,
  kHardLight_Mode, kSoftLight_Mode, kDifference_Mode, kExclusion_Mode,
  kLastMode = kExclusion_Mode
}

Public Member Functions

 SkXfermode ()
virtual void xfer32 (SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[])
virtual void xfer16 (uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[])
virtual void xfer4444 (uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[])
virtual void xferA8 (SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[])
virtual bool asCoeff (Coeff *src, Coeff *dst)

Static Public Member Functions

static SkXfermodeCreate (Mode mode)
static SkXfermodeProc GetProc (Mode mode)
static SkXfermodeProc16 GetProc16 (Mode mode, SkColor srcColor)
static bool IsMode (SkXfermode *, Mode *mode)

Protected Member Functions

 SkXfermode (SkFlattenableReadBuffer &rb)
virtual SkPMColor xferColor (SkPMColor src, SkPMColor dst)

Detailed Description

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.

Definition at line 31 of file SkXfermode.h.


Member Enumeration Documentation

Enum of possible coefficients to describe some xfermodes

Enumerator:
kZero_Coeff 
kOne_Coeff 

0

kSC_Coeff 

1

kISC_Coeff 

src color

kDC_Coeff 

inverse src color (i.e. 1 - sc)

kIDC_Coeff 

dst color

kSA_Coeff 

inverse dst color (i.e. 1 - dc)

kISA_Coeff 

src alpha

kDA_Coeff 

inverse src alpha (i.e. 1 - sa)

kIDA_Coeff 

dst alpha

kCoeffCount 

inverse dst alpha (i.e. 1 - da)

Definition at line 46 of file SkXfermode.h.

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.

Enumerator:
kClear_Mode 

[0, 0]

kSrc_Mode 

[Sa, Sc]

kDst_Mode 

[Da, Dc]

kSrcOver_Mode 

[Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc]

kDstOver_Mode 

[Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc]

kSrcIn_Mode 

[Sa * Da, Sc * Da]

kDstIn_Mode 

[Sa * Da, Sa * Dc]

kSrcOut_Mode 

[Sa * (1 - Da), Sc * (1 - Da)]

kDstOut_Mode 

[Da * (1 - Sa), Dc * (1 - Sa)]

kSrcATop_Mode 

[Da, Sc * Da + (1 - Sa) * Dc]

kDstATop_Mode 

[Sa, Sa * Dc + Sc * (1 - Da)]

kXor_Mode 

[Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]

kPlus_Mode 
kMultiply_Mode 
kScreen_Mode 
kOverlay_Mode 
kDarken_Mode 
kLighten_Mode 
kColorDodge_Mode 
kColorBurn_Mode 
kHardLight_Mode 
kSoftLight_Mode 
kDifference_Mode 
kExclusion_Mode 
kLastMode 

Reimplemented in SkAvoidXfermode.

Definition at line 86 of file SkXfermode.h.


Constructor & Destructor Documentation

SkXfermode::SkXfermode (  )  [inline]

Definition at line 33 of file SkXfermode.h.

SkXfermode::SkXfermode ( SkFlattenableReadBuffer rb  )  [inline, protected]

Definition at line 142 of file SkXfermode.h.


Member Function Documentation

virtual bool SkXfermode::asCoeff ( Coeff src,
Coeff dst 
) [virtual]

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 dst zero one srcover one isa dstover ida one

static SkXfermode* SkXfermode::Create ( Mode  mode  )  [static]

Return an SkXfermode object for the specified mode.

static SkXfermodeProc SkXfermode::GetProc ( Mode  mode  )  [static]

Return a function pointer to a routine that applies the specified porter-duff transfer mode.

static SkXfermodeProc16 SkXfermode::GetProc16 ( Mode  mode,
SkColor  srcColor 
) [static]

Return a function pointer to a routine that applies the specified porter-duff transfer mode and srcColor to a 16bit device color. Note, if the mode+srcColor might return a non-opaque color, then there is not 16bit proc, and this will return NULL.

static bool SkXfermode::IsMode ( SkXfermode ,
Mode mode 
) [static]

If the specified xfermode advertises itself as one of the porterduff modes (via SkXfermode::Coeff), return true and if not null, set mode to the corresponding porterduff mode. If it is not recognized as a one, return false and ignore the mode parameter.

virtual void SkXfermode::xfer16 ( uint16_t  dst[],
const SkPMColor  src[],
int  count,
const SkAlpha  aa[] 
) [virtual]

Reimplemented in SkProcXfermode, and SkAvoidXfermode.

virtual void SkXfermode::xfer32 ( SkPMColor  dst[],
const SkPMColor  src[],
int  count,
const SkAlpha  aa[] 
) [virtual]

Reimplemented in SkProcXfermode, and SkAvoidXfermode.

virtual void SkXfermode::xfer4444 ( uint16_t  dst[],
const SkPMColor  src[],
int  count,
const SkAlpha  aa[] 
) [virtual]

Reimplemented in SkProcXfermode, and SkAvoidXfermode.

virtual void SkXfermode::xferA8 ( SkAlpha  dst[],
const SkPMColor  src[],
int  count,
const SkAlpha  aa[] 
) [virtual]

Reimplemented in SkProcXfermode, and SkAvoidXfermode.

virtual SkPMColor SkXfermode::xferColor ( SkPMColor  src,
SkPMColor  dst 
) [protected, virtual]

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

Reimplemented in SkPixelXorXfermode.


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

Generated on Tue Oct 20 11:03:42 2009 for Skia by  doxygen 1.6.1