| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 23 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
| 24 | 24 |
| 25 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; | 25 void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 28 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
| 29 SkISize fKernelSize; | 29 SkISize fKernelSize; |
| 30 bool fConvolveAlpha; | 30 bool fConvolveAlpha; |
| 31 | 31 |
| 32 UniformHandle fBoundsUni; | |
| 33 UniformHandle fKernelUni; | 32 UniformHandle fKernelUni; |
| 34 UniformHandle fImageIncrementUni; | 33 UniformHandle fImageIncrementUni; |
| 35 UniformHandle fKernelOffsetUni; | 34 UniformHandle fKernelOffsetUni; |
| 36 UniformHandle fGainUni; | 35 UniformHandle fGainUni; |
| 37 UniformHandle fBiasUni; | 36 UniformHandle fBiasUni; |
| 38 GrTextureDomain::GLDomain fDomain; | 37 GrTextureDomain::GLDomain fDomain; |
| 39 | 38 |
| 40 typedef GrGLFragmentProcessor INHERITED; | 39 typedef GrGLFragmentProcessor INHERITED; |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrProcessor& proc
essor) { | 42 GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrProcessor& proc
essor) { |
| 44 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec
t>(); | 43 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec
t>(); |
| 45 fKernelSize = m.kernelSize(); | 44 fKernelSize = m.kernelSize(); |
| 46 fConvolveAlpha = m.convolveAlpha(); | 45 fConvolveAlpha = m.convolveAlpha(); |
| 47 } | 46 } |
| 48 | 47 |
| 49 void GrGLMatrixConvolutionEffect::emitCode(GrGLFPBuilder* builder, | 48 void GrGLMatrixConvolutionEffect::emitCode(GrGLFPBuilder* builder, |
| 50 const GrFragmentProcessor& fp, | 49 const GrFragmentProcessor& fp, |
| 51 const char* outputColor, | 50 const char* outputColor, |
| 52 const char* inputColor, | 51 const char* inputColor, |
| 53 const TransformedCoordsArray& coords, | 52 const TransformedCoordsArray& coords, |
| 54 const TextureSamplerArray& samplers)
{ | 53 const TextureSamplerArray& samplers)
{ |
| 55 const GrTextureDomain& domain = fp.cast<GrMatrixConvolutionEffect>().domain(
); | 54 const GrTextureDomain& domain = fp.cast<GrMatrixConvolutionEffect>().domain(
); |
| 56 | |
| 57 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, | |
| 58 kVec4f_GrSLType, kDefault_GrSLPrecision, "B
ounds"); | |
| 59 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, | 55 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, |
| 60 kVec2f_GrSLType, kDefault_GrSLPreci
sion, | 56 kVec2f_GrSLType, kDefault_GrSLPreci
sion, |
| 61 "ImageIncrement"); | 57 "ImageIncrement"); |
| 62 fKernelUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibili
ty, | 58 fKernelUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibili
ty, |
| 63 kFloat_GrSLType, kDefault_GrSLPrecisio
n, | 59 kFloat_GrSLType, kDefault_GrSLPrecisio
n, |
| 64 "Kernel", | 60 "Kernel", |
| 65 fKernelSize.width() * fKernelSize.heig
ht()); | 61 fKernelSize.width() * fKernelSize.heig
ht()); |
| 66 fKernelOffsetUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibil
ity, | 62 fKernelOffsetUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibil
ity, |
| 67 kVec2f_GrSLType, kDefault_GrSLPrecisi
on, "KernelOffset"); | 63 kVec2f_GrSLType, kDefault_GrSLPrecisi
on, "KernelOffset"); |
| 68 fGainUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, | 64 fGainUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 return GrMatrixConvolutionEffect::Create(textures[texIdx], | 262 return GrMatrixConvolutionEffect::Create(textures[texIdx], |
| 267 bounds, | 263 bounds, |
| 268 kernelSize, | 264 kernelSize, |
| 269 kernel.get(), | 265 kernel.get(), |
| 270 gain, | 266 gain, |
| 271 bias, | 267 bias, |
| 272 kernelOffset, | 268 kernelOffset, |
| 273 tileMode, | 269 tileMode, |
| 274 convolveAlpha); | 270 convolveAlpha); |
| 275 } | 271 } |
| OLD | NEW |