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, ((GrBlendCoeff)(src), (GrBlendC
oeff)(dst))); |
| 58 } |
| 59 |
| 60 static GrXPFactory* Create(GrBlendCoeff src, GrBlendCoeff dst) { |
| 61 return SkNEW_ARGS(GrPorterDuffXPFactory, (src, dst)); |
| 62 } |
| 63 |
| 64 const GrXferProcessor* createXferProcessor() const SK_OVERRIDE; |
| 65 |
| 66 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE; |
| 67 |
| 68 private: |
| 69 GrPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst) |
| 70 : fSrc(src), fDst(dst) {} |
| 71 |
| 72 GrBlendCoeff fSrc; |
| 73 GrBlendCoeff fDst; |
| 74 |
| 75 typedef GrXPFactory INHERITED; |
| 76 }; |
| 77 |
| 78 #endif |
OLD | NEW |