| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkArithmeticMode_gpu_DEFINED | 8 #ifndef SkArithmeticMode_gpu_DEFINED |
| 9 #define SkArithmeticMode_gpu_DEFINED | 9 #define SkArithmeticMode_gpu_DEFINED |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 GrTextureAccess fBackgroundAccess; | 64 GrTextureAccess fBackgroundAccess; |
| 65 | 65 |
| 66 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 66 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 67 typedef GrFragmentProcessor INHERITED; | 67 typedef GrFragmentProcessor INHERITED; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 /////////////////////////////////////////////////////////////////////////////// | 70 /////////////////////////////////////////////////////////////////////////////// |
| 71 // Xfer Processor | 71 // Xfer Processor |
| 72 /////////////////////////////////////////////////////////////////////////////// | 72 /////////////////////////////////////////////////////////////////////////////// |
| 73 | 73 |
| 74 class GrArithmeticXP : public GrXferProcessor { | |
| 75 public: | |
| 76 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool
enforcePMColor, | |
| 77 const GrDeviceCoordTexture* dstCopy, | |
| 78 bool willReadDstColor) { | |
| 79 return SkNEW_ARGS(GrArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstCo
py, | |
| 80 willReadDstColor)); | |
| 81 } | |
| 82 | |
| 83 ~GrArithmeticXP() SK_OVERRIDE {}; | |
| 84 | |
| 85 const char* name() const SK_OVERRIDE { return "Arithmetic"; } | |
| 86 | |
| 87 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; | |
| 88 | |
| 89 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } | |
| 90 | |
| 91 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | |
| 92 const GrProcOptInfo& coveragePOI, | |
| 93 bool doesStencilWrite, | |
| 94 GrColor* overrideColor, | |
| 95 const GrDrawTargetCaps& caps) SK_
OVERRIDE; | |
| 96 | |
| 97 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE { | |
| 98 blendInfo->fSrcBlend = kOne_GrBlendCoeff; | |
| 99 blendInfo->fDstBlend = kZero_GrBlendCoeff; | |
| 100 blendInfo->fBlendConstant = 0; | |
| 101 } | |
| 102 | |
| 103 float k1() const { return fK1; } | |
| 104 float k2() const { return fK2; } | |
| 105 float k3() const { return fK3; } | |
| 106 float k4() const { return fK4; } | |
| 107 bool enforcePMColor() const { return fEnforcePMColor; } | |
| 108 | |
| 109 private: | |
| 110 GrArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, | |
| 111 const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); | |
| 112 | |
| 113 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st SK_OVERRIDE; | |
| 114 | |
| 115 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { | |
| 116 const GrArithmeticXP& xp = xpBase.cast<GrArithmeticXP>(); | |
| 117 if (fK1 != xp.fK1 || | |
| 118 fK2 != xp.fK2 || | |
| 119 fK3 != xp.fK3 || | |
| 120 fK4 != xp.fK4 || | |
| 121 fEnforcePMColor != xp.fEnforcePMColor) { | |
| 122 return false; | |
| 123 } | |
| 124 return true; | |
| 125 } | |
| 126 | |
| 127 float fK1, fK2, fK3, fK4; | |
| 128 bool fEnforcePMColor; | |
| 129 | |
| 130 typedef GrXferProcessor INHERITED; | |
| 131 }; | |
| 132 | |
| 133 /////////////////////////////////////////////////////////////////////////////// | |
| 134 | |
| 135 class GrArithmeticXPFactory : public GrXPFactory { | 74 class GrArithmeticXPFactory : public GrXPFactory { |
| 136 public: | 75 public: |
| 137 static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enfo
rcePMColor) { | 76 static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enfo
rcePMColor) { |
| 138 return SkNEW_ARGS(GrArithmeticXPFactory, (k1, k2, k3, k4, enforcePMColor
)); | 77 return SkNEW_ARGS(GrArithmeticXPFactory, (k1, k2, k3, k4, enforcePMColor
)); |
| 139 } | 78 } |
| 140 | 79 |
| 141 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { | 80 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { |
| 142 return true; | 81 return true; |
| 143 } | 82 } |
| 144 | 83 |
| 145 bool canApplyCoverage(const GrProcOptInfo& colorPOI, | 84 bool canApplyCoverage(const GrProcOptInfo& colorPOI, |
| 146 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { | 85 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { |
| 147 return true; | 86 return true; |
| 148 } | 87 } |
| 149 | 88 |
| 150 bool canTweakAlphaForCoverage() const SK_OVERRIDE { | 89 bool canTweakAlphaForCoverage() const SK_OVERRIDE { |
| 151 return false; | 90 return false; |
| 152 } | 91 } |
| 153 | 92 |
| 154 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, | 93 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, |
| 155 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; | 94 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; |
| 156 | 95 |
| 157 private: | 96 private: |
| 158 GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePM
Color); | 97 GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePM
Color); |
| 159 | 98 |
| 160 GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI, | 99 GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI, |
| 161 const GrProcOptInfo& coveragePOI, | 100 const GrProcOptInfo& coveragePOI, |
| 162 const GrDeviceCoordTexture* dstCopy)
const SK_OVERRIDE { | 101 const GrDeviceCoordTexture* dstCopy)
const SK_OVERRIDE; |
| 163 return GrArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstCo
py, | |
| 164 this->willReadDstColor()); | |
| 165 } | |
| 166 | 102 |
| 167 bool willReadDstColor() const SK_OVERRIDE { return true; } | 103 bool willReadDstColor() const SK_OVERRIDE { return true; } |
| 168 | 104 |
| 169 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { | 105 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { |
| 170 const GrArithmeticXPFactory& xpf = xpfBase.cast<GrArithmeticXPFactory>()
; | 106 const GrArithmeticXPFactory& xpf = xpfBase.cast<GrArithmeticXPFactory>()
; |
| 171 if (fK1 != xpf.fK1 || | 107 if (fK1 != xpf.fK1 || |
| 172 fK2 != xpf.fK2 || | 108 fK2 != xpf.fK2 || |
| 173 fK3 != xpf.fK3 || | 109 fK3 != xpf.fK3 || |
| 174 fK4 != xpf.fK4 || | 110 fK4 != xpf.fK4 || |
| 175 fEnforcePMColor != xpf.fEnforcePMColor) { | 111 fEnforcePMColor != xpf.fEnforcePMColor) { |
| 176 return false; | 112 return false; |
| 177 } | 113 } |
| 178 return true; | 114 return true; |
| 179 } | 115 } |
| 180 | 116 |
| 181 GR_DECLARE_XP_FACTORY_TEST; | 117 GR_DECLARE_XP_FACTORY_TEST; |
| 182 | 118 |
| 183 float fK1, fK2, fK3, fK4; | 119 float fK1, fK2, fK3, fK4; |
| 184 bool fEnforcePMColor; | 120 bool fEnforcePMColor; |
| 185 | 121 |
| 186 typedef GrXPFactory INHERITED; | 122 typedef GrXPFactory INHERITED; |
| 187 }; | 123 }; |
| 188 | 124 |
| 189 #endif | 125 #endif |
| 190 #endif | 126 #endif |
| OLD | NEW |