| 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 "effects/GrCustomXfermode.h" | 8 #include "effects/GrCustomXfermode.h" |
| 9 #include "effects/GrCustomXfermodePriv.h" | 9 #include "effects/GrCustomXfermodePriv.h" |
| 10 | 10 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 501 |
| 502 return SkNEW_ARGS(GrCustomXferFP, (static_cast<SkXfermode::Mode>(mode), text
ures[0])); | 502 return SkNEW_ARGS(GrCustomXferFP, (static_cast<SkXfermode::Mode>(mode), text
ures[0])); |
| 503 } | 503 } |
| 504 | 504 |
| 505 /////////////////////////////////////////////////////////////////////////////// | 505 /////////////////////////////////////////////////////////////////////////////// |
| 506 // Xfer Processor | 506 // Xfer Processor |
| 507 /////////////////////////////////////////////////////////////////////////////// | 507 /////////////////////////////////////////////////////////////////////////////// |
| 508 | 508 |
| 509 class CustomXP : public GrXferProcessor { | 509 class CustomXP : public GrXferProcessor { |
| 510 public: | 510 public: |
| 511 static GrXferProcessor* Create(SkXfermode::Mode mode, const DstTexture* dstT
exture, | 511 static GrXferProcessor* Create(SkXfermode::Mode mode, const GrDeviceCoordTex
ture* dstCopy, |
| 512 bool willReadDstColor) { | 512 bool willReadDstColor) { |
| 513 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 513 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
| 514 return NULL; | 514 return NULL; |
| 515 } else { | 515 } else { |
| 516 return SkNEW_ARGS(CustomXP, (mode, dstTexture, willReadDstColor)); | 516 return SkNEW_ARGS(CustomXP, (mode, dstCopy, willReadDstColor)); |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 ~CustomXP() override {}; | 520 ~CustomXP() override {}; |
| 521 | 521 |
| 522 const char* name() const override { return "Custom Xfermode"; } | 522 const char* name() const override { return "Custom Xfermode"; } |
| 523 | 523 |
| 524 GrGLXferProcessor* createGLInstance() const override; | 524 GrGLXferProcessor* createGLInstance() const override; |
| 525 | 525 |
| 526 bool hasSecondaryOutput() const override { return false; } | 526 bool hasSecondaryOutput() const override { return false; } |
| 527 | 527 |
| 528 SkXfermode::Mode mode() const { return fMode; } | 528 SkXfermode::Mode mode() const { return fMode; } |
| 529 bool hasHWBlendEquation() const { return -1 != static_cast<int>(fHWBlendEqua
tion); } | 529 bool hasHWBlendEquation() const { return -1 != static_cast<int>(fHWBlendEqua
tion); } |
| 530 | 530 |
| 531 GrBlendEquation hwBlendEquation() const { | 531 GrBlendEquation hwBlendEquation() const { |
| 532 SkASSERT(this->hasHWBlendEquation()); | 532 SkASSERT(this->hasHWBlendEquation()); |
| 533 return fHWBlendEquation; | 533 return fHWBlendEquation; |
| 534 } | 534 } |
| 535 | 535 |
| 536 private: | 536 private: |
| 537 CustomXP(SkXfermode::Mode mode, const DstTexture*, bool willReadDstColor); | 537 CustomXP(SkXfermode::Mode mode, const GrDeviceCoordTexture* dstCopy, bool wi
llReadDstColor); |
| 538 | 538 |
| 539 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 539 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
| 540 const GrProcOptInfo& coveragePO
I, | 540 const GrProcOptInfo& coveragePO
I, |
| 541 bool doesStencilWrite, | 541 bool doesStencilWrite, |
| 542 GrColor* overrideColor, | 542 GrColor* overrideColor, |
| 543 const GrCaps& caps) override; | 543 const GrCaps& caps) override; |
| 544 | 544 |
| 545 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | 545 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
| 546 | 546 |
| 547 bool onWillNeedXferBarrier(const GrRenderTarget* rt, | 547 bool onWillNeedXferBarrier(const GrRenderTarget* rt, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 } | 619 } |
| 620 } | 620 } |
| 621 | 621 |
| 622 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {} | 622 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {} |
| 623 | 623 |
| 624 typedef GrGLFragmentProcessor INHERITED; | 624 typedef GrGLFragmentProcessor INHERITED; |
| 625 }; | 625 }; |
| 626 | 626 |
| 627 /////////////////////////////////////////////////////////////////////////////// | 627 /////////////////////////////////////////////////////////////////////////////// |
| 628 | 628 |
| 629 CustomXP::CustomXP(SkXfermode::Mode mode, const DstTexture* dstTexture, bool wil
lReadDstColor) | 629 CustomXP::CustomXP(SkXfermode::Mode mode, const GrDeviceCoordTexture* dstCopy, |
| 630 : INHERITED(dstTexture, willReadDstColor), | 630 bool willReadDstColor) |
| 631 : INHERITED(dstCopy, willReadDstColor), |
| 631 fMode(mode), | 632 fMode(mode), |
| 632 fHWBlendEquation(static_cast<GrBlendEquation>(-1)) { | 633 fHWBlendEquation(static_cast<GrBlendEquation>(-1)) { |
| 633 this->initClassID<CustomXP>(); | 634 this->initClassID<CustomXP>(); |
| 634 } | 635 } |
| 635 | 636 |
| 636 void CustomXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder
* b) const { | 637 void CustomXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder
* b) const { |
| 637 GLCustomXP::GenKey(*this, caps, b); | 638 GLCustomXP::GenKey(*this, caps, b); |
| 638 } | 639 } |
| 639 | 640 |
| 640 GrGLXferProcessor* CustomXP::createGLInstance() const { | 641 GrGLXferProcessor* CustomXP::createGLInstance() const { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 783 |
| 783 GrCustomXPFactory::GrCustomXPFactory(SkXfermode::Mode mode) | 784 GrCustomXPFactory::GrCustomXPFactory(SkXfermode::Mode mode) |
| 784 : fMode(mode) { | 785 : fMode(mode) { |
| 785 this->initClassID<GrCustomXPFactory>(); | 786 this->initClassID<GrCustomXPFactory>(); |
| 786 } | 787 } |
| 787 | 788 |
| 788 GrXferProcessor* | 789 GrXferProcessor* |
| 789 GrCustomXPFactory::onCreateXferProcessor(const GrCaps& caps, | 790 GrCustomXPFactory::onCreateXferProcessor(const GrCaps& caps, |
| 790 const GrProcOptInfo& colorPOI, | 791 const GrProcOptInfo& colorPOI, |
| 791 const GrProcOptInfo& coveragePOI, | 792 const GrProcOptInfo& coveragePOI, |
| 792 const DstTexture* dstTexture) const { | 793 const GrDeviceCoordTexture* dstCopy) co
nst { |
| 793 return CustomXP::Create(fMode, dstTexture, this->willReadDstColor(caps, colo
rPOI, coveragePOI)); | 794 return CustomXP::Create(fMode, dstCopy, this->willReadDstColor(caps, colorPO
I, coveragePOI)); |
| 794 } | 795 } |
| 795 | 796 |
| 796 bool GrCustomXPFactory::willReadDstColor(const GrCaps& caps, | 797 bool GrCustomXPFactory::willReadDstColor(const GrCaps& caps, |
| 797 const GrProcOptInfo& colorPOI, | 798 const GrProcOptInfo& colorPOI, |
| 798 const GrProcOptInfo& coveragePOI) const
{ | 799 const GrProcOptInfo& coveragePOI) const
{ |
| 799 if (!caps.advancedBlendEquationSupport()) { | 800 if (!caps.advancedBlendEquationSupport()) { |
| 800 // No hardware support for advanced blend equations; we will need to do
it in the shader. | 801 // No hardware support for advanced blend equations; we will need to do
it in the shader. |
| 801 return true; | 802 return true; |
| 802 } | 803 } |
| 803 if (coveragePOI.isFourChannelOutput()) { | 804 if (coveragePOI.isFourChannelOutput()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 817 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); | 818 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); |
| 818 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand, | 819 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand, |
| 819 GrContext*, | 820 GrContext*, |
| 820 const GrCaps&, | 821 const GrCaps&, |
| 821 GrTexture*[]) { | 822 GrTexture*[]) { |
| 822 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas
tSeparableMode); | 823 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas
tSeparableMode); |
| 823 | 824 |
| 824 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); | 825 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); |
| 825 } | 826 } |
| 826 | 827 |
| OLD | NEW |