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

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

Issue 1709153002: Add more specialized fragment builders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make MSVC happy Created 4 years, 10 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 | « src/gpu/effects/GrDitherEffect.cpp ('k') | src/gpu/effects/GrOvalEffect.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 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 #include "GrMatrixConvolutionEffect.h" 7 #include "GrMatrixConvolutionEffect.h"
8 #include "glsl/GrGLSLFragmentProcessor.h" 8 #include "glsl/GrGLSLFragmentProcessor.h"
9 #include "glsl/GrGLSLFragmentShaderBuilder.h" 9 #include "glsl/GrGLSLFragmentShaderBuilder.h"
10 #include "glsl/GrGLSLProgramDataManager.h" 10 #include "glsl/GrGLSLProgramDataManager.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 kFloat_GrSLType, kDefault_GrSLPrecisio n, "Gain"); 54 kFloat_GrSLType, kDefault_GrSLPrecisio n, "Gain");
55 fBiasUni = uniformHandler->addUniform(kFragment_GrShaderFlag, 55 fBiasUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
56 kFloat_GrSLType, kDefault_GrSLPrecisio n, "Bias"); 56 kFloat_GrSLType, kDefault_GrSLPrecisio n, "Bias");
57 57
58 const char* kernelOffset = uniformHandler->getUniformCStr(fKernelOffsetUni); 58 const char* kernelOffset = uniformHandler->getUniformCStr(fKernelOffsetUni);
59 const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni); 59 const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
60 const char* kernel = uniformHandler->getUniformCStr(fKernelUni); 60 const char* kernel = uniformHandler->getUniformCStr(fKernelUni);
61 const char* gain = uniformHandler->getUniformCStr(fGainUni); 61 const char* gain = uniformHandler->getUniformCStr(fGainUni);
62 const char* bias = uniformHandler->getUniformCStr(fBiasUni); 62 const char* bias = uniformHandler->getUniformCStr(fBiasUni);
63 63
64 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 64 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
65 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); 65 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
66 fragBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);"); 66 fragBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);");
67 fragBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), ker nelOffset, imgInc); 67 fragBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), ker nelOffset, imgInc);
68 fragBuilder->codeAppend("vec4 c;"); 68 fragBuilder->codeAppend("vec4 c;");
69 69
70 for (int y = 0; y < kHeight; y++) { 70 for (int y = 0; y < kHeight; y++) {
71 for (int x = 0; x < kWidth; x++) { 71 for (int x = 0; x < kWidth; x++) {
72 GrGLSLShaderBuilder::ShaderBlock block(fragBuilder); 72 GrGLSLShaderBuilder::ShaderBlock block(fragBuilder);
73 fragBuilder->codeAppendf("float k = %s[%d * %d + %d];", kernel, y, k Width, x); 73 fragBuilder->codeAppendf("float k = %s[%d * %d + %d];", kernel, y, k Width, x);
74 SkString coord; 74 SkString coord;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx], 248 return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx],
249 bounds, 249 bounds,
250 kernelSize, 250 kernelSize,
251 kernel.get(), 251 kernel.get(),
252 gain, 252 gain,
253 bias, 253 bias,
254 kernelOffset, 254 kernelOffset,
255 tileMode, 255 tileMode,
256 convolveAlpha); 256 convolveAlpha);
257 } 257 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDitherEffect.cpp ('k') | src/gpu/effects/GrOvalEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698