| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 GrGLRectBlurEffect(const GrBackendEffectFactory& factory, | 599 GrGLRectBlurEffect(const GrBackendEffectFactory& factory, |
| 600 const GrDrawEffect&); | 600 const GrDrawEffect&); |
| 601 virtual void emitCode(GrGLShaderBuilder*, | 601 virtual void emitCode(GrGLShaderBuilder*, |
| 602 const GrDrawEffect&, | 602 const GrDrawEffect&, |
| 603 const GrEffectKey&, | 603 const GrEffectKey&, |
| 604 const char* outputColor, | 604 const char* outputColor, |
| 605 const char* inputColor, | 605 const char* inputColor, |
| 606 const TransformedCoordsArray&, | 606 const TransformedCoordsArray&, |
| 607 const TextureSamplerArray&) SK_OVERRIDE; | 607 const TextureSamplerArray&) SK_OVERRIDE; |
| 608 | 608 |
| 609 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 609 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
| 610 | 610 |
| 611 private: | 611 private: |
| 612 typedef GrGLUniformManager::UniformHandle UniformHandle; | 612 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
| 613 | 613 |
| 614 UniformHandle fProxyRectUniform; | 614 UniformHandle fProxyRectUniform; |
| 615 UniformHandle fProfileSizeUniform; | 615 UniformHandle fProfileSizeUniform; |
| 616 | 616 |
| 617 typedef GrGLEffect INHERITED; | 617 typedef GrGLEffect INHERITED; |
| 618 }; | 618 }; |
| 619 | 619 |
| 620 | 620 |
| 621 | 621 |
| 622 GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendEffectFactory& factory, co
nst GrDrawEffect&) | 622 GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendEffectFactory& factory, co
nst GrDrawEffect&) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 builder->fsCodeAppendf("\tfloat center = 2.0 * floor(%s/2.0 + .25) - 1.0;\n"
, profileSizeName); | 675 builder->fsCodeAppendf("\tfloat center = 2.0 * floor(%s/2.0 + .25) - 1.0;\n"
, profileSizeName); |
| 676 builder->fsCodeAppendf("\tvec2 wh = smallDims - vec2(center,center);\n"); | 676 builder->fsCodeAppendf("\tvec2 wh = smallDims - vec2(center,center);\n"); |
| 677 | 677 |
| 678 OutputRectBlurProfileLookup(builder, samplers[0], "horiz_lookup", profileSiz
eName, "translatedPos.x", "width", "wh.x"); | 678 OutputRectBlurProfileLookup(builder, samplers[0], "horiz_lookup", profileSiz
eName, "translatedPos.x", "width", "wh.x"); |
| 679 OutputRectBlurProfileLookup(builder, samplers[0], "vert_lookup", profileSize
Name, "translatedPos.y", "height", "wh.y"); | 679 OutputRectBlurProfileLookup(builder, samplers[0], "vert_lookup", profileSize
Name, "translatedPos.y", "height", "wh.y"); |
| 680 | 680 |
| 681 builder->fsCodeAppendf("\tfloat final = horiz_lookup * vert_lookup;\n"); | 681 builder->fsCodeAppendf("\tfloat final = horiz_lookup * vert_lookup;\n"); |
| 682 builder->fsCodeAppendf("\t%s = src * vec4(final);\n", outputColor ); | 682 builder->fsCodeAppendf("\t%s = src * vec4(final);\n", outputColor ); |
| 683 } | 683 } |
| 684 | 684 |
| 685 void GrGLRectBlurEffect::setData(const GrGLUniformManager& uman, | 685 void GrGLRectBlurEffect::setData(const GrGLProgramDataManager& pdman, |
| 686 const GrDrawEffect& drawEffect) { | 686 const GrDrawEffect& drawEffect) { |
| 687 const GrRectBlurEffect& rbe = drawEffect.castEffect<GrRectBlurEffect>(); | 687 const GrRectBlurEffect& rbe = drawEffect.castEffect<GrRectBlurEffect>(); |
| 688 SkRect rect = rbe.getRect(); | 688 SkRect rect = rbe.getRect(); |
| 689 | 689 |
| 690 uman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBott
om); | 690 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot
tom); |
| 691 uman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma())); | 691 pdman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma())); |
| 692 } | 692 } |
| 693 | 693 |
| 694 bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma, | 694 bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma, |
| 695 GrTexture **blurProfileTexture) { | 695 GrTexture **blurProfileTexture) { |
| 696 GrTextureParams params; | 696 GrTextureParams params; |
| 697 GrTextureDesc texDesc; | 697 GrTextureDesc texDesc; |
| 698 | 698 |
| 699 unsigned int profile_size = SkScalarCeilToInt(6*sigma); | 699 unsigned int profile_size = SkScalarCeilToInt(6*sigma); |
| 700 | 700 |
| 701 texDesc.fWidth = profile_size; | 701 texDesc.fWidth = profile_size; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 GrGLRRectBlurEffect(const GrBackendEffectFactory&, const GrDrawEffect&); | 960 GrGLRRectBlurEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
| 961 | 961 |
| 962 virtual void emitCode(GrGLShaderBuilder* builder, | 962 virtual void emitCode(GrGLShaderBuilder* builder, |
| 963 const GrDrawEffect& drawEffect, | 963 const GrDrawEffect& drawEffect, |
| 964 const GrEffectKey& key, | 964 const GrEffectKey& key, |
| 965 const char* outputColor, | 965 const char* outputColor, |
| 966 const char* inputColor, | 966 const char* inputColor, |
| 967 const TransformedCoordsArray&, | 967 const TransformedCoordsArray&, |
| 968 const TextureSamplerArray&) SK_OVERRIDE; | 968 const TextureSamplerArray&) SK_OVERRIDE; |
| 969 | 969 |
| 970 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 970 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
| 971 | 971 |
| 972 private: | 972 private: |
| 973 GrGLUniformManager::UniformHandle fProxyRectUniform; | 973 GrGLProgramDataManager::UniformHandle fProxyRectUniform; |
| 974 GrGLUniformManager::UniformHandle fCornerRadiusUniform; | 974 GrGLProgramDataManager::UniformHandle fCornerRadiusUniform; |
| 975 GrGLUniformManager::UniformHandle fBlurRadiusUniform; | 975 GrGLProgramDataManager::UniformHandle fBlurRadiusUniform; |
| 976 typedef GrGLEffect INHERITED; | 976 typedef GrGLEffect INHERITED; |
| 977 }; | 977 }; |
| 978 | 978 |
| 979 GrGLRRectBlurEffect::GrGLRRectBlurEffect(const GrBackendEffectFactory& factory, | 979 GrGLRRectBlurEffect::GrGLRRectBlurEffect(const GrBackendEffectFactory& factory, |
| 980 const GrDrawEffect& drawEffect) | 980 const GrDrawEffect& drawEffect) |
| 981 : INHERITED (factory) { | 981 : INHERITED (factory) { |
| 982 } | 982 } |
| 983 | 983 |
| 984 void GrGLRRectBlurEffect::emitCode(GrGLShaderBuilder* builder, | 984 void GrGLRRectBlurEffect::emitCode(GrGLShaderBuilder* builder, |
| 985 const GrDrawEffect& drawEffect, | 985 const GrDrawEffect& drawEffect, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 builder->fsCodeAppendf("\t\t}\n"); | 1029 builder->fsCodeAppendf("\t\t}\n"); |
| 1030 | 1030 |
| 1031 builder->fsCodeAppendf("\t\tvec2 proxyDims = vec2(2.0*threshold+1.0);\n"); | 1031 builder->fsCodeAppendf("\t\tvec2 proxyDims = vec2(2.0*threshold+1.0);\n"); |
| 1032 builder->fsCodeAppendf("\t\tvec2 texCoord = translatedFragPos / proxyDims;\n
"); | 1032 builder->fsCodeAppendf("\t\tvec2 texCoord = translatedFragPos / proxyDims;\n
"); |
| 1033 | 1033 |
| 1034 builder->fsCodeAppendf("\t%s = ", outputColor); | 1034 builder->fsCodeAppendf("\t%s = ", outputColor); |
| 1035 builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], "texCoord
"); | 1035 builder->fsAppendTextureLookupAndModulate(inputColor, samplers[0], "texCoord
"); |
| 1036 builder->fsCodeAppend(";\n"); | 1036 builder->fsCodeAppend(";\n"); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 void GrGLRRectBlurEffect::setData(const GrGLUniformManager& uman, | 1039 void GrGLRRectBlurEffect::setData(const GrGLProgramDataManager& pdman, |
| 1040 const GrDrawEffect& drawEffect) { | 1040 const GrDrawEffect& drawEffect) { |
| 1041 const GrRRectBlurEffect& brre = drawEffect.castEffect<GrRRectBlurEffect>(); | 1041 const GrRRectBlurEffect& brre = drawEffect.castEffect<GrRRectBlurEffect>(); |
| 1042 SkRRect rrect = brre.getRRect(); | 1042 SkRRect rrect = brre.getRRect(); |
| 1043 | 1043 |
| 1044 float blurRadius = 3.f*SkScalarCeilToScalar(brre.getSigma()-1/6.0f); | 1044 float blurRadius = 3.f*SkScalarCeilToScalar(brre.getSigma()-1/6.0f); |
| 1045 uman.set1f(fBlurRadiusUniform, blurRadius); | 1045 pdman.set1f(fBlurRadiusUniform, blurRadius); |
| 1046 | 1046 |
| 1047 SkRect rect = rrect.getBounds(); | 1047 SkRect rect = rrect.getBounds(); |
| 1048 rect.outset(blurRadius, blurRadius); | 1048 rect.outset(blurRadius, blurRadius); |
| 1049 uman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBott
om); | 1049 pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBot
tom); |
| 1050 | 1050 |
| 1051 SkScalar radius = 0; | 1051 SkScalar radius = 0; |
| 1052 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); | 1052 SkASSERT(rrect.isSimpleCircular() || rrect.isRect()); |
| 1053 radius = rrect.getSimpleRadii().fX; | 1053 radius = rrect.getSimpleRadii().fX; |
| 1054 uman.set1f(fCornerRadiusUniform, radius); | 1054 pdman.set1f(fCornerRadiusUniform, radius); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 | 1057 |
| 1058 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context, | 1058 bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context, |
| 1059 GrPaint* grp, | 1059 GrPaint* grp, |
| 1060 const SkStrokeRec& strokeRec
, | 1060 const SkStrokeRec& strokeRec
, |
| 1061 const SkRRect& rrect) const
{ | 1061 const SkRRect& rrect) const
{ |
| 1062 if (fBlurStyle != kNormal_SkBlurStyle) { | 1062 if (fBlurStyle != kNormal_SkBlurStyle) { |
| 1063 return false; | 1063 return false; |
| 1064 } | 1064 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 } else { | 1204 } else { |
| 1205 str->append("None"); | 1205 str->append("None"); |
| 1206 } | 1206 } |
| 1207 str->append("))"); | 1207 str->append("))"); |
| 1208 } | 1208 } |
| 1209 #endif | 1209 #endif |
| 1210 | 1210 |
| 1211 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1211 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
| 1212 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1212 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
| 1213 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1213 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |