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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright 2006 The Android Open Source Project
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkPorterDuff_DEFINED
michael@0 9 #define SkPorterDuff_DEFINED
michael@0 10
michael@0 11 #include "SkColor.h"
michael@0 12 #include "SkXfermode.h"
michael@0 13
michael@0 14 class SkXfermode;
michael@0 15
michael@0 16 class SK_API SkPorterDuff {
michael@0 17 public:
michael@0 18 /** List of predefined xfermodes. In general, the algebra for the modes
michael@0 19 uses the following symbols:
michael@0 20 Sa, Sc - source alpha and color
michael@0 21 Da, Dc - destination alpha and color (before compositing)
michael@0 22 [a, c] - Resulting (alpha, color) values
michael@0 23 For these equations, the colors are in premultiplied state.
michael@0 24 If no xfermode is specified, kSrcOver is assumed.
michael@0 25 */
michael@0 26 enum Mode {
michael@0 27 kClear_Mode, //!< [0, 0]
michael@0 28 kSrc_Mode, //!< [Sa, Sc]
michael@0 29 kDst_Mode, //!< [Da, Dc]
michael@0 30 kSrcOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc]
michael@0 31 kDstOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc]
michael@0 32 kSrcIn_Mode, //!< [Sa * Da, Sc * Da]
michael@0 33 kDstIn_Mode, //!< [Sa * Da, Sa * Dc]
michael@0 34 kSrcOut_Mode, //!< [Sa * (1 - Da), Sc * (1 - Da)]
michael@0 35 kDstOut_Mode, //!< [Da * (1 - Sa), Dc * (1 - Sa)]
michael@0 36 kSrcATop_Mode, //!< [Da, Sc * Da + (1 - Sa) * Dc]
michael@0 37 kDstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)]
michael@0 38 kXor_Mode, //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
michael@0 39 kDarken_Mode, //!< [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + min(Sc, Dc)]
michael@0 40 kLighten_Mode, //!< [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)]
michael@0 41 kModulate_Mode, //!< [Sa * Da, Sc * Dc] multiplies all components
michael@0 42 kScreen_Mode, //!< [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc]
michael@0 43 kAdd_Mode, //!< Saturate(S + D)
michael@0 44 #ifdef SK_BUILD_FOR_ANDROID
michael@0 45 kOverlay_Mode,
michael@0 46 #endif
michael@0 47
michael@0 48 kModeCount
michael@0 49 };
michael@0 50
michael@0 51 /** Return an SkXfermode object for the specified mode.
michael@0 52 */
michael@0 53 static SkXfermode* CreateXfermode(Mode mode);
michael@0 54
michael@0 55 /** Return a function pointer to a routine that applies the specified
michael@0 56 porter-duff transfer mode.
michael@0 57 */
michael@0 58 static SkXfermodeProc GetXfermodeProc(Mode mode);
michael@0 59
michael@0 60 /** Return a function pointer to a routine that applies the specified
michael@0 61 porter-duff transfer mode and srcColor to a 16bit device color. Note,
michael@0 62 if the mode+srcColor might return a non-opaque color, then there is not
michael@0 63 16bit proc, and this will return NULL.
michael@0 64 */
michael@0 65 static SkXfermodeProc16 GetXfermodeProc16(Mode mode, SkColor srcColor);
michael@0 66
michael@0 67 /** If the specified xfermode advertises itself as one of the porterduff
michael@0 68 modes (via SkXfermode::Coeff), return true and if not null, set mode
michael@0 69 to the corresponding porterduff mode. If it is not recognized as a one,
michael@0 70 return false and ignore the mode parameter.
michael@0 71 */
michael@0 72 static bool IsMode(SkXfermode*, Mode* mode);
michael@0 73
michael@0 74 /** Return the corersponding SkXfermode::Mode
michael@0 75 */
michael@0 76 static SkXfermode::Mode ToXfermodeMode(Mode);
michael@0 77 } SK_ATTR_DEPRECATED("use SkXfermode::Mode");
michael@0 78
michael@0 79 #endif

mercurial