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