| 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkBlendMode_DEFINED |
| 9 | #define SkBlendMode_DEFINED |
| 10 | |
| 11 | #include "include/core/SkTypes.h" |
| 12 | |
| 13 | enum class SkBlendMode { |
| 14 | kClear, //!< replaces destination with zero: fully transparent |
| 15 | kSrc, //!< replaces destination |
| 16 | kDst, //!< preserves destination |
| 17 | kSrcOver, //!< source over destination |
| 18 | kDstOver, //!< destination over source |
| 19 | kSrcIn, //!< source trimmed inside destination |
| 20 | kDstIn, //!< destination trimmed by source |
| 21 | kSrcOut, //!< source trimmed outside destination |
| 22 | kDstOut, //!< destination trimmed outside source |
| 23 | kSrcATop, //!< source inside destination blended with destination |
| 24 | kDstATop, //!< destination inside source blended with source |
| 25 | kXor, //!< each of source and destination trimmed outside the other |
| 26 | kPlus, //!< sum of colors |
| 27 | kModulate, //!< product of premultiplied colors; darkens destination |
| 28 | kScreen, //!< multiply inverse of pixels, inverting result; brightens destination |
| 29 | kLastCoeffMode = kScreen, //!< last porter duff blend mode |
| 30 | kOverlay, //!< multiply or screen, depending on destination |
| 31 | kDarken, //!< darker of source and destination |
| 32 | kLighten, //!< lighter of source and destination |
| 33 | kColorDodge, //!< brighten destination to reflect source |
| 34 | kColorBurn, //!< darken destination to reflect source |
| 35 | kHardLight, //!< multiply or screen, depending on source |
| 36 | kSoftLight, //!< lighten or darken, depending on source |
| 37 | kDifference, //!< subtract darker from lighter with higher contrast |
| 38 | kExclusion, //!< subtract darker from lighter with lower contrast |
| 39 | kMultiply, //!< multiply source with destination, darkening image |
| 40 | kLastSeparableMode = kMultiply, //!< last blend mode operating separately on components |
| 41 | kHue, //!< hue of source with saturation and luminosity of destination |
| 42 | kSaturation, //!< saturation of source with hue and luminosity of destination |
| 43 | kColor, //!< hue and saturation of source with luminosity of destination |
| 44 | kLuminosity, //!< luminosity of source with hue and saturation of destination |
| 45 | kLastMode = kLuminosity, //!< last valid value |
| 46 | }; |
| 47 | |
| 48 | /** |
| 49 | * For Porter-Duff SkBlendModes (those <= kLastCoeffMode), these coefficients describe the blend |
| 50 | * equation used. Coefficient-based blend modes specify an equation: |
| 51 | * ('dstCoeff' * dst + 'srcCoeff' * src), where the coefficient values are constants, functions of |
| 52 | * the src or dst alpha, or functions of the src or dst color. |
| 53 | */ |
| 54 | enum class SkBlendModeCoeff { |
| 55 | kZero, /** 0 */ |
| 56 | kOne, /** 1 */ |
| 57 | kSC, /** src color */ |
| 58 | kISC, /** inverse src color (i.e. 1 - sc) */ |
| 59 | kDC, /** dst color */ |
| 60 | kIDC, /** inverse dst color (i.e. 1 - dc) */ |
| 61 | kSA, /** src alpha */ |
| 62 | kISA, /** inverse src alpha (i.e. 1 - sa) */ |
| 63 | kDA, /** dst alpha */ |
| 64 | kIDA, /** inverse dst alpha (i.e. 1 - da) */ |
| 65 | |
| 66 | kCoeffCount |
| 67 | }; |
| 68 | |
| 69 | /** |
| 70 | * Returns true if 'mode' is a coefficient-based blend mode (<= kLastCoeffMode). If true is |
| 71 | * returned, the mode's src and dst coefficient functions are set in 'src' and 'dst'. |
| 72 | */ |
| 73 | SK_API bool SkBlendMode_AsCoeff(SkBlendMode mode, SkBlendModeCoeff* src, SkBlendModeCoeff* dst); |
| 74 | |
| 75 | |
| 76 | /** Returns name of blendMode as null-terminated C string. |
| 77 | |
| 78 | @return C string |
| 79 | */ |
| 80 | SK_API const char* SkBlendMode_Name(SkBlendMode blendMode); |
| 81 | |
| 82 | #endif |
| 83 | |