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