OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 #if SK_SUPPORT_GPU | 604 #if SK_SUPPORT_GPU |
605 | 605 |
606 class GrGLRectBlurEffect; | 606 class GrGLRectBlurEffect; |
607 | 607 |
608 class GrRectBlurEffect : public GrFragmentProcessor { | 608 class GrRectBlurEffect : public GrFragmentProcessor { |
609 public: | 609 public: |
610 virtual ~GrRectBlurEffect(); | 610 virtual ~GrRectBlurEffect(); |
611 | 611 |
612 const char* name() const override { return "RectBlur"; } | 612 const char* name() const override { return "RectBlur"; } |
613 | 613 |
614 virtual void getGLProcessorKey(const GrGLSLCaps& caps, | |
615 GrProcessorKeyBuilder* b) const override; | |
616 | |
617 GrGLFragmentProcessor* createGLInstance() const override; | 614 GrGLFragmentProcessor* createGLInstance() const override; |
618 | 615 |
619 /** | 616 /** |
620 * Create a simple filter effect with custom bicubic coefficients. | 617 * Create a simple filter effect with custom bicubic coefficients. |
621 */ | 618 */ |
622 static GrFragmentProcessor* Create(GrTextureProvider *textureProvider, const
SkRect& rect, | 619 static GrFragmentProcessor* Create(GrTextureProvider *textureProvider, const
SkRect& rect, |
623 float sigma) { | 620 float sigma) { |
624 GrTexture *blurProfileTexture = NULL; | 621 GrTexture *blurProfileTexture = NULL; |
625 int doubleProfileSize = SkScalarCeilToInt(12*sigma); | 622 int doubleProfileSize = SkScalarCeilToInt(12*sigma); |
626 | 623 |
(...skipping 11 matching lines...) Expand all Loading... |
638 return NULL; | 635 return NULL; |
639 } | 636 } |
640 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); | 637 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); |
641 } | 638 } |
642 | 639 |
643 const SkRect& getRect() const { return fRect; } | 640 const SkRect& getRect() const { return fRect; } |
644 float getSigma() const { return fSigma; } | 641 float getSigma() const { return fSigma; } |
645 | 642 |
646 private: | 643 private: |
647 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); | 644 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); |
| 645 |
| 646 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 647 GrProcessorKeyBuilder* b) const override; |
| 648 |
648 bool onIsEqual(const GrFragmentProcessor&) const override; | 649 bool onIsEqual(const GrFragmentProcessor&) const override; |
649 | 650 |
650 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 651 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
651 | 652 |
652 static bool CreateBlurProfileTexture(GrTextureProvider*, float sigma, | 653 static bool CreateBlurProfileTexture(GrTextureProvider*, float sigma, |
653 GrTexture **blurProfileTexture); | 654 GrTexture **blurProfileTexture); |
654 | 655 |
655 SkRect fRect; | 656 SkRect fRect; |
656 float fSigma; | 657 float fSigma; |
657 GrTextureAccess fBlurProfileAccess; | 658 GrTextureAccess fBlurProfileAccess; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 fSigma(sigma), | 788 fSigma(sigma), |
788 fBlurProfileAccess(blur_profile) { | 789 fBlurProfileAccess(blur_profile) { |
789 this->initClassID<GrRectBlurEffect>(); | 790 this->initClassID<GrRectBlurEffect>(); |
790 this->addTextureAccess(&fBlurProfileAccess); | 791 this->addTextureAccess(&fBlurProfileAccess); |
791 this->setWillReadFragmentPosition(); | 792 this->setWillReadFragmentPosition(); |
792 } | 793 } |
793 | 794 |
794 GrRectBlurEffect::~GrRectBlurEffect() { | 795 GrRectBlurEffect::~GrRectBlurEffect() { |
795 } | 796 } |
796 | 797 |
797 void GrRectBlurEffect::getGLProcessorKey(const GrGLSLCaps& caps, | 798 void GrRectBlurEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
798 GrProcessorKeyBuilder* b) const { | 799 GrProcessorKeyBuilder* b) const { |
799 GrGLRectBlurEffect::GenKey(*this, caps, b); | 800 GrGLRectBlurEffect::GenKey(*this, caps, b); |
800 } | 801 } |
801 | 802 |
802 GrGLFragmentProcessor* GrRectBlurEffect::createGLInstance() const { | 803 GrGLFragmentProcessor* GrRectBlurEffect::createGLInstance() const { |
803 return SkNEW_ARGS(GrGLRectBlurEffect, (*this)); | 804 return SkNEW_ARGS(GrGLRectBlurEffect, (*this)); |
804 } | 805 } |
805 | 806 |
806 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 807 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
807 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); | 808 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 public: | 873 public: |
873 | 874 |
874 static GrFragmentProcessor* Create(GrTextureProvider*, float sigma, const Sk
RRect&); | 875 static GrFragmentProcessor* Create(GrTextureProvider*, float sigma, const Sk
RRect&); |
875 | 876 |
876 virtual ~GrRRectBlurEffect() {}; | 877 virtual ~GrRRectBlurEffect() {}; |
877 const char* name() const override { return "GrRRectBlur"; } | 878 const char* name() const override { return "GrRRectBlur"; } |
878 | 879 |
879 const SkRRect& getRRect() const { return fRRect; } | 880 const SkRRect& getRRect() const { return fRRect; } |
880 float getSigma() const { return fSigma; } | 881 float getSigma() const { return fSigma; } |
881 | 882 |
882 virtual void getGLProcessorKey(const GrGLSLCaps& caps, | |
883 GrProcessorKeyBuilder* b) const override; | |
884 | |
885 GrGLFragmentProcessor* createGLInstance() const override; | 883 GrGLFragmentProcessor* createGLInstance() const override; |
886 | 884 |
887 private: | 885 private: |
888 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); | 886 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); |
889 | 887 |
| 888 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 889 GrProcessorKeyBuilder* b) const override; |
| 890 |
890 bool onIsEqual(const GrFragmentProcessor& other) const override; | 891 bool onIsEqual(const GrFragmentProcessor& other) const override; |
891 | 892 |
892 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 893 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
893 | 894 |
894 SkRRect fRRect; | 895 SkRRect fRRect; |
895 float fSigma; | 896 float fSigma; |
896 GrTextureAccess fNinePatchAccess; | 897 GrTextureAccess fNinePatchAccess; |
897 | 898 |
898 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 899 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
899 | 900 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 SkRect rect = rrect.getBounds(); | 1088 SkRect rect = rrect.getBounds(); |
1088 rect.outset(blurRadius, blurRadius); | 1089 rect.outset(blurRadius, blurRadius); |
1089 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot
tom); | 1090 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot
tom); |
1090 | 1091 |
1091 SkScalar radius = 0; | 1092 SkScalar radius = 0; |
1092 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); | 1093 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); |
1093 radius = rrect.getSimpleRadii().fX; | 1094 radius = rrect.getSimpleRadii().fX; |
1094 pdman.set1f(fCornerRadiusUniform, radius); | 1095 pdman.set1f(fCornerRadiusUniform, radius); |
1095 } | 1096 } |
1096 | 1097 |
1097 void GrRRectBlurEffect::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKey
Builder* b) const { | 1098 void GrRRectBlurEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK
eyBuilder* b) const { |
1098 GrGLRRectBlurEffect::GenKey(*this, caps, b); | 1099 GrGLRRectBlurEffect::GenKey(*this, caps, b); |
1099 } | 1100 } |
1100 | 1101 |
1101 GrGLFragmentProcessor* GrRRectBlurEffect::createGLInstance() const { | 1102 GrGLFragmentProcessor* GrRRectBlurEffect::createGLInstance() const { |
1102 return SkNEW_ARGS(GrGLRRectBlurEffect, (*this)); | 1103 return SkNEW_ARGS(GrGLRRectBlurEffect, (*this)); |
1103 } | 1104 } |
1104 | 1105 |
1105 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
er, | 1106 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
er, |
1106 GrDrawContext* drawContext, | 1107 GrDrawContext* drawContext, |
1107 GrRenderTarget* rt, | 1108 GrRenderTarget* rt, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 } else { | 1264 } else { |
1264 str->append("None"); | 1265 str->append("None"); |
1265 } | 1266 } |
1266 str->append("))"); | 1267 str->append("))"); |
1267 } | 1268 } |
1268 #endif | 1269 #endif |
1269 | 1270 |
1270 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1271 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1271 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1272 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |