aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/graphics/SkXfermode.h
blob: 9a6faaded034c2191d82aac801e27356d3148a87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef SkXfermode_DEFINED
#define SkXfermode_DEFINED

#include "SkFlattenable.h"
#include "SkColor.h"

/**	\class SkXfermode

	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.
*/
class SkXfermode : public SkFlattenable {
public:
    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 xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
    
protected:
    SkXfermode(SkRBuffer&) {}

private:
    typedef SkFlattenable INHERITED;
};

////////////////////////////////////////////////////////////////////////////////

/** \class SkProcXfermode

    SkProcXfermode is a xfermode that applies the specified proc to its colors.
    This class is not exported to java.
*/
class SkProcXfermode : public SkXfermode {
public:
	SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}

	// overrides from 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 xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[]);

    // overrides from SkFlattenable
	virtual Factory	getFactory();
	virtual void	flatten(SkWBuffer&);

protected:
    SkProcXfermode(SkRBuffer&);

private:
	SkXfermodeProc	fProc;
    
    static SkFlattenable* CreateProc(SkRBuffer&);

    typedef SkXfermode INHERITED;
};

#endif