Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: src/effects/SkBlurMaskFilter.cpp

Issue 1881513002: Add appendPrecisionModifier method to GrGLSLShaderBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/effects/GrDistanceFieldGeoProc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 716
717 717
718 void GrGLRectBlurEffect::emitCode(EmitArgs& args) { 718 void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
719 const GrRectBlurEffect& rbe = args.fFp.cast<GrRectBlurEffect>(); 719 const GrRectBlurEffect& rbe = args.fFp.cast<GrRectBlurEffect>();
720 720
721 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 721 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
722 722
723 const char *rectName; 723 const char *rectName;
724 const char *profileSizeName; 724 const char *profileSizeName;
725 725
726 const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fGLSLCap s, rbe.precision()); 726 SkString precisionString;
727 if (args.fGLSLCaps->usesPrecisionModifiers()) {
728 precisionString.printf("%s ", GrGLSLPrecisionString(rbe.precision()));
729 }
727 fProxyRectUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, 730 fProxyRectUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
728 kVec4f_GrSLType, 731 kVec4f_GrSLType,
729 rbe.precision(), 732 rbe.precision(),
730 "proxyRect", 733 "proxyRect",
731 &rectName); 734 &rectName);
732 fProfileSizeUniform = uniformHandler->addUniform(kFragment_GrShaderFlag, 735 fProfileSizeUniform = uniformHandler->addUniform(kFragment_GrShaderFlag,
733 kFloat_GrSLType, 736 kFloat_GrSLType,
734 kDefault_GrSLPrecision, 737 kDefault_GrSLPrecision,
735 "profileSize", 738 "profileSize",
736 &profileSizeName); 739 &profileSizeName);
737 740
738 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; 741 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
739 const char *fragmentPos = fragBuilder->fragmentPosition(); 742 const char *fragmentPos = fragBuilder->fragmentPosition();
740 743
741 if (args.fInputColor) { 744 if (args.fInputColor) {
742 fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); 745 fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor);
743 } else { 746 } else {
744 fragBuilder->codeAppendf("vec4 src=vec4(1);"); 747 fragBuilder->codeAppendf("vec4 src=vec4(1);");
745 } 748 }
746 749
747 fragBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precision String, fragmentPos, 750 fragBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precision String.c_str(),
751 fragmentPos, rectName);
752 fragBuilder->codeAppendf("%s float width = %s.z - %s.x;", precisionString.c_ str(), rectName,
748 rectName); 753 rectName);
749 fragBuilder->codeAppendf("%s float width = %s.z - %s.x;", precisionString, r ectName, rectName); 754 fragBuilder->codeAppendf("%s float height = %s.w - %s.y;", precisionString.c _str(), rectName,
750 fragBuilder->codeAppendf("%s float height = %s.w - %s.y;", precisionString, rectName, rectName); 755 rectName);
751 756
752 fragBuilder->codeAppendf("%s vec2 smallDims = vec2(width - %s, height - %s); ", precisionString, 757 fragBuilder->codeAppendf("%s vec2 smallDims = vec2(width - %s, height - %s); ",
753 profileSizeName, profileSizeName); 758 precisionString.c_str(), profileSizeName, profileSi zeName);
754 fragBuilder->codeAppendf("%s float center = 2.0 * floor(%s/2.0 + .25) - 1.0; ", precisionString, 759 fragBuilder->codeAppendf("%s float center = 2.0 * floor(%s/2.0 + .25) - 1.0; ",
755 profileSizeName); 760 precisionString.c_str(), profileSizeName);
756 fragBuilder->codeAppendf("%s vec2 wh = smallDims - vec2(center,center);", pr ecisionString); 761 fragBuilder->codeAppendf("%s vec2 wh = smallDims - vec2(center,center);",
762 precisionString.c_str());
757 763
758 OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "horiz_lookup", profileSizeName, 764 OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "horiz_lookup", profileSizeName,
759 "translatedPos.x", "width", "wh.x"); 765 "translatedPos.x", "width", "wh.x");
760 OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "vert_lookup", p rofileSizeName, 766 OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "vert_lookup", p rofileSizeName,
761 "translatedPos.y", "height", "wh.y"); 767 "translatedPos.y", "height", "wh.y");
762 768
763 fragBuilder->codeAppendf("float final = horiz_lookup * vert_lookup;"); 769 fragBuilder->codeAppendf("float final = horiz_lookup * vert_lookup;");
764 fragBuilder->codeAppendf("%s = src * final;", args.fOutputColor); 770 fragBuilder->codeAppendf("%s = src * final;", args.fOutputColor);
765 } 771 }
766 772
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 } else { 1315 } else {
1310 str->append("None"); 1316 str->append("None");
1311 } 1317 }
1312 str->append("))"); 1318 str->append("))");
1313 } 1319 }
1314 #endif 1320 #endif
1315 1321
1316 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1322 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1317 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1323 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1318 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1324 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « no previous file | src/gpu/effects/GrDistanceFieldGeoProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698