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 21 matching lines...) Expand all Loading... |
32 typedef GrGLSLFragmentProcessor INHERITED; | 32 typedef GrGLSLFragmentProcessor INHERITED; |
33 }; | 33 }; |
34 | 34 |
35 void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) { | 35 void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) { |
36 const GrMatrixConvolutionEffect& mce = args.fFp.cast<GrMatrixConvolutionEffe
ct>(); | 36 const GrMatrixConvolutionEffect& mce = args.fFp.cast<GrMatrixConvolutionEffe
ct>(); |
37 const GrTextureDomain& domain = mce.domain(); | 37 const GrTextureDomain& domain = mce.domain(); |
38 | 38 |
39 int kWidth = mce.kernelSize().width(); | 39 int kWidth = mce.kernelSize().width(); |
40 int kHeight = mce.kernelSize().height(); | 40 int kHeight = mce.kernelSize().height(); |
41 | 41 |
42 int arrayCount = (kWidth + 3) / 4; | 42 int arrayCount = (kWidth * kHeight + 3) / 4; |
43 SkASSERT(4 * arrayCount >= kWidth); | 43 SkASSERT(4 * arrayCount >= kWidth * kHeight); |
44 | 44 |
45 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 45 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
46 fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 46 fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
47 kVec2f_GrSLType, kDefault_Gr
SLPrecision, | 47 kVec2f_GrSLType, kDefault_Gr
SLPrecision, |
48 "ImageIncrement"); | 48 "ImageIncrement"); |
49 fKernelUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag, | 49 fKernelUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag, |
50 kVec4f_GrSLType, kDefault_GrSLP
recision, | 50 kVec4f_GrSLType, kDefault_GrSLP
recision, |
51 "Kernel", | 51 "Kernel", |
52 arrayCount); | 52 arrayCount); |
53 fKernelOffsetUni = uniformHandler->addUniform(kFragment_GrShaderFlag, | 53 fKernelOffsetUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
(...skipping 204 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 |