| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 /////////////////////////////////////////////////////////////////////////////// | 522 /////////////////////////////////////////////////////////////////////////////// |
| 523 | 523 |
| 524 class CustomXP : public GrXferProcessor { | 524 class CustomXP : public GrXferProcessor { |
| 525 public: | 525 public: |
| 526 CustomXP(SkXfermode::Mode mode, GrBlendEquation hwBlendEquation) | 526 CustomXP(SkXfermode::Mode mode, GrBlendEquation hwBlendEquation) |
| 527 : fMode(mode), | 527 : fMode(mode), |
| 528 fHWBlendEquation(hwBlendEquation) { | 528 fHWBlendEquation(hwBlendEquation) { |
| 529 this->initClassID<CustomXP>(); | 529 this->initClassID<CustomXP>(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 CustomXP(SkXfermode::Mode mode, const DstTexture* dstTexture) | 532 CustomXP(const GrPipelineBuilder& builder, const DstTexture* dstTexture, SkX
fermode::Mode mode) |
| 533 : INHERITED(dstTexture, true), | 533 : INHERITED(builder, dstTexture, true), |
| 534 fMode(mode), | 534 fMode(mode), |
| 535 fHWBlendEquation(static_cast<GrBlendEquation>(-1)) { | 535 fHWBlendEquation(static_cast<GrBlendEquation>(-1)) { |
| 536 this->initClassID<CustomXP>(); | 536 this->initClassID<CustomXP>(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 const char* name() const override { return "Custom Xfermode"; } | 539 const char* name() const override { return "Custom Xfermode"; } |
| 540 | 540 |
| 541 GrGLXferProcessor* createGLInstance() const override; | 541 GrGLXferProcessor* createGLInstance() const override; |
| 542 | 542 |
| 543 bool hasSecondaryOutput() const override { return false; } | |
| 544 | |
| 545 SkXfermode::Mode mode() const { return fMode; } | 543 SkXfermode::Mode mode() const { return fMode; } |
| 546 bool hasHWBlendEquation() const { return -1 != static_cast<int>(fHWBlendEqua
tion); } | 544 bool hasHWBlendEquation() const { return -1 != static_cast<int>(fHWBlendEqua
tion); } |
| 547 | 545 |
| 548 GrBlendEquation hwBlendEquation() const { | 546 GrBlendEquation hwBlendEquation() const { |
| 549 SkASSERT(this->hasHWBlendEquation()); | 547 SkASSERT(this->hasHWBlendEquation()); |
| 550 return fHWBlendEquation; | 548 return fHWBlendEquation; |
| 551 } | 549 } |
| 552 | 550 |
| 553 private: | 551 private: |
| 554 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 552 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 | 784 |
| 787 GrCustomXPFactory::GrCustomXPFactory(SkXfermode::Mode mode) | 785 GrCustomXPFactory::GrCustomXPFactory(SkXfermode::Mode mode) |
| 788 : fMode(mode), | 786 : fMode(mode), |
| 789 fHWBlendEquation(hw_blend_equation(mode)) { | 787 fHWBlendEquation(hw_blend_equation(mode)) { |
| 790 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); | 788 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); |
| 791 this->initClassID<GrCustomXPFactory>(); | 789 this->initClassID<GrCustomXPFactory>(); |
| 792 } | 790 } |
| 793 | 791 |
| 794 GrXferProcessor* | 792 GrXferProcessor* |
| 795 GrCustomXPFactory::onCreateXferProcessor(const GrCaps& caps, | 793 GrCustomXPFactory::onCreateXferProcessor(const GrCaps& caps, |
| 794 const GrPipelineBuilder& builder, |
| 796 const GrProcOptInfo& colorPOI, | 795 const GrProcOptInfo& colorPOI, |
| 797 const GrProcOptInfo& coveragePOI, | 796 const GrProcOptInfo& coveragePOI, |
| 798 const DstTexture* dstTexture) const { | 797 const DstTexture* dstTexture) const { |
| 799 if (can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps)) { | 798 if (can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps)) { |
| 800 SkASSERT(!dstTexture || !dstTexture->texture()); | 799 SkASSERT(!dstTexture || !dstTexture->texture()); |
| 801 return SkNEW_ARGS(CustomXP, (fMode, fHWBlendEquation)); | 800 return SkNEW_ARGS(CustomXP, (fMode, fHWBlendEquation)); |
| 802 } | 801 } |
| 803 return SkNEW_ARGS(CustomXP, (fMode, dstTexture)); | 802 return SkNEW_ARGS(CustomXP, (builder, dstTexture, fMode)); |
| 804 } | 803 } |
| 805 | 804 |
| 806 bool GrCustomXPFactory::willReadDstColor(const GrCaps& caps, | 805 bool GrCustomXPFactory::willReadDstColor(const GrCaps& caps, |
| 806 const GrPipelineBuilder&, |
| 807 const GrProcOptInfo& colorPOI, | 807 const GrProcOptInfo& colorPOI, |
| 808 const GrProcOptInfo& coveragePOI) const
{ | 808 const GrProcOptInfo& coveragePOI) const
{ |
| 809 return !can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps); | 809 return !can_use_hw_blend_equation(fHWBlendEquation, coveragePOI, caps); |
| 810 } | 810 } |
| 811 | 811 |
| 812 void GrCustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | 812 void GrCustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 813 InvariantBlendedColor* blendedC
olor) const { | 813 InvariantBlendedColor* blendedC
olor) const { |
| 814 blendedColor->fWillBlendWithDst = true; | 814 blendedColor->fWillBlendWithDst = true; |
| 815 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 815 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 816 } | 816 } |
| 817 | 817 |
| 818 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); | 818 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); |
| 819 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand, | 819 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand, |
| 820 GrContext*, | 820 GrContext*, |
| 821 const GrCaps&, | 821 const GrCaps&, |
| 822 GrTexture*[]) { | 822 GrTexture*[]) { |
| 823 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas
tSeparableMode); | 823 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas
tSeparableMode); |
| 824 | 824 |
| 825 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); | 825 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); |
| 826 } | 826 } |
| 827 | 827 |
| OLD | NEW |