2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkAvoidXfermode_DEFINED
|
|
|
|
#define SkAvoidXfermode_DEFINED
|
|
|
|
|
|
|
|
#include "SkXfermode.h"
|
|
|
|
|
|
|
|
/** \class SkAvoidXfermode
|
|
|
|
|
|
|
|
This xfermode will draw the src everywhere except on top of the specified
|
|
|
|
color.
|
|
|
|
*/
|
2012-10-12 14:41:39 +00:00
|
|
|
class SK_API SkAvoidXfermode : public SkXfermode {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
kAvoidColor_Mode, //!< draw everywhere except on the opColor
|
|
|
|
kTargetColor_Mode //!< draw only on top of the opColor
|
|
|
|
};
|
|
|
|
|
2009-11-09 16:01:36 +00:00
|
|
|
/** This xfermode draws, or doesn't draw, based on the destination's
|
|
|
|
distance from an op-color.
|
2011-04-27 14:09:52 +00:00
|
|
|
|
2009-11-09 16:01:36 +00:00
|
|
|
There are two modes, and each mode interprets a tolerance value.
|
2011-04-27 14:09:52 +00:00
|
|
|
|
2009-11-09 16:01:36 +00:00
|
|
|
Avoid: In this mode, drawing is allowed only on destination pixels that
|
|
|
|
are different from the op-color.
|
2010-02-18 19:32:03 +00:00
|
|
|
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
|
2011-04-27 14:09:52 +00:00
|
|
|
|
2009-11-09 16:01:36 +00:00
|
|
|
Target: In this mode, drawing only occurs on destination pixels that
|
|
|
|
are similar to the op-color
|
2010-02-18 19:32:03 +00:00
|
|
|
Tolerance near 0: draw only on colors that are nearly identical to the op-color
|
|
|
|
Tolerance near 255: draw on any colors even remotely similar to the op-color
|
2009-11-09 16:01:36 +00:00
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
|
|
|
|
|
|
|
|
// overrides from SkXfermode
|
|
|
|
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
|
2012-12-17 19:55:24 +00:00
|
|
|
const SkAlpha aa[]) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
|
2012-12-17 19:55:24 +00:00
|
|
|
const SkAlpha aa[]) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void xfer4444(uint16_t dst[], const SkPMColor src[], int count,
|
2012-12-17 19:55:24 +00:00
|
|
|
const SkAlpha aa[]) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
|
2012-12-17 19:55:24 +00:00
|
|
|
const SkAlpha aa[]) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-03-26 17:57:35 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAvoidXfermode)
|
2011-04-27 14:09:52 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
|
|
|
SkAvoidXfermode(SkFlattenableReadBuffer&);
|
2012-03-29 15:18:04 +00:00
|
|
|
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkColor fOpColor;
|
|
|
|
uint32_t fDistMul; // x.14
|
|
|
|
Mode fMode;
|
2011-04-27 14:09:52 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
typedef SkXfermode INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|