gfx/skia/trunk/include/effects/SkAvoidXfermode.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/effects/SkAvoidXfermode.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +/*
     1.5 + * Copyright 2006 The Android Open Source Project
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkAvoidXfermode_DEFINED
    1.12 +#define SkAvoidXfermode_DEFINED
    1.13 +
    1.14 +#include "SkXfermode.h"
    1.15 +
    1.16 +/** \class SkAvoidXfermode
    1.17 +
    1.18 +    This xfermode will draw the src everywhere except on top of the specified
    1.19 +    color.
    1.20 +*/
    1.21 +class SK_API SkAvoidXfermode : public SkXfermode {
    1.22 +public:
    1.23 +    enum Mode {
    1.24 +        kAvoidColor_Mode,   //!< draw everywhere except on the opColor
    1.25 +        kTargetColor_Mode   //!< draw only on top of the opColor
    1.26 +    };
    1.27 +
    1.28 +    /** This xfermode draws, or doesn't draw, based on the destination's
    1.29 +        distance from an op-color.
    1.30 +
    1.31 +        There are two modes, and each mode interprets a tolerance value.
    1.32 +
    1.33 +        Avoid: In this mode, drawing is allowed only on destination pixels that
    1.34 +               are different from the op-color.
    1.35 +               Tolerance near 0: avoid any colors even remotely similar to the op-color
    1.36 +               Tolerance near 255: avoid only colors nearly identical to the op-color
    1.37 +
    1.38 +        Target: In this mode, drawing only occurs on destination pixels that
    1.39 +                are similar to the op-color
    1.40 +                Tolerance near 0: draw only on colors that are nearly identical to the op-color
    1.41 +                Tolerance near 255: draw on any colors even remotely similar to the op-color
    1.42 +     */
    1.43 +    static SkAvoidXfermode* Create(SkColor opColor, U8CPU tolerance, Mode mode) {
    1.44 +        return SkNEW_ARGS(SkAvoidXfermode, (opColor, tolerance, mode));
    1.45 +    }
    1.46 +
    1.47 +    // overrides from SkXfermode
    1.48 +    virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
    1.49 +                        const SkAlpha aa[]) const SK_OVERRIDE;
    1.50 +    virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
    1.51 +                        const SkAlpha aa[]) const SK_OVERRIDE;
    1.52 +    virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
    1.53 +                        const SkAlpha aa[]) const SK_OVERRIDE;
    1.54 +
    1.55 +    SK_TO_STRING_OVERRIDE()
    1.56 +    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAvoidXfermode)
    1.57 +
    1.58 +protected:
    1.59 +    SkAvoidXfermode(SkReadBuffer&);
    1.60 +    virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
    1.61 +
    1.62 +#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
    1.63 +public:
    1.64 +#endif
    1.65 +    SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
    1.66 +
    1.67 +private:
    1.68 +    SkColor     fOpColor;
    1.69 +    uint32_t    fDistMul;   // x.14
    1.70 +    Mode        fMode;
    1.71 +
    1.72 +    typedef SkXfermode INHERITED;
    1.73 +};
    1.74 +
    1.75 +#endif

mercurial