| 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 #if SK_SUPPORT_GPU | 602 #if SK_SUPPORT_GPU |
| 603 | 603 |
| 604 class GrGLRectBlurEffect; | 604 class GrGLRectBlurEffect; |
| 605 | 605 |
| 606 class GrRectBlurEffect : public GrFragmentProcessor { | 606 class GrRectBlurEffect : public GrFragmentProcessor { |
| 607 public: | 607 public: |
| 608 virtual ~GrRectBlurEffect(); | 608 virtual ~GrRectBlurEffect(); |
| 609 | 609 |
| 610 const char* name() const override { return "RectBlur"; } | 610 const char* name() const override { return "RectBlur"; } |
| 611 | 611 |
| 612 virtual void getGLProcessorKey(const GrGLCaps& caps, | 612 virtual void getGLProcessorKey(const GrGLSLCaps& caps, |
| 613 GrProcessorKeyBuilder* b) const override; | 613 GrProcessorKeyBuilder* b) const override; |
| 614 | 614 |
| 615 GrGLFragmentProcessor* createGLInstance() const override; | 615 GrGLFragmentProcessor* createGLInstance() const override; |
| 616 | 616 |
| 617 /** | 617 /** |
| 618 * Create a simple filter effect with custom bicubic coefficients. | 618 * Create a simple filter effect with custom bicubic coefficients. |
| 619 */ | 619 */ |
| 620 static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, f
loat sigma) { | 620 static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, f
loat sigma) { |
| 621 GrTexture *blurProfileTexture = NULL; | 621 GrTexture *blurProfileTexture = NULL; |
| 622 int doubleProfileSize = SkScalarCeilToInt(12*sigma); | 622 int doubleProfileSize = SkScalarCeilToInt(12*sigma); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 fSigma(sigma), | 791 fSigma(sigma), |
| 792 fBlurProfileAccess(blur_profile) { | 792 fBlurProfileAccess(blur_profile) { |
| 793 this->initClassID<GrRectBlurEffect>(); | 793 this->initClassID<GrRectBlurEffect>(); |
| 794 this->addTextureAccess(&fBlurProfileAccess); | 794 this->addTextureAccess(&fBlurProfileAccess); |
| 795 this->setWillReadFragmentPosition(); | 795 this->setWillReadFragmentPosition(); |
| 796 } | 796 } |
| 797 | 797 |
| 798 GrRectBlurEffect::~GrRectBlurEffect() { | 798 GrRectBlurEffect::~GrRectBlurEffect() { |
| 799 } | 799 } |
| 800 | 800 |
| 801 void GrRectBlurEffect::getGLProcessorKey(const GrGLCaps& caps, | 801 void GrRectBlurEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
| 802 GrProcessorKeyBuilder* b) const { | 802 GrProcessorKeyBuilder* b) const { |
| 803 GrGLRectBlurEffect::GenKey(*this, caps, b); | 803 GrGLRectBlurEffect::GenKey(*this, caps, b); |
| 804 } | 804 } |
| 805 | 805 |
| 806 GrGLFragmentProcessor* GrRectBlurEffect::createGLInstance() const { | 806 GrGLFragmentProcessor* GrRectBlurEffect::createGLInstance() const { |
| 807 return SkNEW_ARGS(GrGLRectBlurEffect, (*this)); | 807 return SkNEW_ARGS(GrGLRectBlurEffect, (*this)); |
| 808 } | 808 } |
| 809 | 809 |
| 810 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 810 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
| 811 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); | 811 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 public: | 874 public: |
| 875 | 875 |
| 876 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk
RRect&); | 876 static GrFragmentProcessor* Create(GrContext* context, float sigma, const Sk
RRect&); |
| 877 | 877 |
| 878 virtual ~GrRRectBlurEffect() {}; | 878 virtual ~GrRRectBlurEffect() {}; |
| 879 const char* name() const override { return "GrRRectBlur"; } | 879 const char* name() const override { return "GrRRectBlur"; } |
| 880 | 880 |
| 881 const SkRRect& getRRect() const { return fRRect; } | 881 const SkRRect& getRRect() const { return fRRect; } |
| 882 float getSigma() const { return fSigma; } | 882 float getSigma() const { return fSigma; } |
| 883 | 883 |
| 884 virtual void getGLProcessorKey(const GrGLCaps& caps, | 884 virtual void getGLProcessorKey(const GrGLSLCaps& caps, |
| 885 GrProcessorKeyBuilder* b) const override; | 885 GrProcessorKeyBuilder* b) const override; |
| 886 | 886 |
| 887 GrGLFragmentProcessor* createGLInstance() const override; | 887 GrGLFragmentProcessor* createGLInstance() const override; |
| 888 | 888 |
| 889 private: | 889 private: |
| 890 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); | 890 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); |
| 891 | 891 |
| 892 bool onIsEqual(const GrFragmentProcessor& other) const override; | 892 bool onIsEqual(const GrFragmentProcessor& other) const override; |
| 893 | 893 |
| 894 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 894 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 SkRect rect = rrect.getBounds(); | 1101 SkRect rect = rrect.getBounds(); |
| 1102 rect.outset(blurRadius, blurRadius); | 1102 rect.outset(blurRadius, blurRadius); |
| 1103 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot
tom); | 1103 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot
tom); |
| 1104 | 1104 |
| 1105 SkScalar radius = 0; | 1105 SkScalar radius = 0; |
| 1106 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); | 1106 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); |
| 1107 radius = rrect.getSimpleRadii().fX; | 1107 radius = rrect.getSimpleRadii().fX; |
| 1108 pdman.set1f(fCornerRadiusUniform, radius); | 1108 pdman.set1f(fCornerRadiusUniform, radius); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 void GrRRectBlurEffect::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBu
ilder* b) const { | 1111 void GrRRectBlurEffect::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKey
Builder* b) const { |
| 1112 GrGLRRectBlurEffect::GenKey(*this, caps, b); | 1112 GrGLRRectBlurEffect::GenKey(*this, caps, b); |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 GrGLFragmentProcessor* GrRRectBlurEffect::createGLInstance() const { | 1115 GrGLFragmentProcessor* GrRRectBlurEffect::createGLInstance() const { |
| 1116 return SkNEW_ARGS(GrGLRRectBlurEffect, (*this)); | 1116 return SkNEW_ARGS(GrGLRRectBlurEffect, (*this)); |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context, | 1119 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context, |
| 1120 GrRenderTarget* rt, | 1120 GrRenderTarget* rt, |
| 1121 GrPaint* grp, | 1121 GrPaint* grp, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 } else { | 1265 } else { |
| 1266 str->append("None"); | 1266 str->append("None"); |
| 1267 } | 1267 } |
| 1268 str->append("))"); | 1268 str->append("))"); |
| 1269 } | 1269 } |
| 1270 #endif | 1270 #endif |
| 1271 | 1271 |
| 1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1272 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |