| 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 "gl/GrGLProcessor.h" | 8 #include "gl/GrGLProcessor.h" |
| 9 #include "gl/GrGLSL.h" | 9 #include "gl/GrGLSL.h" |
| 10 #include "gl/GrGLTexture.h" | 10 #include "gl/GrGLTexture.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 for (int y = 0; y < kHeight; y++) { | 84 for (int y = 0; y < kHeight; y++) { |
| 85 for (int x = 0; x < kWidth; x++) { | 85 for (int x = 0; x < kWidth; x++) { |
| 86 GrGLShaderBuilder::ShaderBlock block(fsBuilder); | 86 GrGLShaderBuilder::ShaderBlock block(fsBuilder); |
| 87 fsBuilder->codeAppendf("float k = %s[%d * %d + %d];", kernel, y, kWi
dth, x); | 87 fsBuilder->codeAppendf("float k = %s[%d * %d + %d];", kernel, y, kWi
dth, x); |
| 88 SkString coord; | 88 SkString coord; |
| 89 coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc); | 89 coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc); |
| 90 fDomain.sampleTexture(fsBuilder, domain, "c", coord, samplers[0]); | 90 fDomain.sampleTexture(fsBuilder, domain, "c", coord, samplers[0]); |
| 91 if (!fConvolveAlpha) { | 91 if (!fConvolveAlpha) { |
| 92 fsBuilder->codeAppend("c.rgb /= c.a;"); | 92 fsBuilder->codeAppend("c.rgb /= c.a;"); |
| 93 fsBuilder->codeAppend("c.rgb = clamp(c.rgb, 0, 1);"); | 93 fsBuilder->codeAppend("c.rgb = clamp(c.rgb, 0.0, 1.0);"); |
| 94 } | 94 } |
| 95 fsBuilder->codeAppend("sum += c * k;"); | 95 fsBuilder->codeAppend("sum += c * k;"); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 if (fConvolveAlpha) { | 98 if (fConvolveAlpha) { |
| 99 fsBuilder->codeAppendf("%s = sum * %s + %s;", outputColor, gain, bias); | 99 fsBuilder->codeAppendf("%s = sum * %s + %s;", outputColor, gain, bias); |
| 100 fsBuilder->codeAppendf("%s.rgb = clamp(%s.rgb, 0.0, %s.a);", | 100 fsBuilder->codeAppendf("%s.rgb = clamp(%s.rgb, 0.0, %s.a);", |
| 101 outputColor, outputColor, outputColor); | 101 outputColor, outputColor, outputColor); |
| 102 } else { | 102 } else { |
| 103 fDomain.sampleTexture(fsBuilder, domain, "c", coords2D, samplers[0]); | 103 fDomain.sampleTexture(fsBuilder, domain, "c", coords2D, samplers[0]); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 return GrMatrixConvolutionEffect::Create(textures[texIdx], | 263 return GrMatrixConvolutionEffect::Create(textures[texIdx], |
| 264 bounds, | 264 bounds, |
| 265 kernelSize, | 265 kernelSize, |
| 266 kernel.get(), | 266 kernel.get(), |
| 267 gain, | 267 gain, |
| 268 bias, | 268 bias, |
| 269 kernelOffset, | 269 kernelOffset, |
| 270 tileMode, | 270 tileMode, |
| 271 convolveAlpha); | 271 convolveAlpha); |
| 272 } | 272 } |
| OLD | NEW |