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 "gl/builders/GrGLProgramBuilder.h" | 7 #include "gl/builders/GrGLProgramBuilder.h" |
8 #include "GrMatrixConvolutionEffect.h" | 8 #include "GrMatrixConvolutionEffect.h" |
9 #include "gl/GrGLProcessor.h" | 9 #include "gl/GrGLProcessor.h" |
10 #include "gl/GrGLSL.h" | 10 #include "gl/GrGLSL.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 fsBuilder->codeAppendf("%s.rgb = clamp(%s.rgb, 0.0, %s.a);", | 109 fsBuilder->codeAppendf("%s.rgb = clamp(%s.rgb, 0.0, %s.a);", |
110 outputColor, outputColor, outputColor); | 110 outputColor, outputColor, outputColor); |
111 } else { | 111 } else { |
112 fDomain.sampleTexture(fsBuilder, domain, "c", coords2D, samplers[0]); | 112 fDomain.sampleTexture(fsBuilder, domain, "c", coords2D, samplers[0]); |
113 fsBuilder->codeAppendf("%s.a = c.a;", outputColor); | 113 fsBuilder->codeAppendf("%s.a = c.a;", outputColor); |
114 fsBuilder->codeAppendf("%s.rgb = sum.rgb * %s + %s;", outputColor, gain,
bias); | 114 fsBuilder->codeAppendf("%s.rgb = sum.rgb * %s + %s;", outputColor, gain,
bias); |
115 fsBuilder->codeAppendf("%s.rgb *= %s.a;", outputColor, outputColor); | 115 fsBuilder->codeAppendf("%s.rgb *= %s.a;", outputColor, outputColor); |
116 } | 116 } |
117 | 117 |
118 SkString modulate; | 118 SkString modulate; |
119 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); | 119 GrGLSLMulVarBy4f(&modulate, outputColor, inputColor); |
120 fsBuilder->codeAppend(modulate.c_str()); | 120 fsBuilder->codeAppend(modulate.c_str()); |
121 } | 121 } |
122 | 122 |
123 void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor, | 123 void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor, |
124 const GrGLCaps&, GrProcessorKeyBuilder*
b) { | 124 const GrGLCaps&, GrProcessorKeyBuilder*
b) { |
125 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec
t>(); | 125 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec
t>(); |
126 SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFF
FF); | 126 SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFF
FF); |
127 uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height(); | 127 uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height(); |
128 key |= m.convolveAlpha() ? 1 << 31 : 0; | 128 key |= m.convolveAlpha() ? 1 << 31 : 0; |
129 b->add32(key); | 129 b->add32(key); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 return GrMatrixConvolutionEffect::Create(textures[texIdx], | 267 return GrMatrixConvolutionEffect::Create(textures[texIdx], |
268 bounds, | 268 bounds, |
269 kernelSize, | 269 kernelSize, |
270 kernel.get(), | 270 kernel.get(), |
271 gain, | 271 gain, |
272 bias, | 272 bias, |
273 kernelOffset, | 273 kernelOffset, |
274 tileMode, | 274 tileMode, |
275 convolveAlpha); | 275 convolveAlpha); |
276 } | 276 } |
OLD | NEW |