| 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" |
| 11 #include "gl/GrGLTexture.h" | 11 #include "gl/GrGLTexture.h" |
| 12 #include "GrTBackendProcessorFactory.h" | 12 #include "GrTBackendProcessorFactory.h" |
| 13 | 13 |
| 14 class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor { | 14 class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor { |
| 15 public: | 15 public: |
| 16 GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory, | 16 GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory, |
| 17 const GrProcessor&); | 17 const GrProcessor&); |
| 18 virtual void emitCode(GrGLFPBuilder*, | 18 virtual void emitCode(GrGLFPBuilder*, |
| 19 const GrFragmentProcessor&, | 19 const GrFragmentProcessor&, |
| 20 const GrProcessorKey&, | |
| 21 const char* outputColor, | 20 const char* outputColor, |
| 22 const char* inputColor, | 21 const char* inputColor, |
| 23 const TransformedCoordsArray&, | 22 const TransformedCoordsArray&, |
| 24 const TextureSamplerArray&) SK_OVERRIDE; | 23 const TextureSamplerArray&) SK_OVERRIDE; |
| 25 | 24 |
| 26 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 25 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
| 27 | 26 |
| 28 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 27 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; |
| 29 | 28 |
| 30 private: | 29 private: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendProcesso
rFactory& factory, | 45 GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendProcesso
rFactory& factory, |
| 47 const GrProcessor& proc
essor) | 46 const GrProcessor& proc
essor) |
| 48 : INHERITED(factory) { | 47 : INHERITED(factory) { |
| 49 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec
t>(); | 48 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec
t>(); |
| 50 fKernelSize = m.kernelSize(); | 49 fKernelSize = m.kernelSize(); |
| 51 fConvolveAlpha = m.convolveAlpha(); | 50 fConvolveAlpha = m.convolveAlpha(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 void GrGLMatrixConvolutionEffect::emitCode(GrGLFPBuilder* builder, | 53 void GrGLMatrixConvolutionEffect::emitCode(GrGLFPBuilder* builder, |
| 55 const GrFragmentProcessor& fp, | 54 const GrFragmentProcessor& fp, |
| 56 const GrProcessorKey& key, | |
| 57 const char* outputColor, | 55 const char* outputColor, |
| 58 const char* inputColor, | 56 const char* inputColor, |
| 59 const TransformedCoordsArray& coords, | 57 const TransformedCoordsArray& coords, |
| 60 const TextureSamplerArray& samplers)
{ | 58 const TextureSamplerArray& samplers)
{ |
| 61 const GrTextureDomain& domain = fp.cast<GrMatrixConvolutionEffect>().domain(
); | 59 const GrTextureDomain& domain = fp.cast<GrMatrixConvolutionEffect>().domain(
); |
| 62 | 60 |
| 63 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, | 61 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, |
| 64 kVec4f_GrSLType, "Bounds"); | 62 kVec4f_GrSLType, "Bounds"); |
| 65 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, | 63 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, |
| 66 kVec2f_GrSLType, "ImageIncrement"); | 64 kVec2f_GrSLType, "ImageIncrement"); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return GrMatrixConvolutionEffect::Create(textures[texIdx], | 263 return GrMatrixConvolutionEffect::Create(textures[texIdx], |
| 266 bounds, | 264 bounds, |
| 267 kernelSize, | 265 kernelSize, |
| 268 kernel.get(), | 266 kernel.get(), |
| 269 gain, | 267 gain, |
| 270 bias, | 268 bias, |
| 271 kernelOffset, | 269 kernelOffset, |
| 272 tileMode, | 270 tileMode, |
| 273 convolveAlpha); | 271 convolveAlpha); |
| 274 } | 272 } |
| OLD | NEW |