Chromium Code Reviews| Index: src/gpu/effects/GrPorterDuffXferProcessor.h |
| diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.h b/src/gpu/effects/GrPorterDuffXferProcessor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c7bd465c13ea42254a572327358b9b1e689d0ab2 |
| --- /dev/null |
| +++ b/src/gpu/effects/GrPorterDuffXferProcessor.h |
| @@ -0,0 +1,75 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef GrPorterDuffXferProcessor_DEFINED |
| +#define GrPorterDuffXferProcessor_DEFINED |
| + |
| +#include "GrTypes.h" |
| +#include "GrXferProcessor.h" |
| +#include "SkXfermode.h" |
| + |
| +class GrBackendFragmentProcessorFactory; |
| +class GrDrawState; |
| +class GrGLPorterDuffXferProcessor; |
| +class GrInvariantOutput; |
| + |
| +class GrPorterDuffXferProcessor : public GrXferProcessor { |
| +public: |
| + static GrXferProcessor* Create(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend) { |
| + return SkNEW_ARGS(GrPorterDuffXferProcessor, (srcBlend, dstBlend)); |
| + } |
| + |
| + virtual ~GrPorterDuffXferProcessor(); |
| + |
| + virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; |
| + |
| + typedef GrGLPorterDuffXferProcessor GLProcessor; |
| + static const char* Name() { return "Porter Duff"; } |
| + |
| +private: |
| + GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend); |
| + |
| + virtual bool onIsEqual(const GrFragmentProcessor& fpBase) const SK_OVERRIDE { |
| + const GrPorterDuffXferProcessor& xp = fpBase.cast<GrPorterDuffXferProcessor>(); |
| + if (fSrcBlend != xp.fSrcBlend || fDstBlend != xp.fDstBlend) { |
| + return false; |
| + } |
| + return true; |
| + } |
| + |
| + virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVERRIDE; |
| + |
| + GrBlendCoeff fSrcBlend; |
| + GrBlendCoeff fDstBlend; |
| + |
| + typedef GrXferProcessor INHERITED; |
| +}; |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +class GrPorterDuffXPFactory : public GrXPFactory { |
| +public: |
| + static GrXPFactory* Create(SkXfermode::Coeff src, SkXfermode::Coeff dst) { |
| + return SkNEW_ARGS(GrPorterDuffXPFactory, (src, dst)); |
| + } |
| + |
| + 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.
|
| + |
| + virtual bool supportsRGBCoverage(const GrDrawState&) const SK_OVERRIDE; |
| + |
| +protected: |
| + GrPorterDuffXPFactory(SkXfermode::Coeff src, SkXfermode::Coeff dst) |
| + : fSrc((GrBlendCoeff)(src)), fDst((GrBlendCoeff)(dst)) {} |
| + |
| + GrBlendCoeff fSrc; |
| + GrBlendCoeff fDst; |
| + |
| +private: |
| + typedef GrXPFactory INHERITED; |
| +}; |
| + |
| +#endif |