2 * Copyright 2006 The Android Open Source Project
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkAvoidXfermode_DEFINED
9 #define SkAvoidXfermode_DEFINED
11 #include "SkXfermode.h"
13 /** \class SkAvoidXfermode
15 This xfermode will draw the src everywhere except on top of the specified
18 class SK_API SkAvoidXfermode : public SkXfermode {
21 kAvoidColor_Mode, //!< draw everywhere except on the opColor
22 kTargetColor_Mode //!< draw only on top of the opColor
25 /** This xfermode draws, or doesn't draw, based on the destination's
26 distance from an op-color.
28 There are two modes, and each mode interprets a tolerance value.
30 Avoid: In this mode, drawing is allowed only on destination pixels that
31 are different from the op-color.
32 Tolerance near 0: avoid any colors even remotely similar to the op-color
33 Tolerance near 255: avoid only colors nearly identical to the op-color
35 Target: In this mode, drawing only occurs on destination pixels that
36 are similar to the op-color
37 Tolerance near 0: draw only on colors that are nearly identical to the op-color
38 Tolerance near 255: draw on any colors even remotely similar to the op-color
40 SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
42 // overrides from SkXfermode
43 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
44 const SkAlpha aa[]) const SK_OVERRIDE;
45 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
46 const SkAlpha aa[]) const SK_OVERRIDE;
47 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
48 const SkAlpha aa[]) const SK_OVERRIDE;
50 SK_DEVELOPER_TO_STRING()
51 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAvoidXfermode)
54 SkAvoidXfermode(SkReadBuffer&);
55 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
59 uint32_t fDistMul; // x.14
62 typedef SkXfermode INHERITED;