| 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 #include "SkArithmeticMode_gpu.h" | 8 #include "SkArithmeticMode_gpu.h" |
| 9 | 9 |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); | 155 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); |
| 156 | 156 |
| 157 /////////////////////////////////////////////////////////////////////////////// | 157 /////////////////////////////////////////////////////////////////////////////// |
| 158 // Xfer Processor | 158 // Xfer Processor |
| 159 /////////////////////////////////////////////////////////////////////////////// | 159 /////////////////////////////////////////////////////////////////////////////// |
| 160 | 160 |
| 161 class ArithmeticXP : public GrXferProcessor { | 161 class ArithmeticXP : public GrXferProcessor { |
| 162 public: | 162 public: |
| 163 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool
enforcePMColor, | 163 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool
enforcePMColor, |
| 164 const DstTexture* dstTexture, bool willReadDs
tColor) { | 164 const GrDeviceCoordTexture* dstCopy, |
| 165 return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstText
ure, | 165 bool willReadDstColor) { |
| 166 return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstCopy
, |
| 166 willReadDstColor)); | 167 willReadDstColor)); |
| 167 } | 168 } |
| 168 | 169 |
| 169 ~ArithmeticXP() override {}; | 170 ~ArithmeticXP() override {}; |
| 170 | 171 |
| 171 const char* name() const override { return "Arithmetic"; } | 172 const char* name() const override { return "Arithmetic"; } |
| 172 | 173 |
| 173 GrGLXferProcessor* createGLInstance() const override; | 174 GrGLXferProcessor* createGLInstance() const override; |
| 174 | 175 |
| 175 bool hasSecondaryOutput() const override { return false; } | 176 bool hasSecondaryOutput() const override { return false; } |
| 176 | 177 |
| 177 float k1() const { return fK1; } | 178 float k1() const { return fK1; } |
| 178 float k2() const { return fK2; } | 179 float k2() const { return fK2; } |
| 179 float k3() const { return fK3; } | 180 float k3() const { return fK3; } |
| 180 float k4() const { return fK4; } | 181 float k4() const { return fK4; } |
| 181 bool enforcePMColor() const { return fEnforcePMColor; } | 182 bool enforcePMColor() const { return fEnforcePMColor; } |
| 182 | 183 |
| 183 private: | 184 private: |
| 184 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, | 185 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, |
| 185 const DstTexture*, bool willReadDstColor); | 186 const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); |
| 186 | 187 |
| 187 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 188 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
| 188 const GrProcOptInfo& coveragePO
I, | 189 const GrProcOptInfo& coveragePO
I, |
| 189 bool doesStencilWrite, | 190 bool doesStencilWrite, |
| 190 GrColor* overrideColor, | 191 GrColor* overrideColor, |
| 191 const GrCaps& caps) override; | 192 const GrCaps& caps) override; |
| 192 | 193 |
| 193 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | 194 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
| 194 | 195 |
| 195 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 196 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 256 |
| 256 GrGLProgramDataManager::UniformHandle fKUni; | 257 GrGLProgramDataManager::UniformHandle fKUni; |
| 257 bool fEnforcePMColor; | 258 bool fEnforcePMColor; |
| 258 | 259 |
| 259 typedef GrGLXferProcessor INHERITED; | 260 typedef GrGLXferProcessor INHERITED; |
| 260 }; | 261 }; |
| 261 | 262 |
| 262 /////////////////////////////////////////////////////////////////////////////// | 263 /////////////////////////////////////////////////////////////////////////////// |
| 263 | 264 |
| 264 ArithmeticXP::ArithmeticXP(float k1, float k2, float k3, float k4, bool enforceP
MColor, | 265 ArithmeticXP::ArithmeticXP(float k1, float k2, float k3, float k4, bool enforceP
MColor, |
| 265 const DstTexture* dstTexture, bool willReadDstColor) | 266 const GrDeviceCoordTexture* dstCopy, bool willReadDst
Color) |
| 266 : INHERITED(dstTexture, willReadDstColor) | 267 : INHERITED(dstCopy, willReadDstColor) |
| 267 , fK1(k1) | 268 , fK1(k1) |
| 268 , fK2(k2) | 269 , fK2(k2) |
| 269 , fK3(k3) | 270 , fK3(k3) |
| 270 , fK4(k4) | 271 , fK4(k4) |
| 271 , fEnforcePMColor(enforcePMColor) { | 272 , fEnforcePMColor(enforcePMColor) { |
| 272 this->initClassID<ArithmeticXP>(); | 273 this->initClassID<ArithmeticXP>(); |
| 273 } | 274 } |
| 274 | 275 |
| 275 void ArithmeticXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { | 276 void ArithmeticXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { |
| 276 GLArithmeticXP::GenKey(*this, caps, b); | 277 GLArithmeticXP::GenKey(*this, caps, b); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 293 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, | 294 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, |
| 294 bool enforcePMColor) | 295 bool enforcePMColor) |
| 295 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { | 296 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { |
| 296 this->initClassID<GrArithmeticXPFactory>(); | 297 this->initClassID<GrArithmeticXPFactory>(); |
| 297 } | 298 } |
| 298 | 299 |
| 299 GrXferProcessor* | 300 GrXferProcessor* |
| 300 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, | 301 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, |
| 301 const GrProcOptInfo& colorPOI, | 302 const GrProcOptInfo& colorPOI, |
| 302 const GrProcOptInfo& coveragePOI, | 303 const GrProcOptInfo& coveragePOI, |
| 303 const DstTexture* dstTexture) const
{ | 304 const GrDeviceCoordTexture* dstCopy
) const { |
| 304 return ArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstTexture, | 305 return ArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstCopy, |
| 305 this->willReadDstColor(caps, colorPOI, coverageP
OI)); | 306 this->willReadDstColor(caps, colorPOI, coverageP
OI)); |
| 306 } | 307 } |
| 307 | 308 |
| 308 | 309 |
| 309 void GrArithmeticXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, | 310 void GrArithmeticXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, |
| 310 const GrProcOptInfo& coveragePOI, | 311 const GrProcOptInfo& coveragePOI, |
| 311 GrXPFactory::InvariantOutput* out
put) const { | 312 GrXPFactory::InvariantOutput* out
put) const { |
| 312 output->fWillBlendWithDst = true; | 313 output->fWillBlendWithDst = true; |
| 313 | 314 |
| 314 // TODO: We could try to optimize this more. For example if we have solid co
verage and fK1 and | 315 // TODO: We could try to optimize this more. For example if we have solid co
verage and fK1 and |
| (...skipping 11 matching lines...) Expand all Loading... |
| 326 float k1 = random->nextF(); | 327 float k1 = random->nextF(); |
| 327 float k2 = random->nextF(); | 328 float k2 = random->nextF(); |
| 328 float k3 = random->nextF(); | 329 float k3 = random->nextF(); |
| 329 float k4 = random->nextF(); | 330 float k4 = random->nextF(); |
| 330 bool enforcePMColor = random->nextBool(); | 331 bool enforcePMColor = random->nextBool(); |
| 331 | 332 |
| 332 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 333 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
| 333 } | 334 } |
| 334 | 335 |
| 335 #endif | 336 #endif |
| OLD | NEW |