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

Side by Side Diff: src/gpu/effects/GrBicubicEffect.cpp

Issue 1453623003: Move glsl onto EmitArgs struct for emitCode (Closed) Base URL: https://skia.googlesource.com/skia.git@moveShaders
Patch Set: nit 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
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 "GrBicubicEffect.h" 8 #include "GrBicubicEffect.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "glsl/GrGLSLFragmentShaderBuilder.h" 10 #include "glsl/GrGLSLFragmentShaderBuilder.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 fragBuilder->codeAppendf("\tcoord /= %s;\n", imgInc); 90 fragBuilder->codeAppendf("\tcoord /= %s;\n", imgInc);
91 fragBuilder->codeAppend("\tvec2 f = fract(coord);\n"); 91 fragBuilder->codeAppend("\tvec2 f = fract(coord);\n");
92 fragBuilder->codeAppendf("\tcoord = (coord - f + vec2(0.5)) * %s;\n", imgInc ); 92 fragBuilder->codeAppendf("\tcoord = (coord - f + vec2(0.5)) * %s;\n", imgInc );
93 fragBuilder->codeAppend("\tvec4 rowColors[4];\n"); 93 fragBuilder->codeAppend("\tvec4 rowColors[4];\n");
94 for (int y = 0; y < 4; ++y) { 94 for (int y = 0; y < 4; ++y) {
95 for (int x = 0; x < 4; ++x) { 95 for (int x = 0; x < 4; ++x) {
96 SkString coord; 96 SkString coord;
97 coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1); 97 coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1);
98 SkString sampleVar; 98 SkString sampleVar;
99 sampleVar.printf("rowColors[%d]", x); 99 sampleVar.printf("rowColors[%d]", x);
100 fDomain.sampleTexture(fragBuilder, domain, sampleVar.c_str(), coord, args.fSamplers[0]); 100 fDomain.sampleTexture(fragBuilder,
101 args.fGLSLCaps,
102 domain,
103 sampleVar.c_str(),
104 coord,
105 args.fSamplers[0]);
101 } 106 }
102 fragBuilder->codeAppendf( 107 fragBuilder->codeAppendf(
103 "\tvec4 s%d = %s(%s, f.x, rowColors[0], rowColors[1], rowColors[2], rowColors[3]);\n", 108 "\tvec4 s%d = %s(%s, f.x, rowColors[0], rowColors[1], rowColors[2], rowColors[3]);\n",
104 y, cubicBlendName.c_str(), coeff); 109 y, cubicBlendName.c_str(), coeff);
105 } 110 }
106 SkString bicubicColor; 111 SkString bicubicColor;
107 bicubicColor.printf("%s(%s, f.y, s0, s1, s2, s3)", cubicBlendName.c_str(), c oeff); 112 bicubicColor.printf("%s(%s, f.y, s0, s1, s2, s3)", cubicBlendName.c_str(), c oeff);
108 fragBuilder->codeAppendf("\t%s = %s;\n", 113 fragBuilder->codeAppendf("\t%s = %s;\n",
109 args.fOutputColor, (GrGLSLExpr4(bicubicColor.c_str( )) * 114 args.fOutputColor, (GrGLSLExpr4(bicubicColor.c_str( )) *
110 GrGLSLExpr4(args.fInputColor)). c_str()); 115 GrGLSLExpr4(args.fInputColor)). c_str());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // Use bilerp to handle rotation or fractional translation. 217 // Use bilerp to handle rotation or fractional translation.
213 *filterMode = GrTextureParams::kBilerp_FilterMode; 218 *filterMode = GrTextureParams::kBilerp_FilterMode;
214 } 219 }
215 return false; 220 return false;
216 } 221 }
217 // When we use the bicubic filtering effect each sample is read from the tex ture using 222 // When we use the bicubic filtering effect each sample is read from the tex ture using
218 // nearest neighbor sampling. 223 // nearest neighbor sampling.
219 *filterMode = GrTextureParams::kNone_FilterMode; 224 *filterMode = GrTextureParams::kNone_FilterMode;
220 return true; 225 return true;
221 } 226 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp ('k') | src/gpu/effects/GrConfigConversionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698