Index: src/effects/SkArithmeticMode_gpu.h |
diff --git a/src/effects/SkArithmeticMode_gpu.h b/src/effects/SkArithmeticMode_gpu.h |
index 84b839d2cb8c88745dfe58042a470392385198bc..17116c29be328c7908b55e032773ae78dc2a7edf 100644 |
--- a/src/effects/SkArithmeticMode_gpu.h |
+++ b/src/effects/SkArithmeticMode_gpu.h |
@@ -13,8 +13,11 @@ |
#include "GrCoordTransform.h" |
#include "GrFragmentProcessor.h" |
#include "GrTextureAccess.h" |
+#include "GrTypes.h" |
+#include "GrXferProcessor.h" |
class GrInvariantOutput; |
+class GrProcOptInfo; |
class GrTexture; |
/////////////////////////////////////////////////////////////////////////////// |
@@ -38,8 +41,6 @@ public: |
GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; |
- GrTexture* backgroundTexture() const { return fBackgroundAccess.getTexture(); } |
- |
float k1() const { return fK1; } |
float k2() const { return fK2; } |
float k3() const { return fK3; } |
@@ -63,5 +64,121 @@ private: |
typedef GrFragmentProcessor INHERITED; |
}; |
+/////////////////////////////////////////////////////////////////////////////// |
+// Xfer Processor |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
+class GrArithmeticXP : public GrXferProcessor { |
+public: |
+ static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool enforcePMColor) { |
+ return SkNEW_ARGS(GrArithmeticXP, (k1, k2, k3, k4, enforcePMColor)); |
+ } |
+ |
+ ~GrArithmeticXP() SK_OVERRIDE {}; |
+ |
+ const char* name() const SK_OVERRIDE { return "Arithmetic"; } |
+ |
+ void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
+ |
+ GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; |
+ |
+ bool hasSecondaryOutput() const SK_OVERRIDE { return false; } |
+ |
+ GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
+ const GrProcOptInfo& coveragePOI, |
+ bool doesStencilWrite, |
+ GrColor* overrideColor, |
+ const GrDrawTargetCaps& caps) SK_OVERRIDE; |
+ |
+ void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE { |
+ blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
+ blendInfo->fDstBlend = kZero_GrBlendCoeff; |
+ blendInfo->fBlendConstant = 0; |
+ } |
+ |
+ float k1() const { return fK1; } |
+ float k2() const { return fK2; } |
+ float k3() const { return fK3; } |
+ float k4() const { return fK4; } |
+ bool enforcePMColor() const { return fEnforcePMColor; } |
+ |
+private: |
+ GrArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor); |
+ |
+ bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { |
+ const GrArithmeticXP& xp = xpBase.cast<GrArithmeticXP>(); |
+ if (fK1 != xp.fK1 || |
+ fK2 != xp.fK2 || |
+ fK3 != xp.fK3 || |
+ fK4 != xp.fK4 || |
+ fEnforcePMColor != xp.fEnforcePMColor) { |
+ return false; |
+ } |
+ return true; |
+ } |
+ |
+ float fK1, fK2, fK3, fK4; |
+ bool fEnforcePMColor; |
+ |
+ typedef GrXferProcessor INHERITED; |
+}; |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
+class GrArithmeticXPFactory : public GrXPFactory { |
+public: |
+ static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enforcePMColor) { |
+ return SkNEW_ARGS(GrArithmeticXPFactory, (k1, k2, k3, k4, enforcePMColor)); |
+ } |
+ |
+ GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, |
+ const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { |
+ return GrArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor); |
+ } |
+ |
+ bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE { |
+ return true; |
+ } |
+ |
+ bool canApplyCoverage(const GrProcOptInfo& colorPOI, |
+ const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { |
+ return true; |
+ } |
+ |
+ bool canTweakAlphaForCoverage() const SK_OVERRIDE { |
+ return false; |
+ } |
+ |
+ void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI, |
+ GrXPFactory::InvariantOutput*) const SK_OVERRIDE; |
+ |
+ bool willReadDst(const GrProcOptInfo& colorPOI, |
+ const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { |
+ return true; |
+ } |
+ |
+private: |
+ GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePMColor); |
+ |
+ bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { |
+ const GrArithmeticXPFactory& xpf = xpfBase.cast<GrArithmeticXPFactory>(); |
+ if (fK1 != xpf.fK1 || |
+ fK2 != xpf.fK2 || |
+ fK3 != xpf.fK3 || |
+ fK4 != xpf.fK4 || |
+ fEnforcePMColor != xpf.fEnforcePMColor) { |
+ return false; |
+ } |
+ return true; |
+ } |
+ |
+ GR_DECLARE_XP_FACTORY_TEST; |
+ |
+ float fK1, fK2, fK3, fK4; |
+ bool fEnforcePMColor; |
+ |
+ typedef GrXPFactory INHERITED; |
+}; |
+ |
#endif |
#endif |