OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkLumaXfermode_DEFINED | 8 #ifndef SkLumaXfermode_DEFINED |
9 #define SkLumaXfermode_DEFINED | 9 #define SkLumaXfermode_DEFINED |
10 | 10 |
11 #include "SkXfermode.h" | 11 #include "SkXfermode.h" |
12 | 12 |
13 /** | 13 /** |
14 * Luminance mask transfer, as defined in | 14 * Luminance mask transfer, as defined in |
15 * http://www.w3.org/TR/SVG/masking.html#Masking | 15 * http://www.w3.org/TR/SVG/masking.html#Masking |
16 * http://www.w3.org/TR/css-masking/#MaskValues | 16 * http://www.w3.org/TR/css-masking/#MaskValues |
17 * | 17 * |
18 * The luminance-to-alpha function is applied before performing a standard | 18 * The luminance-to-alpha function is applied before performing a standard |
19 * SrcIn/DstIn/SrcOver xfer: | 19 * SrcIn/DstIn/SrcOver xfer: |
20 * | 20 * |
21 * luma(C) = (0.2125 * C.r + 0.7154 * C.g + 0.0721 * C.b) * C.a | 21 * luma(C) = (0.2125 * C.r + 0.7154 * C.g + 0.0721 * C.b) * C.a |
22 * | 22 * |
23 * (where C is un-premultiplied) | 23 * (where C is un-premultiplied) |
24 */ | 24 */ |
25 class SK_API SkLumaMaskXfermode : public SkXfermode { | 25 class SK_API SkLumaMaskXfermode : public SkXfermode { |
| 26 typedef SkXfermode INHERITED; |
| 27 |
26 public: | 28 public: |
27 /** Return an SkLumaMaskXfermode object for the specified submode. | 29 /** Return an SkLumaMaskXfermode object for the specified submode. |
28 * | 30 * |
29 * Only kSrcIn_Mode, kDstIn_Mode kSrcOver_Mode are supported - for everythi
ng else, | 31 * Only kSrcIn_Mode, kDstIn_Mode kSrcOver_Mode are supported - for everythi
ng else, |
30 * the factory returns NULL. | 32 * the factory returns NULL. |
31 */ | 33 */ |
32 static SkXfermode* Create(SkXfermode::Mode); | 34 static SkXfermode* Create(SkXfermode::Mode); |
33 | 35 |
34 virtual SkPMColor xferColor(SkPMColor, SkPMColor) const SK_OVERRIDE; | 36 virtual SkPMColor xferColor(SkPMColor, SkPMColor) const SK_OVERRIDE; |
35 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, | 37 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, |
(...skipping 10 matching lines...) Expand all Loading... |
46 | 48 |
47 protected: | 49 protected: |
48 SkLumaMaskXfermode(SkFlattenableReadBuffer&); | 50 SkLumaMaskXfermode(SkFlattenableReadBuffer&); |
49 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 51 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; |
50 | 52 |
51 SkLumaMaskXfermode(SkXfermode::Mode); | 53 SkLumaMaskXfermode(SkXfermode::Mode); |
52 | 54 |
53 private: | 55 private: |
54 const SkXfermode::Mode fMode; | 56 const SkXfermode::Mode fMode; |
55 | 57 |
56 typedef SkXfermode INHERITED; | |
57 | |
58 virtual SkPMColor lumaProc(const SkPMColor a, const SkPMColor b) const; | 58 virtual SkPMColor lumaProc(const SkPMColor a, const SkPMColor b) const; |
59 }; | 59 }; |
60 | 60 |
61 #endif | 61 #endif |
OLD | NEW |