OLD | NEW |
1 #ifndef SkXfermode_proccoeff_DEFINED | 1 #ifndef SkXfermode_proccoeff_DEFINED |
2 #define SkXfermode_proccoeff_DEFINED | 2 #define SkXfermode_proccoeff_DEFINED |
3 | 3 |
4 #include "SkXfermode.h" | 4 #include "SkXfermode.h" |
5 #include "SkReadBuffer.h" | 5 #include "SkReadBuffer.h" |
6 #include "SkWriteBuffer.h" | 6 #include "SkWriteBuffer.h" |
7 | 7 |
8 struct ProcCoeff { | 8 struct ProcCoeff { |
9 SkXfermodeProc fProc; | 9 SkXfermodeProc fProc; |
10 SkXfermode::Coeff fSC; | 10 SkXfermode::Coeff fSC; |
11 SkXfermode::Coeff fDC; | 11 SkXfermode::Coeff fDC; |
12 }; | 12 }; |
13 | 13 |
14 #define CANNOT_USE_COEFF SkXfermode::Coeff(-1) | 14 #define CANNOT_USE_COEFF SkXfermode::Coeff(-1) |
15 | 15 |
16 class SkProcCoeffXfermode : public SkProcXfermode { | 16 class SkProcCoeffXfermode : public SkProcXfermode { |
17 public: | 17 public: |
18 SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode) | 18 static SkProcCoeffXfermode* Create(const ProcCoeff& rec, Mode mode) { |
19 : INHERITED(rec.fProc) { | 19 return SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode)); |
20 fMode = mode; | |
21 // these may be valid, or may be CANNOT_USE_COEFF | |
22 fSrcCoeff = rec.fSC; | |
23 fDstCoeff = rec.fDC; | |
24 } | 20 } |
25 | 21 |
26 virtual bool asMode(Mode* mode) const SK_OVERRIDE; | 22 virtual bool asMode(Mode* mode) const SK_OVERRIDE; |
27 | 23 |
28 virtual bool asCoeff(Coeff* sc, Coeff* dc) const SK_OVERRIDE; | 24 virtual bool asCoeff(Coeff* sc, Coeff* dc) const SK_OVERRIDE; |
29 | 25 |
30 #if SK_SUPPORT_GPU | 26 #if SK_SUPPORT_GPU |
31 virtual bool asNewEffect(GrEffectRef** effect, | 27 virtual bool asNewEffect(GrEffectRef** effect, |
32 GrTexture* background) const SK_OVERRIDE; | 28 GrTexture* background) const SK_OVERRIDE; |
33 #endif | 29 #endif |
34 | 30 |
35 SK_DEVELOPER_TO_STRING() | 31 SK_DEVELOPER_TO_STRING() |
36 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode) | 32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode) |
37 | 33 |
38 protected: | 34 protected: |
| 35 SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode) |
| 36 : INHERITED(rec.fProc) { |
| 37 fMode = mode; |
| 38 // these may be valid, or may be CANNOT_USE_COEFF |
| 39 fSrcCoeff = rec.fSC; |
| 40 fDstCoeff = rec.fDC; |
| 41 } |
| 42 |
39 SkProcCoeffXfermode(SkReadBuffer& buffer); | 43 SkProcCoeffXfermode(SkReadBuffer& buffer); |
40 | 44 |
41 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; | 45 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; |
42 | 46 |
43 Mode getMode() const { | 47 Mode getMode() const { |
44 return fMode; | 48 return fMode; |
45 } | 49 } |
46 | 50 |
47 private: | 51 private: |
48 Mode fMode; | 52 Mode fMode; |
49 Coeff fSrcCoeff, fDstCoeff; | 53 Coeff fSrcCoeff, fDstCoeff; |
50 | 54 |
51 typedef SkProcXfermode INHERITED; | 55 typedef SkProcXfermode INHERITED; |
52 }; | 56 }; |
53 | 57 |
54 #endif // #ifndef SkXfermode_proccoeff_DEFINED | 58 #endif // #ifndef SkXfermode_proccoeff_DEFINED |
OLD | NEW |