OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBlurMaskFilter.h" | 8 #include "SkBlurMaskFilter.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkGpuBlurUtils.h" | 10 #include "SkGpuBlurUtils.h" |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 | 683 |
684 private: | 684 private: |
685 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 685 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
686 | 686 |
687 UniformHandle fProxyRectUniform; | 687 UniformHandle fProxyRectUniform; |
688 UniformHandle fProfileSizeUniform; | 688 UniformHandle fProfileSizeUniform; |
689 | 689 |
690 typedef GrGLSLFragmentProcessor INHERITED; | 690 typedef GrGLSLFragmentProcessor INHERITED; |
691 }; | 691 }; |
692 | 692 |
693 void OutputRectBlurProfileLookup(GrGLSLFragmentBuilder* fragBuilder, | 693 void OutputRectBlurProfileLookup(GrGLSLFPFragmentBuilder* fragBuilder, |
694 const GrGLSLTextureSampler& sampler, | 694 const GrGLSLTextureSampler& sampler, |
695 const char *output, | 695 const char *output, |
696 const char *profileSize, const char *loc, | 696 const char *profileSize, const char *loc, |
697 const char *blurred_width, | 697 const char *blurred_width, |
698 const char *sharp_width) { | 698 const char *sharp_width) { |
699 fragBuilder->codeAppendf("float %s;", output); | 699 fragBuilder->codeAppendf("float %s;", output); |
700 fragBuilder->codeAppendf("{"); | 700 fragBuilder->codeAppendf("{"); |
701 fragBuilder->codeAppendf("float coord = ((abs(%s - 0.5 * %s) - 0.5 * %s)) /
%s;", | 701 fragBuilder->codeAppendf("float coord = ((abs(%s - 0.5 * %s) - 0.5 * %s)) /
%s;", |
702 loc, blurred_width, sharp_width, profileSize); | 702 loc, blurred_width, sharp_width, profileSize); |
703 fragBuilder->codeAppendf("%s = ", output); | 703 fragBuilder->codeAppendf("%s = ", output); |
(...skipping 24 matching lines...) Expand all Loading... |
728 kVec4f_GrSLType, | 728 kVec4f_GrSLType, |
729 rbe.precision(), | 729 rbe.precision(), |
730 "proxyRect", | 730 "proxyRect", |
731 &rectName); | 731 &rectName); |
732 fProfileSizeUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, | 732 fProfileSizeUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, |
733 kFloat_GrSLType, | 733 kFloat_GrSLType, |
734 kDefault_GrSLPrecision, | 734 kDefault_GrSLPrecision, |
735 "profileSize", | 735 "profileSize", |
736 &profileSizeName); | 736 &profileSizeName); |
737 | 737 |
738 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 738 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
739 const char *fragmentPos = fragBuilder->fragmentPosition(); | 739 const char *fragmentPos = fragBuilder->fragmentPosition(); |
740 | 740 |
741 if (args.fInputColor) { | 741 if (args.fInputColor) { |
742 fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); | 742 fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); |
743 } else { | 743 } else { |
744 fragBuilder->codeAppendf("vec4 src=vec4(1);"); | 744 fragBuilder->codeAppendf("vec4 src=vec4(1);"); |
745 } | 745 } |
746 | 746 |
747 fragBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precision
String, fragmentPos, | 747 fragBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precision
String, fragmentPos, |
748 rectName); | 748 rectName); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 kFloat_GrSLType, | 1075 kFloat_GrSLType, |
1076 kDefault_GrSLPrecision, | 1076 kDefault_GrSLPrecision, |
1077 "cornerRadius", | 1077 "cornerRadius", |
1078 &cornerRadiusName); | 1078 &cornerRadiusName); |
1079 fBlurRadiusUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, | 1079 fBlurRadiusUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, |
1080 kFloat_GrSLType, | 1080 kFloat_GrSLType, |
1081 kDefault_GrSLPrecision, | 1081 kDefault_GrSLPrecision, |
1082 "blurRadius", | 1082 "blurRadius", |
1083 &blurRadiusName); | 1083 &blurRadiusName); |
1084 | 1084 |
1085 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 1085 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
1086 const char* fragmentPos = fragBuilder->fragmentPosition(); | 1086 const char* fragmentPos = fragBuilder->fragmentPosition(); |
1087 | 1087 |
1088 // warp the fragment position to the appropriate part of the 9patch blur tex
ture | 1088 // warp the fragment position to the appropriate part of the 9patch blur tex
ture |
1089 | 1089 |
1090 fragBuilder->codeAppendf("vec2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName,
rectName); | 1090 fragBuilder->codeAppendf("vec2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName,
rectName); |
1091 fragBuilder->codeAppendf("vec2 translatedFragPos = %s.xy - %s.xy;", fragment
Pos, rectName); | 1091 fragBuilder->codeAppendf("vec2 translatedFragPos = %s.xy - %s.xy;", fragment
Pos, rectName); |
1092 fragBuilder->codeAppendf("float threshold = %s + 2.0*%s;", cornerRadiusName,
blurRadiusName); | 1092 fragBuilder->codeAppendf("float threshold = %s + 2.0*%s;", cornerRadiusName,
blurRadiusName); |
1093 fragBuilder->codeAppendf("vec2 middle = %s.zw - %s.xy - 2.0*threshold;", rec
tName, rectName); | 1093 fragBuilder->codeAppendf("vec2 middle = %s.zw - %s.xy - 2.0*threshold;", rec
tName, rectName); |
1094 | 1094 |
1095 fragBuilder->codeAppendf( | 1095 fragBuilder->codeAppendf( |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 } else { | 1304 } else { |
1305 str->append("None"); | 1305 str->append("None"); |
1306 } | 1306 } |
1307 str->append("))"); | 1307 str->append("))"); |
1308 } | 1308 } |
1309 #endif | 1309 #endif |
1310 | 1310 |
1311 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1311 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1312 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1312 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1313 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1313 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |