epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef SkXfermode_DEFINED |
| 11 | #define SkXfermode_DEFINED |
| 12 | |
| 13 | #include "SkFlattenable.h" |
| 14 | #include "SkColor.h" |
| 15 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 16 | class GrFragmentProcessor; |
senorblanco@chromium.org | 86fc266 | 2013-05-31 17:49:12 +0000 | [diff] [blame] | 17 | class GrTexture; |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 18 | class GrXPFactory; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 19 | class SkString; |
| 20 | |
reed | dd9ffea | 2016-02-18 12:39:14 -0800 | [diff] [blame] | 21 | struct SkPM4f; |
| 22 | typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst); |
| 23 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | /** \class SkXfermode |
reed@google.com | fb6deed | 2013-10-10 17:35:58 +0000 | [diff] [blame] | 25 | * |
| 26 | * SkXfermode is the base class for objects that are called to implement custom |
| 27 | * "transfer-modes" in the drawing pipeline. The static function Create(Modes) |
| 28 | * can be called to return an instance of any of the predefined subclasses as |
| 29 | * specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, |
| 30 | * then objects drawn with that paint have the xfermode applied. |
| 31 | * |
| 32 | * All subclasses are required to be reentrant-safe : it must be legal to share |
| 33 | * the same instance between several threads. |
| 34 | */ |
ctguil@chromium.org | 7ffb1b2 | 2011-03-15 21:27:08 +0000 | [diff] [blame] | 35 | class SK_API SkXfermode : public SkFlattenable { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 36 | public: |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, |
reed@google.com | 30da745 | 2012-12-17 19:55:24 +0000 | [diff] [blame] | 38 | const SkAlpha aa[]) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 39 | virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, |
reed@google.com | 30da745 | 2012-12-17 19:55:24 +0000 | [diff] [blame] | 40 | const SkAlpha aa[]) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 41 | virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, |
reed@google.com | 30da745 | 2012-12-17 19:55:24 +0000 | [diff] [blame] | 42 | const SkAlpha aa[]) const; |
tomhudson@google.com | 1447c6f | 2011-04-27 14:09:52 +0000 | [diff] [blame] | 43 | |
reed@android.com | d252db0 | 2009-04-01 18:31:44 +0000 | [diff] [blame] | 44 | /** Enum of possible coefficients to describe some xfermodes |
| 45 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 46 | enum Coeff { |
reed@android.com | d252db0 | 2009-04-01 18:31:44 +0000 | [diff] [blame] | 47 | kZero_Coeff, /** 0 */ |
| 48 | kOne_Coeff, /** 1 */ |
| 49 | kSC_Coeff, /** src color */ |
| 50 | kISC_Coeff, /** inverse src color (i.e. 1 - sc) */ |
| 51 | kDC_Coeff, /** dst color */ |
| 52 | kIDC_Coeff, /** inverse dst color (i.e. 1 - dc) */ |
| 53 | kSA_Coeff, /** src alpha */ |
| 54 | kISA_Coeff, /** inverse src alpha (i.e. 1 - sa) */ |
| 55 | kDA_Coeff, /** dst alpha */ |
| 56 | kIDA_Coeff, /** inverse dst alpha (i.e. 1 - da) */ |
tomhudson@google.com | 1447c6f | 2011-04-27 14:09:52 +0000 | [diff] [blame] | 57 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 58 | kCoeffCount |
| 59 | }; |
tomhudson@google.com | 1447c6f | 2011-04-27 14:09:52 +0000 | [diff] [blame] | 60 | |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 61 | /** List of predefined xfermodes. |
| 62 | The algebra for the modes uses the following symbols: |
| 63 | Sa, Sc - source alpha and color |
| 64 | Da, Dc - destination alpha and color (before compositing) |
| 65 | [a, c] - Resulting (alpha, color) values |
| 66 | For these equations, the colors are in premultiplied state. |
| 67 | If no xfermode is specified, kSrcOver is assumed. |
bsalomon@google.com | 8da9bc7 | 2013-04-19 15:03:21 +0000 | [diff] [blame] | 68 | The modes are ordered by those that can be expressed as a pair of Coeffs, followed by those |
| 69 | that aren't Coeffs but have separable r,g,b computations, and finally |
| 70 | those that are not separable. |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 71 | */ |
| 72 | enum Mode { |
| 73 | kClear_Mode, //!< [0, 0] |
| 74 | kSrc_Mode, //!< [Sa, Sc] |
| 75 | kDst_Mode, //!< [Da, Dc] |
pkasting | 129319f | 2015-10-29 08:41:15 -0700 | [diff] [blame] | 76 | kSrcOver_Mode, //!< [Sa + Da * (1 - Sa), Sc + Dc * (1 - Sa)] |
| 77 | kDstOver_Mode, //!< [Da + Sa * (1 - Da), Dc + Sc * (1 - Da)] |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 78 | kSrcIn_Mode, //!< [Sa * Da, Sc * Da] |
pkasting | 129319f | 2015-10-29 08:41:15 -0700 | [diff] [blame] | 79 | kDstIn_Mode, //!< [Da * Sa, Dc * Sa] |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 80 | kSrcOut_Mode, //!< [Sa * (1 - Da), Sc * (1 - Da)] |
| 81 | kDstOut_Mode, //!< [Da * (1 - Sa), Dc * (1 - Sa)] |
pkasting | 129319f | 2015-10-29 08:41:15 -0700 | [diff] [blame] | 82 | kSrcATop_Mode, //!< [Da, Sc * Da + Dc * (1 - Sa)] |
| 83 | kDstATop_Mode, //!< [Sa, Dc * Sa + Sc * (1 - Da)] |
| 84 | kXor_Mode, //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + Dc * (1 - Sa)] |
commit-bot@chromium.org | b24f893 | 2013-03-05 16:23:59 +0000 | [diff] [blame] | 85 | kPlus_Mode, //!< [Sa + Da, Sc + Dc] |
reed@google.com | 8d3cd7a | 2013-01-30 21:36:11 +0000 | [diff] [blame] | 86 | kModulate_Mode, // multiplies all components (= alpha and color) |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 87 | |
skia.committer@gmail.com | 6433435 | 2013-03-06 07:01:46 +0000 | [diff] [blame] | 88 | // Following blend modes are defined in the CSS Compositing standard: |
commit-bot@chromium.org | b24f893 | 2013-03-05 16:23:59 +0000 | [diff] [blame] | 89 | // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending |
bsalomon@google.com | b0091b8 | 2013-04-15 15:16:47 +0000 | [diff] [blame] | 90 | kScreen_Mode, |
bsalomon@google.com | 8da9bc7 | 2013-04-19 15:03:21 +0000 | [diff] [blame] | 91 | kLastCoeffMode = kScreen_Mode, |
| 92 | |
| 93 | kOverlay_Mode, |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 94 | kDarken_Mode, |
| 95 | kLighten_Mode, |
| 96 | kColorDodge_Mode, |
| 97 | kColorBurn_Mode, |
| 98 | kHardLight_Mode, |
| 99 | kSoftLight_Mode, |
| 100 | kDifference_Mode, |
| 101 | kExclusion_Mode, |
reed@google.com | 25cfa69 | 2013-02-04 20:06:00 +0000 | [diff] [blame] | 102 | kMultiply_Mode, |
bsalomon@google.com | 8da9bc7 | 2013-04-19 15:03:21 +0000 | [diff] [blame] | 103 | kLastSeparableMode = kMultiply_Mode, |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 104 | |
commit-bot@chromium.org | b24f893 | 2013-03-05 16:23:59 +0000 | [diff] [blame] | 105 | kHue_Mode, |
| 106 | kSaturation_Mode, |
| 107 | kColor_Mode, |
| 108 | kLuminosity_Mode, |
commit-bot@chromium.org | b24f893 | 2013-03-05 16:23:59 +0000 | [diff] [blame] | 109 | kLastMode = kLuminosity_Mode |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 110 | }; |
skia.committer@gmail.com | 05a2ee0 | 2013-04-02 07:01:34 +0000 | [diff] [blame] | 111 | |
commit-bot@chromium.org | d7aaf60 | 2013-04-01 12:51:34 +0000 | [diff] [blame] | 112 | /** |
| 113 | * Gets the name of the Mode as a string. |
| 114 | */ |
| 115 | static const char* ModeName(Mode); |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 116 | |
reed@google.com | c0d4aa2 | 2011-04-13 21:12:04 +0000 | [diff] [blame] | 117 | /** |
| 118 | * If the xfermode is one of the modes in the Mode enum, then asMode() |
| 119 | * returns true and sets (if not null) mode accordingly. Otherwise it |
| 120 | * returns false and ignores the mode parameter. |
vandebo@chromium.org | 4854327 | 2011-02-08 19:28:07 +0000 | [diff] [blame] | 121 | */ |
reed@google.com | 30da745 | 2012-12-17 19:55:24 +0000 | [diff] [blame] | 122 | virtual bool asMode(Mode* mode) const; |
vandebo@chromium.org | 4854327 | 2011-02-08 19:28:07 +0000 | [diff] [blame] | 123 | |
reed@google.com | 43c50c8 | 2011-04-14 15:50:52 +0000 | [diff] [blame] | 124 | /** |
| 125 | * The same as calling xfermode->asMode(mode), except that this also checks |
bsalomon@google.com | f51c013 | 2013-03-27 18:31:15 +0000 | [diff] [blame] | 126 | * if the xfermode is NULL, and if so, treats it as kSrcOver_Mode. |
reed@google.com | 43c50c8 | 2011-04-14 15:50:52 +0000 | [diff] [blame] | 127 | */ |
reed@google.com | 30da745 | 2012-12-17 19:55:24 +0000 | [diff] [blame] | 128 | static bool AsMode(const SkXfermode*, Mode* mode); |
reed@google.com | 43c50c8 | 2011-04-14 15:50:52 +0000 | [diff] [blame] | 129 | |
mike@reedtribe.org | e303fcf | 2011-11-17 02:16:43 +0000 | [diff] [blame] | 130 | /** |
| 131 | * Returns true if the xfermode claims to be the specified Mode. This works |
| 132 | * correctly even if the xfermode is NULL (which equates to kSrcOver.) Thus |
| 133 | * you can say this without checking for a null... |
| 134 | * |
| 135 | * If (SkXfermode::IsMode(paint.getXfermode(), |
| 136 | * SkXfermode::kDstOver_Mode)) { |
| 137 | * ... |
| 138 | * } |
| 139 | */ |
reed@google.com | 30da745 | 2012-12-17 19:55:24 +0000 | [diff] [blame] | 140 | static bool IsMode(const SkXfermode* xfer, Mode mode); |
mike@reedtribe.org | e303fcf | 2011-11-17 02:16:43 +0000 | [diff] [blame] | 141 | |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 142 | /** Return an SkXfermode object for the specified mode. |
| 143 | */ |
| 144 | static SkXfermode* Create(Mode mode); |
| 145 | |
| 146 | /** Return a function pointer to a routine that applies the specified |
| 147 | porter-duff transfer mode. |
| 148 | */ |
| 149 | static SkXfermodeProc GetProc(Mode mode); |
reed | 3125565 | 2016-02-08 12:56:56 -0800 | [diff] [blame] | 150 | static SkXfermodeProc4f GetProc4f(Mode); |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 151 | |
reed@google.com | c0d4aa2 | 2011-04-13 21:12:04 +0000 | [diff] [blame] | 152 | /** |
reed@google.com | 43c50c8 | 2011-04-14 15:50:52 +0000 | [diff] [blame] | 153 | * If the specified mode can be represented by a pair of Coeff, then return |
| 154 | * true and set (if not NULL) the corresponding coeffs. If the mode is |
| 155 | * not representable as a pair of Coeffs, return false and ignore the |
| 156 | * src and dst parameters. |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 157 | */ |
reed@google.com | 43c50c8 | 2011-04-14 15:50:52 +0000 | [diff] [blame] | 158 | static bool ModeAsCoeff(Mode mode, Coeff* src, Coeff* dst); |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 159 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 160 | SK_ATTR_DEPRECATED("use AsMode(...)") |
reed@google.com | 30da745 | 2012-12-17 19:55:24 +0000 | [diff] [blame] | 161 | static bool IsMode(const SkXfermode* xfer, Mode* mode) { |
reed@google.com | 43c50c8 | 2011-04-14 15:50:52 +0000 | [diff] [blame] | 162 | return AsMode(xfer, mode); |
| 163 | } |
tomhudson@google.com | 1447c6f | 2011-04-27 14:09:52 +0000 | [diff] [blame] | 164 | |
egdaniel | dcfb7cf | 2015-01-22 06:52:29 -0800 | [diff] [blame] | 165 | /** |
| 166 | * Returns whether or not the xfer mode can support treating coverage as alpha |
mtklein | 2766c00 | 2015-06-26 11:45:03 -0700 | [diff] [blame] | 167 | */ |
egdaniel | dcfb7cf | 2015-01-22 06:52:29 -0800 | [diff] [blame] | 168 | virtual bool supportsCoverageAsAlpha() const; |
| 169 | |
| 170 | /** |
| 171 | * The same as calling xfermode->supportsCoverageAsAlpha(), except that this also checks if |
| 172 | * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. |
| 173 | */ |
| 174 | static bool SupportsCoverageAsAlpha(const SkXfermode* xfer); |
| 175 | |
| 176 | enum SrcColorOpacity { |
| 177 | // The src color is known to be opaque (alpha == 255) |
| 178 | kOpaque_SrcColorOpacity = 0, |
| 179 | // The src color is known to be fully transparent (color == 0) |
| 180 | kTransparentBlack_SrcColorOpacity = 1, |
| 181 | // The src alpha is known to be fully transparent (alpha == 0) |
| 182 | kTransparentAlpha_SrcColorOpacity = 2, |
| 183 | // The src color opacity is unknown |
| 184 | kUnknown_SrcColorOpacity = 3 |
| 185 | }; |
| 186 | |
| 187 | /** |
| 188 | * Returns whether or not the result of the draw with the xfer mode will be opaque or not. The |
| 189 | * input to this call is an enum describing known information about the opacity of the src color |
| 190 | * that will be given to the xfer mode. |
| 191 | */ |
| 192 | virtual bool isOpaque(SrcColorOpacity opacityType) const; |
| 193 | |
| 194 | /** |
| 195 | * The same as calling xfermode->isOpaque(...), except that this also checks if |
| 196 | * the xfermode is NULL, and if so, treats it as kSrcOver_Mode. |
| 197 | */ |
| 198 | static bool IsOpaque(const SkXfermode* xfer, SrcColorOpacity opacityType); |
| 199 | |
robertphillips | 4f03794 | 2016-02-09 05:09:27 -0800 | [diff] [blame] | 200 | #if SK_SUPPORT_GPU |
| 201 | /** Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentProcessor. |
| 202 | The input to the returned FP is the src color. The dst color is |
| 203 | provided by the dst param which becomes a child FP of the returned FP. |
| 204 | It is legal for the function to return a null output. This indicates that |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 205 | the output of the blend is simply the src color. |
bsalomon@google.com | f51c013 | 2013-03-27 18:31:15 +0000 | [diff] [blame] | 206 | */ |
robertphillips | 4f03794 | 2016-02-09 05:09:27 -0800 | [diff] [blame] | 207 | virtual const GrFragmentProcessor* getFragmentProcessorForImageFilter( |
| 208 | const GrFragmentProcessor* dst) const; |
bsalomon@google.com | f51c013 | 2013-03-27 18:31:15 +0000 | [diff] [blame] | 209 | |
robertphillips | 4f03794 | 2016-02-09 05:09:27 -0800 | [diff] [blame] | 210 | /** A subclass must implement this factory function to work with the GPU backend. |
| 211 | The xfermode will return a factory for which the caller will get a ref. It is up |
| 212 | to the caller to install it. XferProcessors cannot use a background texture. |
egdaniel | c4b7272 | 2015-11-23 13:20:41 -0800 | [diff] [blame] | 213 | */ |
robertphillips | 4f03794 | 2016-02-09 05:09:27 -0800 | [diff] [blame] | 214 | virtual GrXPFactory* asXPFactory() const; |
| 215 | #endif |
bsalomon@google.com | f51c013 | 2013-03-27 18:31:15 +0000 | [diff] [blame] | 216 | |
commit-bot@chromium.org | 0f10f7b | 2014-03-13 18:02:17 +0000 | [diff] [blame] | 217 | SK_TO_STRING_PUREVIRT() |
djsollen@google.com | a2ca41e | 2012-03-23 19:00:34 +0000 | [diff] [blame] | 218 | SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
commit-bot@chromium.org | c0b7e10 | 2013-10-23 17:06:21 +0000 | [diff] [blame] | 219 | SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) |
| 220 | |
reed | 395eabe | 2016-01-30 18:52:31 -0800 | [diff] [blame] | 221 | enum PM4fFlags { |
| 222 | kSrcIsOpaque_PM4fFlag = 1 << 0, |
| 223 | kDstIsSRGB_PM4fFlag = 1 << 1, |
| 224 | }; |
| 225 | struct PM4fState { |
| 226 | const SkXfermode* fXfer; |
| 227 | uint32_t fFlags; |
| 228 | }; |
| 229 | typedef void (*PM4fProc1)(const PM4fState&, uint32_t dst[], const SkPM4f& src, |
| 230 | int count, const SkAlpha coverage[]); |
| 231 | typedef void (*PM4fProcN)(const PM4fState&, uint32_t dst[], const SkPM4f src[], |
| 232 | int count, const SkAlpha coverage[]); |
reed | 3125565 | 2016-02-08 12:56:56 -0800 | [diff] [blame] | 233 | |
reed | 395eabe | 2016-01-30 18:52:31 -0800 | [diff] [blame] | 234 | static PM4fProc1 GetPM4fProc1(Mode, uint32_t flags); |
| 235 | static PM4fProcN GetPM4fProcN(Mode, uint32_t flags); |
| 236 | virtual PM4fProc1 getPM4fProc1(uint32_t flags) const; |
| 237 | virtual PM4fProcN getPM4fProcN(uint32_t flags) const; |
| 238 | |
reed | d2ed622 | 2016-02-09 09:14:59 -0800 | [diff] [blame] | 239 | enum U64Flags { |
| 240 | kSrcIsOpaque_U64Flag = 1 << 0, |
| 241 | kDstIsFloat16_U64Flag = 1 << 1, // else U16 bit components |
| 242 | }; |
| 243 | struct U64State { |
| 244 | const SkXfermode* fXfer; |
| 245 | uint32_t fFlags; |
| 246 | }; |
| 247 | typedef void (*U64Proc1)(const U64State&, uint64_t dst[], const SkPM4f& src, int count, |
| 248 | const SkAlpha coverage[]); |
| 249 | typedef void (*U64ProcN)(const U64State&, uint64_t dst[], const SkPM4f src[], int count, |
| 250 | const SkAlpha coverage[]); |
| 251 | static U64Proc1 GetU64Proc1(Mode, uint32_t flags); |
| 252 | static U64ProcN GetU64ProcN(Mode, uint32_t flags); |
| 253 | |
reed | 4528c86 | 2016-02-18 08:16:33 -0800 | [diff] [blame] | 254 | enum LCDFlags { |
| 255 | kSrcIsOpaque_LCDFlag = 1 << 0, // else src(s) may have alpha < 1 |
| 256 | kSrcIsSingle_LCDFlag = 1 << 1, // else src[count] |
| 257 | kDstIsLinearInt_LCDFlag = 1 << 2, // else srgb/half-float |
| 258 | }; |
| 259 | typedef void (*LCD32Proc)(uint32_t* dst, const SkPM4f* src, int count, const uint16_t lcd[]); |
| 260 | typedef void (*LCD64Proc)(uint64_t* dst, const SkPM4f* src, int count, const uint16_t lcd[]); |
| 261 | static LCD32Proc GetLCD32Proc(uint32_t flags); |
| 262 | static LCD64Proc GetLCD64Proc(uint32_t) { return nullptr; } |
| 263 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 264 | protected: |
commit-bot@chromium.org | bd0be25 | 2014-05-15 15:40:41 +0000 | [diff] [blame] | 265 | SkXfermode() {} |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 266 | /** The default implementation of xfer32/xfer16/xferA8 in turn call this |
| 267 | method, 1 color at a time (upscaled to a SkPMColor). The default |
bsalomon | ae4738f | 2015-09-15 15:33:27 -0700 | [diff] [blame] | 268 | implementation of this method just returns dst. If performance is |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 269 | important, your subclass should override xfer32/xfer16/xferA8 directly. |
tomhudson@google.com | 1447c6f | 2011-04-27 14:09:52 +0000 | [diff] [blame] | 270 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 271 | This method will not be called directly by the client, so it need not |
| 272 | be implemented if your subclass has overridden xfer32/xfer16/xferA8 |
| 273 | */ |
reed@google.com | 30da745 | 2012-12-17 19:55:24 +0000 | [diff] [blame] | 274 | virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 275 | |
| 276 | private: |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 277 | enum { |
| 278 | kModeCount = kLastMode + 1 |
| 279 | }; |
commit-bot@chromium.org | 8649057 | 2013-10-04 16:52:55 +0000 | [diff] [blame] | 280 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 281 | typedef SkFlattenable INHERITED; |
| 282 | }; |
| 283 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 284 | #endif |