OLD | NEW |
| 1 /* |
| 2 * Copyright 2015 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 |
1 #ifndef SkXfermode_proccoeff_DEFINED | 8 #ifndef SkXfermode_proccoeff_DEFINED |
2 #define SkXfermode_proccoeff_DEFINED | 9 #define SkXfermode_proccoeff_DEFINED |
3 | 10 |
4 #include "SkXfermode.h" | 11 #include "SkXfermode.h" |
5 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
6 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
7 | 14 |
8 struct ProcCoeff { | 15 struct ProcCoeff { |
9 SkXfermodeProc fProc; | 16 SkXfermodeProc fProc; |
10 SkXfermode::Coeff fSC; | 17 SkXfermode::Coeff fSC; |
11 SkXfermode::Coeff fDC; | 18 SkXfermode::Coeff fDC; |
12 }; | 19 }; |
13 | 20 |
14 #define CANNOT_USE_COEFF SkXfermode::Coeff(-1) | 21 #define CANNOT_USE_COEFF SkXfermode::Coeff(-1) |
15 | 22 |
16 class SK_API SkProcCoeffXfermode : public SkXfermode { | 23 class SK_API SkProcCoeffXfermode : public SkXfermode { |
17 public: | 24 public: |
18 SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode) { | 25 SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode) { |
19 fMode = mode; | 26 fMode = mode; |
20 fProc = rec.fProc; | 27 fProc = rec.fProc; |
21 // these may be valid, or may be CANNOT_USE_COEFF | 28 // these may be valid, or may be CANNOT_USE_COEFF |
22 fSrcCoeff = rec.fSC; | 29 fSrcCoeff = rec.fSC; |
23 fDstCoeff = rec.fDC; | 30 fDstCoeff = rec.fDC; |
24 } | 31 } |
25 | 32 |
26 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, | 33 void xfer32(SkPMColor dst[], const SkPMColor src[], int count, |
27 const SkAlpha aa[]) const override; | 34 const SkAlpha aa[]) const override; |
28 virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, | 35 void xfer16(uint16_t dst[], const SkPMColor src[], int count, |
29 const SkAlpha aa[]) const override; | 36 const SkAlpha aa[]) const override; |
30 virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, | 37 void xferA8(SkAlpha dst[], const SkPMColor src[], int count, |
31 const SkAlpha aa[]) const override; | 38 const SkAlpha aa[]) const override; |
32 | 39 |
33 bool asMode(Mode* mode) const override; | 40 bool asMode(Mode* mode) const override; |
34 | 41 |
35 bool supportsCoverageAsAlpha() const override; | 42 bool supportsCoverageAsAlpha() const override; |
36 | 43 |
37 bool isOpaque(SkXfermode::SrcColorOpacity opacityType) const override; | 44 bool isOpaque(SkXfermode::SrcColorOpacity opacityType) const override; |
38 | 45 |
39 #if SK_SUPPORT_GPU | 46 #if SK_SUPPORT_GPU |
40 virtual bool asFragmentProcessor(GrFragmentProcessor**, | 47 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* background) const
override; |
41 GrTexture* background) const override; | |
42 | 48 |
43 virtual bool asXPFactory(GrXPFactory**) const override; | 49 bool asXPFactory(GrXPFactory**) const override; |
44 #endif | 50 #endif |
45 | 51 |
46 SK_TO_STRING_OVERRIDE() | 52 SK_TO_STRING_OVERRIDE() |
47 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode) | 53 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode) |
48 | 54 |
49 protected: | 55 protected: |
50 void flatten(SkWriteBuffer& buffer) const override; | 56 void flatten(SkWriteBuffer& buffer) const override; |
51 | 57 |
52 Mode getMode() const { return fMode; } | 58 Mode getMode() const { return fMode; } |
53 | 59 |
54 SkXfermodeProc getProc() const { return fProc; } | 60 SkXfermodeProc getProc() const { return fProc; } |
55 | 61 |
56 private: | 62 private: |
57 SkXfermodeProc fProc; | 63 SkXfermodeProc fProc; |
58 Mode fMode; | 64 Mode fMode; |
59 Coeff fSrcCoeff, fDstCoeff; | 65 Coeff fSrcCoeff, fDstCoeff; |
60 | 66 |
61 friend class SkXfermode; | 67 friend class SkXfermode; |
62 | 68 |
63 typedef SkXfermode INHERITED; | 69 typedef SkXfermode INHERITED; |
64 }; | 70 }; |
65 | 71 |
66 #endif // #ifndef SkXfermode_proccoeff_DEFINED | 72 #endif // #ifndef SkXfermode_proccoeff_DEFINED |
OLD | NEW |