| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "effects/GrPorterDuffXferProcessor.h" | 8 #include "effects/GrPorterDuffXferProcessor.h" |
| 9 | 9 |
| 10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 static BlendFormula get_unoptimized_blend_formula(SkXfermode::Mode xfermode) { | 300 static BlendFormula get_unoptimized_blend_formula(SkXfermode::Mode xfermode) { |
| 301 SkASSERT(xfermode >= 0 && xfermode <= SkXfermode::kLastCoeffMode); | 301 SkASSERT(xfermode >= 0 && xfermode <= SkXfermode::kLastCoeffMode); |
| 302 | 302 |
| 303 return gBlendTable[0][0][xfermode]; | 303 return gBlendTable[0][0][xfermode]; |
| 304 } | 304 } |
| 305 | 305 |
| 306 /////////////////////////////////////////////////////////////////////////////// | 306 /////////////////////////////////////////////////////////////////////////////// |
| 307 | 307 |
| 308 class PorterDuffXferProcessor : public GrXferProcessor { | 308 class PorterDuffXferProcessor : public GrXferProcessor { |
| 309 public: | 309 public: |
| 310 static GrXferProcessor* Create(SkXfermode::Mode xfermode, const DstTexture*
dstTexture, | 310 static GrXferProcessor* Create(SkXfermode::Mode xfermode, const GrDeviceCoor
dTexture* dstCopy, |
| 311 bool willReadDstColor) { | 311 bool willReadDstColor) { |
| 312 return SkNEW_ARGS(PorterDuffXferProcessor, (xfermode, dstTexture, willRe
adDstColor)); | 312 return SkNEW_ARGS(PorterDuffXferProcessor, (xfermode, dstCopy, willReadD
stColor)); |
| 313 } | 313 } |
| 314 | 314 |
| 315 ~PorterDuffXferProcessor() override; | 315 ~PorterDuffXferProcessor() override; |
| 316 | 316 |
| 317 const char* name() const override { return "Porter Duff"; } | 317 const char* name() const override { return "Porter Duff"; } |
| 318 | 318 |
| 319 GrGLXferProcessor* createGLInstance() const override; | 319 GrGLXferProcessor* createGLInstance() const override; |
| 320 | 320 |
| 321 bool hasSecondaryOutput() const override { | 321 bool hasSecondaryOutput() const override { |
| 322 return fBlendFormula.hasSecondaryOutput(); | 322 return fBlendFormula.hasSecondaryOutput(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 SkXfermode::Mode getXfermode() const { return fXfermode; } | 325 SkXfermode::Mode getXfermode() const { return fXfermode; } |
| 326 BlendFormula getBlendFormula() const { return fBlendFormula; } | 326 BlendFormula getBlendFormula() const { return fBlendFormula; } |
| 327 | 327 |
| 328 private: | 328 private: |
| 329 PorterDuffXferProcessor(SkXfermode::Mode, const DstTexture*, bool willReadDs
tColor); | 329 PorterDuffXferProcessor(SkXfermode::Mode, const GrDeviceCoordTexture* dstCop
y, |
| 330 bool willReadDstColor); |
| 330 | 331 |
| 331 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 332 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
| 332 const GrProcOptInfo& coveragePO
I, | 333 const GrProcOptInfo& coveragePO
I, |
| 333 bool doesStencilWrite, | 334 bool doesStencilWrite, |
| 334 GrColor* overrideColor, | 335 GrColor* overrideColor, |
| 335 const GrCaps& caps) override; | 336 const GrCaps& caps) override; |
| 336 | 337 |
| 337 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | 338 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
| 338 | 339 |
| 339 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { | 340 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 } | 499 } |
| 499 | 500 |
| 500 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {}; | 501 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {}; |
| 501 | 502 |
| 502 typedef GrGLXferProcessor INHERITED; | 503 typedef GrGLXferProcessor INHERITED; |
| 503 }; | 504 }; |
| 504 | 505 |
| 505 /////////////////////////////////////////////////////////////////////////////// | 506 /////////////////////////////////////////////////////////////////////////////// |
| 506 | 507 |
| 507 PorterDuffXferProcessor::PorterDuffXferProcessor(SkXfermode::Mode xfermode, | 508 PorterDuffXferProcessor::PorterDuffXferProcessor(SkXfermode::Mode xfermode, |
| 508 const DstTexture* dstTexture, | 509 const GrDeviceCoordTexture* dst
Copy, |
| 509 bool willReadDstColor) | 510 bool willReadDstColor) |
| 510 : INHERITED(dstTexture, willReadDstColor) | 511 : INHERITED(dstCopy, willReadDstColor) |
| 511 , fXfermode(xfermode) | 512 , fXfermode(xfermode) |
| 512 , fBlendFormula(get_unoptimized_blend_formula(xfermode)) { | 513 , fBlendFormula(get_unoptimized_blend_formula(xfermode)) { |
| 513 this->initClassID<PorterDuffXferProcessor>(); | 514 this->initClassID<PorterDuffXferProcessor>(); |
| 514 } | 515 } |
| 515 | 516 |
| 516 PorterDuffXferProcessor::~PorterDuffXferProcessor() { | 517 PorterDuffXferProcessor::~PorterDuffXferProcessor() { |
| 517 } | 518 } |
| 518 | 519 |
| 519 void PorterDuffXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps, | 520 void PorterDuffXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 520 GrProcessorKeyBuilder* b) cons
t { | 521 GrProcessorKeyBuilder* b) cons
t { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) { | 716 if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) { |
| 716 return NULL; | 717 return NULL; |
| 717 } | 718 } |
| 718 return SkRef(gFactories[xfermode]); | 719 return SkRef(gFactories[xfermode]); |
| 719 } | 720 } |
| 720 | 721 |
| 721 GrXferProcessor* | 722 GrXferProcessor* |
| 722 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, | 723 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, |
| 723 const GrProcOptInfo& colorPOI, | 724 const GrProcOptInfo& colorPOI, |
| 724 const GrProcOptInfo& covPOI, | 725 const GrProcOptInfo& covPOI, |
| 725 const DstTexture* dstTexture) const
{ | 726 const GrDeviceCoordTexture* dstCopy
) const { |
| 726 if (covPOI.isFourChannelOutput()) { | 727 if (covPOI.isFourChannelOutput()) { |
| 727 return PDLCDXferProcessor::Create(fXfermode, colorPOI); | 728 return PDLCDXferProcessor::Create(fXfermode, colorPOI); |
| 728 } else { | 729 } else { |
| 729 return PorterDuffXferProcessor::Create(fXfermode, dstTexture, | 730 return PorterDuffXferProcessor::Create(fXfermode, dstCopy, |
| 730 this->willReadDstColor(caps, colo
rPOI, covPOI)); | 731 this->willReadDstColor(caps, colo
rPOI, covPOI)); |
| 731 } | 732 } |
| 732 } | 733 } |
| 733 | 734 |
| 734 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, | 735 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, |
| 735 uint32_t knownColorFlags) const
{ | 736 uint32_t knownColorFlags) const
{ |
| 736 if (SkXfermode::kSrcOver_Mode == fXfermode && | 737 if (SkXfermode::kSrcOver_Mode == fXfermode && |
| 737 kRGBA_GrColorComponentFlags == knownColorFlags) { | 738 kRGBA_GrColorComponentFlags == knownColorFlags) { |
| 738 return true; | 739 return true; |
| 739 } | 740 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 int* outSecondary) { | 805 int* outSecondary) { |
| 805 if (!!strcmp(xp->name(), "Porter Duff")) { | 806 if (!!strcmp(xp->name(), "Porter Duff")) { |
| 806 *outPrimary = *outSecondary = -1; | 807 *outPrimary = *outSecondary = -1; |
| 807 return; | 808 return; |
| 808 } | 809 } |
| 809 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); | 810 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); |
| 810 *outPrimary = blendFormula.fPrimaryOutputType; | 811 *outPrimary = blendFormula.fPrimaryOutputType; |
| 811 *outSecondary = blendFormula.fSecondaryOutputType; | 812 *outSecondary = blendFormula.fSecondaryOutputType; |
| 812 } | 813 } |
| 813 | 814 |
| OLD | NEW |