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