Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014 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 | |
| 8 #ifndef GrPorterDuffXferProcessor_DEFINED | |
| 9 #define GrPorterDuffXferProcessor_DEFINED | |
| 10 | |
| 11 #include "GrTypes.h" | |
| 12 #include "GrXferProcessor.h" | |
| 13 #include "SkXfermode.h" | |
| 14 | |
| 15 class GrBackendFragmentProcessorFactory; | |
| 16 class GrDrawState; | |
| 17 class GrGLPorterDuffXferProcessor; | |
| 18 class GrInvariantOutput; | |
| 19 | |
| 20 class GrPorterDuffXferProcessor : public GrXferProcessor { | |
| 21 public: | |
| 22 static GrXferProcessor* Create(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend) { | |
| 23 return SkNEW_ARGS(GrPorterDuffXferProcessor, (srcBlend, dstBlend)); | |
| 24 } | |
| 25 | |
| 26 virtual ~GrPorterDuffXferProcessor(); | |
| 27 | |
| 28 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE; | |
| 29 | |
| 30 typedef GrGLPorterDuffXferProcessor GLProcessor; | |
| 31 static const char* Name() { return "Porter Duff"; } | |
| 32 | |
| 33 private: | |
| 34 GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend); | |
| 35 | |
| 36 virtual bool onIsEqual(const GrFragmentProcessor& fpBase) const SK_OVERRIDE { | |
| 37 const GrPorterDuffXferProcessor& xp = fpBase.cast<GrPorterDuffXferProces sor>(); | |
| 38 if (fSrcBlend != xp.fSrcBlend || fDstBlend != xp.fDstBlend) { | |
| 39 return false; | |
| 40 } | |
| 41 return true; | |
| 42 } | |
| 43 | |
| 44 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE RRIDE; | |
| 45 | |
| 46 GrBlendCoeff fSrcBlend; | |
| 47 GrBlendCoeff fDstBlend; | |
| 48 | |
| 49 typedef GrXferProcessor INHERITED; | |
| 50 }; | |
| 51 | |
| 52 /////////////////////////////////////////////////////////////////////////////// | |
| 53 | |
| 54 class GrPorterDuffXPFactory : public GrXPFactory { | |
| 55 public: | |
| 56 static GrXPFactory* Create(SkXfermode::Coeff src, SkXfermode::Coeff dst) { | |
| 57 return SkNEW_ARGS(GrPorterDuffXPFactory, (src, dst)); | |
| 58 } | |
| 59 | |
| 60 virtual const GrXferProcessor* createXferProcessor() const SK_OVERRIDE; | |
|
bsalomon
2014/12/01 19:24:40
minor, no need for virtual w/ SK_OVERRIDE here and
egdaniel
2014/12/02 15:07:10
Done.
| |
| 61 | |
| 62 virtual bool supportsRGBCoverage(const GrDrawState&) const SK_OVERRIDE; | |
| 63 | |
| 64 protected: | |
| 65 GrPorterDuffXPFactory(SkXfermode::Coeff src, SkXfermode::Coeff dst) | |
| 66 : fSrc((GrBlendCoeff)(src)), fDst((GrBlendCoeff)(dst)) {} | |
| 67 | |
| 68 GrBlendCoeff fSrc; | |
| 69 GrBlendCoeff fDst; | |
| 70 | |
| 71 private: | |
| 72 typedef GrXPFactory INHERITED; | |
| 73 }; | |
| 74 | |
| 75 #endif | |
| OLD | NEW |