Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: src/effects/SkBlurMaskFilter.cpp

Issue 1661143003: Next round of GrGLSLFragmentProcessor-derived class cleanup (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix overlength line Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.cpp ('k') | src/effects/SkDisplacementMapEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkBlurMaskFilter.h" 8 #include "SkBlurMaskFilter.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkGpuBlurUtils.h" 10 #include "SkGpuBlurUtils.h"
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 precision = kHigh_GrSLPrecision; 639 precision = kHigh_GrSLPrecision;
640 } 640 }
641 else { 641 else {
642 precision = kDefault_GrSLPrecision; 642 precision = kDefault_GrSLPrecision;
643 } 643 }
644 return new GrRectBlurEffect(rect, sigma, blurProfile, precision); 644 return new GrRectBlurEffect(rect, sigma, blurProfile, precision);
645 } 645 }
646 646
647 const SkRect& getRect() const { return fRect; } 647 const SkRect& getRect() const { return fRect; }
648 float getSigma() const { return fSigma; } 648 float getSigma() const { return fSigma; }
649 GrSLPrecision precision() const { return fPrecision; }
649 650
650 private: 651 private:
651 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blurProfile, 652 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blurProfile,
652 GrSLPrecision fPrecision); 653 GrSLPrecision fPrecision);
653 654
654 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; 655 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
655 656
656 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override; 657 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
657 658
658 bool onIsEqual(const GrFragmentProcessor&) const override; 659 bool onIsEqual(const GrFragmentProcessor&) const override;
659 660
660 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 661 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
661 662
662 static GrTexture* CreateBlurProfileTexture(GrTextureProvider*, float sigma); 663 static GrTexture* CreateBlurProfileTexture(GrTextureProvider*, float sigma);
663 664
664 SkRect fRect; 665 SkRect fRect;
665 float fSigma; 666 float fSigma;
666 GrTextureAccess fBlurProfileAccess; 667 GrTextureAccess fBlurProfileAccess;
667 GrSLPrecision fPrecision; 668 GrSLPrecision fPrecision;
668 669
669 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 670 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
670 671
671 typedef GrFragmentProcessor INHERITED; 672 typedef GrFragmentProcessor INHERITED;
672 }; 673 };
673 674
674 class GrGLRectBlurEffect : public GrGLSLFragmentProcessor { 675 class GrGLRectBlurEffect : public GrGLSLFragmentProcessor {
675 public: 676 public:
676 GrGLRectBlurEffect(const GrProcessor&, GrSLPrecision precision)
677 : fPrecision(precision) {
678 }
679 void emitCode(EmitArgs&) override; 677 void emitCode(EmitArgs&) override;
680 678
681 static void GenKey(GrSLPrecision precision, GrProcessorKeyBuilder* b); 679 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil der* b);
682 680
683 protected: 681 protected:
684 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 682 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
685 683
686 private: 684 private:
687 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; 685 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
688 686
689 UniformHandle fProxyRectUniform; 687 UniformHandle fProxyRectUniform;
690 UniformHandle fProfileSizeUniform; 688 UniformHandle fProfileSizeUniform;
691 GrSLPrecision fPrecision;
692 689
693 typedef GrGLSLFragmentProcessor INHERITED; 690 typedef GrGLSLFragmentProcessor INHERITED;
694 }; 691 };
695 692
696 void OutputRectBlurProfileLookup(GrGLSLFragmentBuilder* fragBuilder, 693 void OutputRectBlurProfileLookup(GrGLSLFragmentBuilder* fragBuilder,
697 const GrGLSLTextureSampler& sampler, 694 const GrGLSLTextureSampler& sampler,
698 const char *output, 695 const char *output,
699 const char *profileSize, const char *loc, 696 const char *profileSize, const char *loc,
700 const char *blurred_width, 697 const char *blurred_width,
701 const char *sharp_width) { 698 const char *sharp_width) {
702 fragBuilder->codeAppendf("float %s;", output); 699 fragBuilder->codeAppendf("float %s;", output);
703 fragBuilder->codeAppendf("{"); 700 fragBuilder->codeAppendf("{");
704 fragBuilder->codeAppendf("float coord = ((abs(%s - 0.5 * %s) - 0.5 * %s)) / %s;", 701 fragBuilder->codeAppendf("float coord = ((abs(%s - 0.5 * %s) - 0.5 * %s)) / %s;",
705 loc, blurred_width, sharp_width, profileSize); 702 loc, blurred_width, sharp_width, profileSize);
706 fragBuilder->codeAppendf("%s = ", output); 703 fragBuilder->codeAppendf("%s = ", output);
707 fragBuilder->appendTextureLookup(sampler, "vec2(coord,0.5)"); 704 fragBuilder->appendTextureLookup(sampler, "vec2(coord,0.5)");
708 fragBuilder->codeAppend(".a;"); 705 fragBuilder->codeAppend(".a;");
709 fragBuilder->codeAppendf("}"); 706 fragBuilder->codeAppendf("}");
710 } 707 }
711 708
712 709
713 void GrGLRectBlurEffect::GenKey(GrSLPrecision precision, GrProcessorKeyBuilder* b) { 710 void GrGLRectBlurEffect::GenKey(const GrProcessor& proc, const GrGLSLCaps&,
714 b->add32(precision); 711 GrProcessorKeyBuilder* b) {
712 const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>();
713
714 b->add32(rbe.precision());
715 } 715 }
716 716
717 717
718 void GrGLRectBlurEffect::emitCode(EmitArgs& args) { 718 void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
719 const GrRectBlurEffect& rbe = args.fFp.cast<GrRectBlurEffect>();
720
719 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 721 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
720 722
721 const char *rectName; 723 const char *rectName;
722 const char *profileSizeName; 724 const char *profileSizeName;
723 725
724 const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fGLSLCap s, fPrecision); 726 const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fGLSLCap s, rbe.precision());
725 fProxyRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragme nt_Visibility, 727 fProxyRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragme nt_Visibility,
726 kVec4f_GrSLType, 728 kVec4f_GrSLType,
727 fPrecision, 729 rbe.precision(),
728 "proxyRect", 730 "proxyRect",
729 &rectName); 731 &rectName);
730 fProfileSizeUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFrag ment_Visibility, 732 fProfileSizeUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFrag ment_Visibility,
731 kFloat_GrSLType, 733 kFloat_GrSLType,
732 kDefault_GrSLPrecision, 734 kDefault_GrSLPrecision,
733 "profileSize", 735 "profileSize",
734 &profileSizeName); 736 &profileSizeName);
735 737
736 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 738 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
737 const char *fragmentPos = fragBuilder->fragmentPosition(); 739 const char *fragmentPos = fragBuilder->fragmentPosition();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 , fSigma(sigma) 809 , fSigma(sigma)
808 , fBlurProfileAccess(blurProfile) 810 , fBlurProfileAccess(blurProfile)
809 , fPrecision(precision) { 811 , fPrecision(precision) {
810 this->initClassID<GrRectBlurEffect>(); 812 this->initClassID<GrRectBlurEffect>();
811 this->addTextureAccess(&fBlurProfileAccess); 813 this->addTextureAccess(&fBlurProfileAccess);
812 this->setWillReadFragmentPosition(); 814 this->setWillReadFragmentPosition();
813 } 815 }
814 816
815 void GrRectBlurEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, 817 void GrRectBlurEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
816 GrProcessorKeyBuilder* b) const { 818 GrProcessorKeyBuilder* b) const {
817 GrGLRectBlurEffect::GenKey(fPrecision, b); 819 GrGLRectBlurEffect::GenKey(*this, caps, b);
818 } 820 }
819 821
820 GrGLSLFragmentProcessor* GrRectBlurEffect::onCreateGLSLInstance() const { 822 GrGLSLFragmentProcessor* GrRectBlurEffect::onCreateGLSLInstance() const {
821 return new GrGLRectBlurEffect(*this, fPrecision); 823 return new GrGLRectBlurEffect;
822 } 824 }
823 825
824 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 826 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
825 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); 827 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>();
826 return this->getSigma() == s.getSigma() && this->getRect() == s.getRect(); 828 return this->getSigma() == s.getSigma() && this->getRect() == s.getRect();
827 } 829 }
828 830
829 void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 831 void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
830 inout->mulByUnknownSingleComponent(); 832 inout->mulByUnknownSingleComponent();
831 } 833 }
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 } else { 1304 } else {
1303 str->append("None"); 1305 str->append("None");
1304 } 1306 }
1305 str->append("))"); 1307 str->append("))");
1306 } 1308 }
1307 #endif 1309 #endif
1308 1310
1309 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1311 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1310 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1312 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1311 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1313 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.cpp ('k') | src/effects/SkDisplacementMapEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698