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 11 matching lines...) Expand all Loading... |
22 #include "GrContext.h" | 22 #include "GrContext.h" |
23 #include "GrDrawContext.h" | 23 #include "GrDrawContext.h" |
24 #include "GrTexture.h" | 24 #include "GrTexture.h" |
25 #include "GrFragmentProcessor.h" | 25 #include "GrFragmentProcessor.h" |
26 #include "GrInvariantOutput.h" | 26 #include "GrInvariantOutput.h" |
27 #include "SkGrPixelRef.h" | 27 #include "SkGrPixelRef.h" |
28 #include "SkDraw.h" | 28 #include "SkDraw.h" |
29 #include "effects/GrSimpleTextureEffect.h" | 29 #include "effects/GrSimpleTextureEffect.h" |
30 #include "glsl/GrGLSLFragmentProcessor.h" | 30 #include "glsl/GrGLSLFragmentProcessor.h" |
31 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 31 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
32 #include "glsl/GrGLSLProgramBuilder.h" | |
33 #include "glsl/GrGLSLProgramDataManager.h" | 32 #include "glsl/GrGLSLProgramDataManager.h" |
34 #include "glsl/GrGLSLTextureSampler.h" | 33 #include "glsl/GrGLSLTextureSampler.h" |
| 34 #include "glsl/GrGLSLUniformHandler.h" |
35 #endif | 35 #endif |
36 | 36 |
37 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { | 37 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { |
38 return SkBlurMask::ConvertRadiusToSigma(radius); | 38 return SkBlurMask::ConvertRadiusToSigma(radius); |
39 } | 39 } |
40 | 40 |
41 class SkBlurMaskFilterImpl : public SkMaskFilter { | 41 class SkBlurMaskFilterImpl : public SkMaskFilter { |
42 public: | 42 public: |
43 SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle, uint32_t flags); | 43 SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle, uint32_t flags); |
44 | 44 |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 fragBuilder->codeAppendf("}"); | 713 fragBuilder->codeAppendf("}"); |
714 } | 714 } |
715 | 715 |
716 | 716 |
717 void GrGLRectBlurEffect::GenKey(GrSLPrecision precision, GrProcessorKeyBuilder*
b) { | 717 void GrGLRectBlurEffect::GenKey(GrSLPrecision precision, GrProcessorKeyBuilder*
b) { |
718 b->add32(precision); | 718 b->add32(precision); |
719 } | 719 } |
720 | 720 |
721 | 721 |
722 void GrGLRectBlurEffect::emitCode(EmitArgs& args) { | 722 void GrGLRectBlurEffect::emitCode(EmitArgs& args) { |
| 723 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
723 | 724 |
724 const char *rectName; | 725 const char *rectName; |
725 const char *profileSizeName; | 726 const char *profileSizeName; |
726 | 727 |
727 const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fGLSLCap
s, fPrecision); | 728 const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fGLSLCap
s, fPrecision); |
728 fProxyRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragmen
t_Visibility, | 729 fProxyRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragme
nt_Visibility, |
729 kVec4f_GrSLType, | 730 kVec4f_GrSLType, |
730 fPrecision, | 731 fPrecision, |
731 "proxyRect", | 732 "proxyRect", |
732 &rectName); | 733 &rectName); |
733 fProfileSizeUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragm
ent_Visibility, | 734 fProfileSizeUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFrag
ment_Visibility, |
734 kFloat_GrSLType, | 735 kFloat_GrSLType, |
735 kDefault_GrSLPrecision, | 736 kDefault_GrSLPrecision, |
736 "profileSize", | 737 "profileSize", |
737 &profileSizeName); | 738 &profileSizeName); |
738 | 739 |
739 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 740 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
740 const char *fragmentPos = fragBuilder->fragmentPosition(); | 741 const char *fragmentPos = fragBuilder->fragmentPosition(); |
741 | 742 |
742 if (args.fInputColor) { | 743 if (args.fInputColor) { |
743 fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); | 744 fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); |
744 } else { | 745 } else { |
745 fragBuilder->codeAppendf("vec4 src=vec4(1);"); | 746 fragBuilder->codeAppendf("vec4 src=vec4(1);"); |
746 } | 747 } |
747 | 748 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 GrGLSLProgramDataManager::UniformHandle fCornerRadiusUniform; | 1057 GrGLSLProgramDataManager::UniformHandle fCornerRadiusUniform; |
1057 GrGLSLProgramDataManager::UniformHandle fBlurRadiusUniform; | 1058 GrGLSLProgramDataManager::UniformHandle fBlurRadiusUniform; |
1058 typedef GrGLSLFragmentProcessor INHERITED; | 1059 typedef GrGLSLFragmentProcessor INHERITED; |
1059 }; | 1060 }; |
1060 | 1061 |
1061 void GrGLRRectBlurEffect::emitCode(EmitArgs& args) { | 1062 void GrGLRRectBlurEffect::emitCode(EmitArgs& args) { |
1062 const char *rectName; | 1063 const char *rectName; |
1063 const char *cornerRadiusName; | 1064 const char *cornerRadiusName; |
1064 const char *blurRadiusName; | 1065 const char *blurRadiusName; |
1065 | 1066 |
| 1067 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
1066 // The proxy rect has left, top, right, and bottom edges correspond to | 1068 // The proxy rect has left, top, right, and bottom edges correspond to |
1067 // components x, y, z, and w, respectively. | 1069 // components x, y, z, and w, respectively. |
1068 | 1070 |
1069 fProxyRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragmen
t_Visibility, | 1071 fProxyRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragme
nt_Visibility, |
1070 kVec4f_GrSLType, | 1072 kVec4f_GrSLType, |
1071 kDefault_GrSLPrecision, | |
1072 "proxyRect", | |
1073 &rectName); | |
1074 fCornerRadiusUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFrag
ment_Visibility, | |
1075 kFloat_GrSLType, | |
1076 kDefault_GrSLPrecision, | |
1077 "cornerRadius", | |
1078 &cornerRadiusName); | |
1079 fBlurRadiusUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme
nt_Visibility, | |
1080 kFloat_GrSLType, | |
1081 kDefault_GrSLPrecision, | 1073 kDefault_GrSLPrecision, |
1082 "blurRadius", | 1074 "proxyRect", |
1083 &blurRadiusName); | 1075 &rectName); |
| 1076 fCornerRadiusUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFra
gment_Visibility, |
| 1077 kFloat_GrSLType, |
| 1078 kDefault_GrSLPrecision, |
| 1079 "cornerRadius", |
| 1080 &cornerRadiusName); |
| 1081 fBlurRadiusUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragm
ent_Visibility, |
| 1082 kFloat_GrSLType, |
| 1083 kDefault_GrSLPrecision, |
| 1084 "blurRadius", |
| 1085 &blurRadiusName); |
1084 | 1086 |
1085 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 1087 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
1086 const char* fragmentPos = fragBuilder->fragmentPosition(); | 1088 const char* fragmentPos = fragBuilder->fragmentPosition(); |
1087 | 1089 |
1088 // warp the fragment position to the appropriate part of the 9patch blur tex
ture | 1090 // warp the fragment position to the appropriate part of the 9patch blur tex
ture |
1089 | 1091 |
1090 fragBuilder->codeAppendf("vec2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName,
rectName); | 1092 fragBuilder->codeAppendf("vec2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName,
rectName); |
1091 fragBuilder->codeAppendf("vec2 translatedFragPos = %s.xy - %s.xy;", fragment
Pos, rectName); | 1093 fragBuilder->codeAppendf("vec2 translatedFragPos = %s.xy - %s.xy;", fragment
Pos, rectName); |
1092 fragBuilder->codeAppendf("float threshold = %s + 2.0*%s;", cornerRadiusName,
blurRadiusName); | 1094 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); | 1095 fragBuilder->codeAppendf("vec2 middle = %s.zw - %s.xy - 2.0*threshold;", rec
tName, rectName); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 } else { | 1307 } else { |
1306 str->append("None"); | 1308 str->append("None"); |
1307 } | 1309 } |
1308 str->append("))"); | 1310 str->append("))"); |
1309 } | 1311 } |
1310 #endif | 1312 #endif |
1311 | 1313 |
1312 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) | 1314 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) |
1313 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) | 1315 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) |
1314 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1316 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |