| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32
_t flags) { | 126 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32
_t flags) { |
| 127 if (!SkScalarIsFinite(sigma) || sigma <= 0) { | 127 if (!SkScalarIsFinite(sigma) || sigma <= 0) { |
| 128 return NULL; | 128 return NULL; |
| 129 } | 129 } |
| 130 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) { | 130 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) { |
| 131 return NULL; | 131 return NULL; |
| 132 } | 132 } |
| 133 if (flags > SkBlurMaskFilter::kAll_BlurFlag) { | 133 if (flags > SkBlurMaskFilter::kAll_BlurFlag) { |
| 134 return NULL; | 134 return NULL; |
| 135 } | 135 } |
| 136 return SkNEW_ARGS(SkBlurMaskFilterImpl, (sigma, style, flags)); | 136 return new SkBlurMaskFilterImpl(sigma, style, flags); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /////////////////////////////////////////////////////////////////////////////// | 139 /////////////////////////////////////////////////////////////////////////////// |
| 140 | 140 |
| 141 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle style, ui
nt32_t flags) | 141 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle style, ui
nt32_t flags) |
| 142 : fSigma(sigma) | 142 : fSigma(sigma) |
| 143 , fBlurStyle(style) | 143 , fBlurStyle(style) |
| 144 , fBlurFlags(flags) { | 144 , fBlurFlags(flags) { |
| 145 SkASSERT(fSigma > 0); | 145 SkASSERT(fSigma > 0); |
| 146 SkASSERT((unsigned)style <= kLastEnum_SkBlurStyle); | 146 SkASSERT((unsigned)style <= kLastEnum_SkBlurStyle); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 | 625 |
| 626 return NULL; | 626 return NULL; |
| 627 } | 627 } |
| 628 | 628 |
| 629 bool createdBlurProfileTexture = CreateBlurProfileTexture( | 629 bool createdBlurProfileTexture = CreateBlurProfileTexture( |
| 630 textureProvider, sigma, &blurProfileTexture); | 630 textureProvider, sigma, &blurProfileTexture); |
| 631 SkAutoTUnref<GrTexture> hunref(blurProfileTexture); | 631 SkAutoTUnref<GrTexture> hunref(blurProfileTexture); |
| 632 if (!createdBlurProfileTexture) { | 632 if (!createdBlurProfileTexture) { |
| 633 return NULL; | 633 return NULL; |
| 634 } | 634 } |
| 635 return SkNEW_ARGS(GrRectBlurEffect, (rect, sigma, blurProfileTexture)); | 635 return new GrRectBlurEffect(rect, sigma, blurProfileTexture); |
| 636 } | 636 } |
| 637 | 637 |
| 638 const SkRect& getRect() const { return fRect; } | 638 const SkRect& getRect() const { return fRect; } |
| 639 float getSigma() const { return fSigma; } | 639 float getSigma() const { return fSigma; } |
| 640 | 640 |
| 641 private: | 641 private: |
| 642 GrGLFragmentProcessor* onCreateGLInstance() const override; | 642 GrGLFragmentProcessor* onCreateGLInstance() const override; |
| 643 | 643 |
| 644 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); | 644 GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile); |
| 645 | 645 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 | 795 |
| 796 GrRectBlurEffect::~GrRectBlurEffect() { | 796 GrRectBlurEffect::~GrRectBlurEffect() { |
| 797 } | 797 } |
| 798 | 798 |
| 799 void GrRectBlurEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 799 void GrRectBlurEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 800 GrProcessorKeyBuilder* b) const { | 800 GrProcessorKeyBuilder* b) const { |
| 801 GrGLRectBlurEffect::GenKey(*this, caps, b); | 801 GrGLRectBlurEffect::GenKey(*this, caps, b); |
| 802 } | 802 } |
| 803 | 803 |
| 804 GrGLFragmentProcessor* GrRectBlurEffect::onCreateGLInstance() const { | 804 GrGLFragmentProcessor* GrRectBlurEffect::onCreateGLInstance() const { |
| 805 return SkNEW_ARGS(GrGLRectBlurEffect, (*this)); | 805 return new GrGLRectBlurEffect(*this); |
| 806 } | 806 } |
| 807 | 807 |
| 808 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 808 bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
| 809 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); | 809 const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>(); |
| 810 return this->getSigma() == s.getSigma() && this->getRect() == s.getRect(); | 810 return this->getSigma() == s.getSigma() && this->getRect() == s.getRect(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 813 void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
| 814 inout->mulByUnknownSingleComponent(); | 814 inout->mulByUnknownSingleComponent(); |
| 815 } | 815 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 texDesc.fConfig = kAlpha_8_GrPixelConfig; | 965 texDesc.fConfig = kAlpha_8_GrPixelConfig; |
| 966 | 966 |
| 967 blurNinePatchTexture.reset( | 967 blurNinePatchTexture.reset( |
| 968 texProvider->createTexture(texDesc, true, blurredMask.fImage, 0)); | 968 texProvider->createTexture(texDesc, true, blurredMask.fImage, 0)); |
| 969 SkMask::FreeImage(blurredMask.fImage); | 969 SkMask::FreeImage(blurredMask.fImage); |
| 970 if (!blurNinePatchTexture) { | 970 if (!blurNinePatchTexture) { |
| 971 return NULL; | 971 return NULL; |
| 972 } | 972 } |
| 973 texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture); | 973 texProvider->assignUniqueKeyToTexture(key, blurNinePatchTexture); |
| 974 } | 974 } |
| 975 return SkNEW_ARGS(GrRRectBlurEffect, (sigma, rrect, blurNinePatchTexture)); | 975 return new GrRRectBlurEffect(sigma, rrect, blurNinePatchTexture); |
| 976 } | 976 } |
| 977 | 977 |
| 978 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 978 void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
| 979 inout->mulByUnknownSingleComponent(); | 979 inout->mulByUnknownSingleComponent(); |
| 980 } | 980 } |
| 981 | 981 |
| 982 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur
e *ninePatchTexture) | 982 GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur
e *ninePatchTexture) |
| 983 : fRRect(rrect), | 983 : fRRect(rrect), |
| 984 fSigma(sigma), | 984 fSigma(sigma), |
| 985 fNinePatchAccess(ninePatchTexture) { | 985 fNinePatchAccess(ninePatchTexture) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); | 1095 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); |
| 1096 radius = rrect.getSimpleRadii().fX; | 1096 radius = rrect.getSimpleRadii().fX; |
| 1097 pdman.set1f(fCornerRadiusUniform, radius); | 1097 pdman.set1f(fCornerRadiusUniform, radius); |
| 1098 } | 1098 } |
| 1099 | 1099 |
| 1100 void GrRRectBlurEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK
eyBuilder* b) const { | 1100 void GrRRectBlurEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK
eyBuilder* b) const { |
| 1101 GrGLRRectBlurEffect::GenKey(*this, caps, b); | 1101 GrGLRRectBlurEffect::GenKey(*this, caps, b); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 GrGLFragmentProcessor* GrRRectBlurEffect::onCreateGLInstance() const { | 1104 GrGLFragmentProcessor* GrRRectBlurEffect::onCreateGLInstance() const { |
| 1105 return SkNEW_ARGS(GrGLRRectBlurEffect, (*this)); | 1105 return new GrGLRRectBlurEffect(*this); |
| 1106 } | 1106 } |
| 1107 | 1107 |
| 1108 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
er, | 1108 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
er, |
| 1109 GrDrawContext* drawContext, | 1109 GrDrawContext* drawContext, |
| 1110 GrRenderTarget* rt, | 1110 GrRenderTarget* rt, |
| 1111 GrPaint* grp, | 1111 GrPaint* grp, |
| 1112 const GrClip& clip, | 1112 const GrClip& clip, |
| 1113 const SkMatrix& viewMatrix, | 1113 const SkMatrix& viewMatrix, |
| 1114 const SkStrokeRec& strokeRec
, | 1114 const SkStrokeRec& strokeRec
, |
| 1115 const SkRRect& rrect) const
{ | 1115 const SkRRect& rrect) const
{ |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 } else { | 1266 } else { |
| 1267 str->append("None"); | 1267 str->append("None"); |
| 1268 } | 1268 } |
| 1269 str->append("))"); | 1269 str->append("))"); |
| 1270 } | 1270 } |
| 1271 #endif | 1271 #endif |
| 1272 | 1272 |
| 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1273 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1274 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 1275 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1275 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |