| 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" |
| 11 #include "SkGpuBlurUtils.h" | 11 #include "SkGpuBlurUtils.h" |
| 12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
| 13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
| 14 #include "SkMaskFilter.h" | 14 #include "SkMaskFilter.h" |
| 15 #include "SkRRect.h" | 15 #include "SkRRect.h" |
| 16 #include "SkRTConf.h" | 16 #include "SkRTConf.h" |
| 17 #include "SkStringUtils.h" | 17 #include "SkStringUtils.h" |
| 18 #include "SkStrokeRec.h" | 18 #include "SkStrokeRec.h" |
| 19 | 19 |
| 20 #if SK_SUPPORT_GPU | 20 #if SK_SUPPORT_GPU |
| 21 #include "GrContext.h" | 21 #include "GrContext.h" |
| 22 #include "GrTexture.h" | 22 #include "GrTexture.h" |
| 23 #include "GrFragmentProcessor.h" | 23 #include "GrFragmentProcessor.h" |
| 24 #include "GrInvariantOutput.h" |
| 24 #include "gl/GrGLProcessor.h" | 25 #include "gl/GrGLProcessor.h" |
| 25 #include "gl/builders/GrGLProgramBuilder.h" | 26 #include "gl/builders/GrGLProgramBuilder.h" |
| 26 #include "effects/GrSimpleTextureEffect.h" | 27 #include "effects/GrSimpleTextureEffect.h" |
| 27 #include "GrTBackendProcessorFactory.h" | 28 #include "GrTBackendProcessorFactory.h" |
| 28 #include "SkGrPixelRef.h" | 29 #include "SkGrPixelRef.h" |
| 29 #include "SkDraw.h" | 30 #include "SkDraw.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { | 33 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { |
| 33 return SkBlurMask::ConvertRadiusToSigma(radius); | 34 return SkBlurMask::ConvertRadiusToSigma(radius); |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); | 646 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); |
| 646 } | 647 } |
| 647 | 648 |
| 648 const SkRect& getRect() const { return fRect; } | 649 const SkRect& getRect() const { return fRect; } |
| 649 float getSigma() const { return fSigma; } | 650 float getSigma() const { return fSigma; } |
| 650 | 651 |
| 651 private: | 652 private: |
| 652 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); | 653 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); |
| 653 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; | 654 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
| 654 | 655 |
| 655 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | 656 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; |
| 656 | 657 |
| 657 static bool CreateBlurProfileTexture(GrContext *context, float sigma, | 658 static bool CreateBlurProfileTexture(GrContext *context, float sigma, |
| 658 GrTexture **blurProfileTexture); | 659 GrTexture **blurProfileTexture); |
| 659 | 660 |
| 660 SkRect fRect; | 661 SkRect fRect; |
| 661 float fSigma; | 662 float fSigma; |
| 662 GrTextureAccess fBlurProfileAccess; | 663 GrTextureAccess fBlurProfileAccess; |
| 663 | 664 |
| 664 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 665 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 665 | 666 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 819 |
| 819 const GrBackendFragmentProcessorFactory& GrRectBlurEffect::getFactory() const { | 820 const GrBackendFragmentProcessorFactory& GrRectBlurEffect::getFactory() const { |
| 820 return GrTBackendFragmentProcessorFactory<GrRectBlurEffect>::getInstance(); | 821 return GrTBackendFragmentProcessorFactory<GrRectBlurEffect>::getInstance(); |
| 821 } | 822 } |
| 822 | 823 |
| 823 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 824 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
| 824 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); | 825 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); |
| 825 return this->getSigma() == s.getSigma() && this->getRect() == s.getRect(); | 826 return this->getSigma() == s.getSigma() && this->getRect() == s.getRect(); |
| 826 } | 827 } |
| 827 | 828 |
| 828 void GrRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const { | 829 void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
| 829 inout->mulByUnknownAlpha(); | 830 inout->mulByUnknownAlpha(); |
| 830 } | 831 } |
| 831 | 832 |
| 832 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect); | 833 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect); |
| 833 | 834 |
| 834 GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random, | 835 GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random, |
| 835 GrContext* context, | 836 GrContext* context, |
| 836 const GrDrawTargetCaps&, | 837 const GrDrawTargetCaps&, |
| 837 GrTexture**) { | 838 GrTexture**) { |
| 838 float sigma = random->nextRangeF(3,8); | 839 float sigma = random->nextRangeF(3,8); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 897 |
| 897 typedef GrGLRRectBlurEffect GLProcessor; | 898 typedef GrGLRRectBlurEffect GLProcessor; |
| 898 | 899 |
| 899 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 900 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
| 900 | 901 |
| 901 private: | 902 private: |
| 902 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); | 903 GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture); |
| 903 | 904 |
| 904 virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE; | 905 virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE; |
| 905 | 906 |
| 906 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | 907 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const SK_OVE
RRIDE; |
| 907 | 908 |
| 908 SkRRect fRRect; | 909 SkRRect fRRect; |
| 909 float fSigma; | 910 float fSigma; |
| 910 GrTextureAccess fNinePatchAccess; | 911 GrTextureAccess fNinePatchAccess; |
| 911 | 912 |
| 912 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 913 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 913 | 914 |
| 914 typedef GrFragmentProcessor INHERITED; | 915 typedef GrFragmentProcessor INHERITED; |
| 915 }; | 916 }; |
| 916 | 917 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 } | 982 } |
| 982 | 983 |
| 983 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture); | 984 SkAutoTUnref<GrTexture> blurunref(blurNinePatchTexture); |
| 984 if (NULL == blurNinePatchTexture) { | 985 if (NULL == blurNinePatchTexture) { |
| 985 return NULL; | 986 return NULL; |
| 986 } | 987 } |
| 987 | 988 |
| 988 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); | 989 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); |
| 989 } | 990 } |
| 990 | 991 |
| 991 void GrRRectBlurEffect::onComputeInvariantOutput(InvariantOutput* inout) const { | 992 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
| 992 inout->mulByUnknownAlpha(); | 993 inout->mulByUnknownAlpha(); |
| 993 } | 994 } |
| 994 | 995 |
| 995 const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const { | 996 const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const { |
| 996 return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance(); | 997 return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance(); |
| 997 } | 998 } |
| 998 | 999 |
| 999 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur
e *ninePatchTexture) | 1000 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur
e *ninePatchTexture) |
| 1000 : fRRect(rrect), | 1001 : fRRect(rrect), |
| 1001 fSigma(sigma), | 1002 fSigma(sigma), |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 } else { | 1279 } else { |
| 1279 str->append("None"); | 1280 str->append("None"); |
| 1280 } | 1281 } |
| 1281 str->append("))"); | 1282 str->append("))"); |
| 1282 } | 1283 } |
| 1283 #endif | 1284 #endif |
| 1284 | 1285 |
| 1285 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1286 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 1286 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1287 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 1287 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1288 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |