OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 fragBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);"); | 69 fragBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);"); |
70 fragBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), ker
nelOffset, imgInc); | 70 fragBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), ker
nelOffset, imgInc); |
71 fragBuilder->codeAppend("vec4 c;"); | 71 fragBuilder->codeAppend("vec4 c;"); |
72 | 72 |
73 const char* kVecSuffix[4] = { ".x", ".y", ".z", ".w" }; | 73 const char* kVecSuffix[4] = { ".x", ".y", ".z", ".w" }; |
74 for (int y = 0; y < kHeight; y++) { | 74 for (int y = 0; y < kHeight; y++) { |
75 for (int x = 0; x < kWidth; x++) { | 75 for (int x = 0; x < kWidth; x++) { |
76 GrGLSLShaderBuilder::ShaderBlock block(fragBuilder); | 76 GrGLSLShaderBuilder::ShaderBlock block(fragBuilder); |
77 int offset = y*kWidth + x; | 77 int offset = y*kWidth + x; |
78 | 78 |
79 fragBuilder->codeAppendf("float k = %s[%d]%s;", kernel, offset / 4, | 79 fragBuilder->codeAppendf("float k = %s[%d]%s;", kernel, offset / 4, |
80 kVecSuffix[offset & 0x3]); | 80 kVecSuffix[offset & 0x3]); |
81 SkString coord; | 81 SkString coord; |
82 coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc); | 82 coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc); |
83 fDomain.sampleTexture(fragBuilder, | 83 fDomain.sampleTexture(fragBuilder, |
84 uniformHandler, | 84 uniformHandler, |
85 args.fGLSLCaps, | 85 args.fGLSLCaps, |
86 domain, | 86 domain, |
87 "c", | 87 "c", |
88 coord, | 88 coord, |
89 args.fSamplers[0]); | 89 args.fSamplers[0]); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx], | 258 return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx], |
259 bounds, | 259 bounds, |
260 kernelSize, | 260 kernelSize, |
261 kernel.get(), | 261 kernel.get(), |
262 gain, | 262 gain, |
263 bias, | 263 bias, |
264 kernelOffset, | 264 kernelOffset, |
265 tileMode, | 265 tileMode, |
266 convolveAlpha); | 266 convolveAlpha); |
267 } | 267 } |
OLD | NEW |