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

Unified Diff: src/effects/SkBlurMaskFilter.cpp

Issue 1457543003: Add ShaderBuilders to EmitArgs and remove gettings from ProgBuilder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.cpp ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkBlurMaskFilter.cpp
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index ac10a8bd80ab1954f377d4074b3f8ce083a10583..a44563ea0883a7c28b16020b366a14f17719a079 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -697,20 +697,20 @@ private:
typedef GrGLSLFragmentProcessor INHERITED;
};
-void OutputRectBlurProfileLookup(GrGLSLFragmentBuilder* fsBuilder,
+void OutputRectBlurProfileLookup(GrGLSLFragmentBuilder* fragBuilder,
const GrGLSLTextureSampler& sampler,
const char *output,
const char *profileSize, const char *loc,
const char *blurred_width,
const char *sharp_width) {
- fsBuilder->codeAppendf("float %s;", output);
- fsBuilder->codeAppendf("{");
- fsBuilder->codeAppendf("float coord = ((abs(%s - 0.5 * %s) - 0.5 * %s)) / %s;",
+ fragBuilder->codeAppendf("float %s;", output);
+ fragBuilder->codeAppendf("{");
+ fragBuilder->codeAppendf("float coord = ((abs(%s - 0.5 * %s) - 0.5 * %s)) / %s;",
loc, blurred_width, sharp_width, profileSize);
- fsBuilder->codeAppendf("%s = ", output);
- fsBuilder->appendTextureLookup(sampler, "vec2(coord,0.5)");
- fsBuilder->codeAppend(".a;");
- fsBuilder->codeAppendf("}");
+ fragBuilder->codeAppendf("%s = ", output);
+ fragBuilder->appendTextureLookup(sampler, "vec2(coord,0.5)");
+ fragBuilder->codeAppend(".a;");
+ fragBuilder->codeAppendf("}");
}
@@ -737,33 +737,33 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
"profileSize",
&profileSizeName);
- GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
- const char *fragmentPos = fsBuilder->fragmentPosition();
+ GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ const char *fragmentPos = fragBuilder->fragmentPosition();
if (args.fInputColor) {
- fsBuilder->codeAppendf("vec4 src=%s;", args.fInputColor);
+ fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor);
} else {
- fsBuilder->codeAppendf("vec4 src=vec4(1);");
+ fragBuilder->codeAppendf("vec4 src=vec4(1);");
}
- fsBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precisionString, fragmentPos,
- rectName);
- fsBuilder->codeAppendf("%s float width = %s.z - %s.x;", precisionString, rectName, rectName);
- fsBuilder->codeAppendf("%s float height = %s.w - %s.y;", precisionString, rectName, rectName);
+ fragBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precisionString, fragmentPos,
+ rectName);
+ fragBuilder->codeAppendf("%s float width = %s.z - %s.x;", precisionString, rectName, rectName);
+ fragBuilder->codeAppendf("%s float height = %s.w - %s.y;", precisionString, rectName, rectName);
- fsBuilder->codeAppendf("%s vec2 smallDims = vec2(width - %s, height - %s);", precisionString,
- profileSizeName, profileSizeName);
- fsBuilder->codeAppendf("%s float center = 2.0 * floor(%s/2.0 + .25) - 1.0;", precisionString,
- profileSizeName);
- fsBuilder->codeAppendf("%s vec2 wh = smallDims - vec2(center,center);", precisionString);
+ fragBuilder->codeAppendf("%s vec2 smallDims = vec2(width - %s, height - %s);", precisionString,
+ profileSizeName, profileSizeName);
+ fragBuilder->codeAppendf("%s float center = 2.0 * floor(%s/2.0 + .25) - 1.0;", precisionString,
+ profileSizeName);
+ fragBuilder->codeAppendf("%s vec2 wh = smallDims - vec2(center,center);", precisionString);
- OutputRectBlurProfileLookup(fsBuilder, args.fSamplers[0], "horiz_lookup", profileSizeName,
+ OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "horiz_lookup", profileSizeName,
"translatedPos.x", "width", "wh.x");
- OutputRectBlurProfileLookup(fsBuilder, args.fSamplers[0], "vert_lookup", profileSizeName,
+ OutputRectBlurProfileLookup(fragBuilder, args.fSamplers[0], "vert_lookup", profileSizeName,
"translatedPos.y", "height", "wh.y");
- fsBuilder->codeAppendf("float final = horiz_lookup * vert_lookup;");
- fsBuilder->codeAppendf("%s = src * final;", args.fOutputColor);
+ fragBuilder->codeAppendf("float final = horiz_lookup * vert_lookup;");
+ fragBuilder->codeAppendf("%s = src * final;", args.fOutputColor);
}
void GrGLRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
@@ -1083,34 +1083,36 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
"blurRadius",
&blurRadiusName);
- GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
- const char* fragmentPos = fsBuilder->fragmentPosition();
+ GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ const char* fragmentPos = fragBuilder->fragmentPosition();
// warp the fragment position to the appropriate part of the 9patch blur texture
- fsBuilder->codeAppendf("vec2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName, rectName);
- fsBuilder->codeAppendf("vec2 translatedFragPos = %s.xy - %s.xy;", fragmentPos, rectName);
- fsBuilder->codeAppendf("float threshold = %s + 2.0*%s;", cornerRadiusName, blurRadiusName);
- fsBuilder->codeAppendf("vec2 middle = %s.zw - %s.xy - 2.0*threshold;", rectName, rectName);
-
- fsBuilder->codeAppendf("if (translatedFragPos.x >= threshold && translatedFragPos.x < (middle.x+threshold)) {");
- fsBuilder->codeAppendf("translatedFragPos.x = threshold;\n");
- fsBuilder->codeAppendf("} else if (translatedFragPos.x >= (middle.x + threshold)) {");
- fsBuilder->codeAppendf("translatedFragPos.x -= middle.x - 1.0;");
- fsBuilder->codeAppendf("}");
-
- fsBuilder->codeAppendf("if (translatedFragPos.y > threshold && translatedFragPos.y < (middle.y+threshold)) {");
- fsBuilder->codeAppendf("translatedFragPos.y = threshold;");
- fsBuilder->codeAppendf("} else if (translatedFragPos.y >= (middle.y + threshold)) {");
- fsBuilder->codeAppendf("translatedFragPos.y -= middle.y - 1.0;");
- fsBuilder->codeAppendf("}");
-
- fsBuilder->codeAppendf("vec2 proxyDims = vec2(2.0*threshold+1.0);");
- fsBuilder->codeAppendf("vec2 texCoord = translatedFragPos / proxyDims;");
-
- fsBuilder->codeAppendf("%s = ", args.fOutputColor);
- fsBuilder->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers[0], "texCoord");
- fsBuilder->codeAppend(";");
+ fragBuilder->codeAppendf("vec2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName, rectName);
+ fragBuilder->codeAppendf("vec2 translatedFragPos = %s.xy - %s.xy;", fragmentPos, rectName);
+ fragBuilder->codeAppendf("float threshold = %s + 2.0*%s;", cornerRadiusName, blurRadiusName);
+ fragBuilder->codeAppendf("vec2 middle = %s.zw - %s.xy - 2.0*threshold;", rectName, rectName);
+
+ fragBuilder->codeAppendf(
+ "if (translatedFragPos.x >= threshold && translatedFragPos.x < (middle.x+threshold)) {");
+ fragBuilder->codeAppendf("translatedFragPos.x = threshold;\n");
+ fragBuilder->codeAppendf("} else if (translatedFragPos.x >= (middle.x + threshold)) {");
+ fragBuilder->codeAppendf("translatedFragPos.x -= middle.x - 1.0;");
+ fragBuilder->codeAppendf("}");
+
+ fragBuilder->codeAppendf(
+ "if (translatedFragPos.y > threshold && translatedFragPos.y < (middle.y+threshold)) {");
+ fragBuilder->codeAppendf("translatedFragPos.y = threshold;");
+ fragBuilder->codeAppendf("} else if (translatedFragPos.y >= (middle.y + threshold)) {");
+ fragBuilder->codeAppendf("translatedFragPos.y -= middle.y - 1.0;");
+ fragBuilder->codeAppendf("}");
+
+ fragBuilder->codeAppendf("vec2 proxyDims = vec2(2.0*threshold+1.0);");
+ fragBuilder->codeAppendf("vec2 texCoord = translatedFragPos / proxyDims;");
+
+ fragBuilder->codeAppendf("%s = ", args.fOutputColor);
+ fragBuilder->appendTextureLookupAndModulate(args.fInputColor, args.fSamplers[0], "texCoord");
+ fragBuilder->codeAppend(";");
}
void GrGLRRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
« no previous file with comments | « src/effects/SkArithmeticMode_gpu.cpp ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698