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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/effects/SkPorterDuff.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     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 SkPorterDuff_DEFINED
    1.12 +#define SkPorterDuff_DEFINED
    1.13 +
    1.14 +#include "SkColor.h"
    1.15 +#include "SkXfermode.h"
    1.16 +
    1.17 +class SkXfermode;
    1.18 +
    1.19 +class SK_API SkPorterDuff {
    1.20 +public:
    1.21 +    /** List of predefined xfermodes. In general, the algebra for the modes
    1.22 +        uses the following symbols:
    1.23 +        Sa, Sc  - source alpha and color
    1.24 +        Da, Dc - destination alpha and color (before compositing)
    1.25 +        [a, c] - Resulting (alpha, color) values
    1.26 +        For these equations, the colors are in premultiplied state.
    1.27 +        If no xfermode is specified, kSrcOver is assumed.
    1.28 +    */
    1.29 +    enum Mode {
    1.30 +        kClear_Mode,    //!< [0, 0]
    1.31 +        kSrc_Mode,      //!< [Sa, Sc]
    1.32 +        kDst_Mode,      //!< [Da, Dc]
    1.33 +        kSrcOver_Mode,  //!< [Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc]
    1.34 +        kDstOver_Mode,  //!< [Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc]
    1.35 +        kSrcIn_Mode,    //!< [Sa * Da, Sc * Da]
    1.36 +        kDstIn_Mode,    //!< [Sa * Da, Sa * Dc]
    1.37 +        kSrcOut_Mode,   //!< [Sa * (1 - Da), Sc * (1 - Da)]
    1.38 +        kDstOut_Mode,   //!< [Da * (1 - Sa), Dc * (1 - Sa)]
    1.39 +        kSrcATop_Mode,  //!< [Da, Sc * Da + (1 - Sa) * Dc]
    1.40 +        kDstATop_Mode,  //!< [Sa, Sa * Dc + Sc * (1 - Da)]
    1.41 +        kXor_Mode,      //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
    1.42 +        kDarken_Mode,   //!< [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + min(Sc, Dc)]
    1.43 +        kLighten_Mode,  //!< [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)]
    1.44 +        kModulate_Mode, //!< [Sa * Da, Sc * Dc] multiplies all components
    1.45 +        kScreen_Mode,   //!< [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc]
    1.46 +        kAdd_Mode,      //!< Saturate(S + D)
    1.47 +#ifdef SK_BUILD_FOR_ANDROID
    1.48 +        kOverlay_Mode,
    1.49 +#endif
    1.50 +
    1.51 +        kModeCount
    1.52 +    };
    1.53 +
    1.54 +    /** Return an SkXfermode object for the specified mode.
    1.55 +    */
    1.56 +    static SkXfermode* CreateXfermode(Mode mode);
    1.57 +
    1.58 +    /** Return a function pointer to a routine that applies the specified
    1.59 +        porter-duff transfer mode.
    1.60 +    */
    1.61 +    static SkXfermodeProc GetXfermodeProc(Mode mode);
    1.62 +
    1.63 +    /** Return a function pointer to a routine that applies the specified
    1.64 +        porter-duff transfer mode and srcColor to a 16bit device color. Note,
    1.65 +        if the mode+srcColor might return a non-opaque color, then there is not
    1.66 +        16bit proc, and this will return NULL.
    1.67 +    */
    1.68 +    static SkXfermodeProc16 GetXfermodeProc16(Mode mode, SkColor srcColor);
    1.69 +
    1.70 +    /** If the specified xfermode advertises itself as one of the porterduff
    1.71 +        modes (via SkXfermode::Coeff), return true and if not null, set mode
    1.72 +        to the corresponding porterduff mode. If it is not recognized as a one,
    1.73 +        return false and ignore the mode parameter.
    1.74 +    */
    1.75 +    static bool IsMode(SkXfermode*, Mode* mode);
    1.76 +
    1.77 +    /** Return the corersponding SkXfermode::Mode
    1.78 +     */
    1.79 +    static SkXfermode::Mode ToXfermodeMode(Mode);
    1.80 +} SK_ATTR_DEPRECATED("use SkXfermode::Mode");
    1.81 +
    1.82 +#endif

mercurial