| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 7 |
| 8 #include "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
| 9 #include "GrConvolutionEffect.h" | 9 #include "GrConvolutionEffect.h" |
| 10 #include "gl/GrGLProcessor.h" | 10 #include "gl/GrGLProcessor.h" |
| 11 #include "gl/GrGLSL.h" | 11 #include "gl/GrGLSL.h" |
| 12 #include "gl/GrGLTexture.h" | 12 #include "gl/GrGLTexture.h" |
| 13 #include "GrTBackendProcessorFactory.h" | 13 #include "GrTBackendProcessorFactory.h" |
| 14 | 14 |
| 15 // For brevity | 15 // For brevity |
| 16 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 16 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
| 17 | 17 |
| 18 class GrGLConvolutionEffect : public GrGLFragmentProcessor { | 18 class GrGLConvolutionEffect : public GrGLFragmentProcessor { |
| 19 public: | 19 public: |
| 20 GrGLConvolutionEffect(const GrBackendProcessorFactory&, const GrProcessor&); | 20 GrGLConvolutionEffect(const GrBackendProcessorFactory&, const GrProcessor&); |
| 21 | 21 |
| 22 virtual void emitCode(GrGLFPBuilder*, | 22 virtual void emitCode(GrGLFPBuilder*, |
| 23 const GrFragmentProcessor&, | 23 const GrFragmentProcessor&, |
| 24 const GrProcessorKey&, | |
| 25 const char* outputColor, | 24 const char* outputColor, |
| 26 const char* inputColor, | 25 const char* inputColor, |
| 27 const TransformedCoordsArray&, | 26 const TransformedCoordsArray&, |
| 28 const TextureSamplerArray&) SK_OVERRIDE; | 27 const TextureSamplerArray&) SK_OVERRIDE; |
| 29 | 28 |
| 30 virtual void setData(const GrGLProgramDataManager& pdman, const GrProcessor&
) SK_OVERRIDE; | 29 virtual void setData(const GrGLProgramDataManager& pdman, const GrProcessor&
) SK_OVERRIDE; |
| 31 | 30 |
| 32 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 31 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
| 33 | 32 |
| 34 private: | 33 private: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 50 const GrProcessor& processor) | 49 const GrProcessor& processor) |
| 51 : INHERITED(factory) { | 50 : INHERITED(factory) { |
| 52 const GrConvolutionEffect& c = processor.cast<GrConvolutionEffect>(); | 51 const GrConvolutionEffect& c = processor.cast<GrConvolutionEffect>(); |
| 53 fRadius = c.radius(); | 52 fRadius = c.radius(); |
| 54 fUseBounds = c.useBounds(); | 53 fUseBounds = c.useBounds(); |
| 55 fDirection = c.direction(); | 54 fDirection = c.direction(); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void GrGLConvolutionEffect::emitCode(GrGLFPBuilder* builder, | 57 void GrGLConvolutionEffect::emitCode(GrGLFPBuilder* builder, |
| 59 const GrFragmentProcessor&, | 58 const GrFragmentProcessor&, |
| 60 const GrProcessorKey& key, | |
| 61 const char* outputColor, | 59 const char* outputColor, |
| 62 const char* inputColor, | 60 const char* inputColor, |
| 63 const TransformedCoordsArray& coords, | 61 const TransformedCoordsArray& coords, |
| 64 const TextureSamplerArray& samplers) { | 62 const TextureSamplerArray& samplers) { |
| 65 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, | 63 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, |
| 66 kVec2f_GrSLType, "ImageIncrement"); | 64 kVec2f_GrSLType, "ImageIncrement"); |
| 67 if (this->useBounds()) { | 65 if (this->useBounds()) { |
| 68 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit
y, | 66 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit
y, |
| 69 kVec2f_GrSLType, "Bounds"); | 67 kVec2f_GrSLType, "Bounds"); |
| 70 } | 68 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } | 229 } |
| 232 | 230 |
| 233 bool useBounds = random->nextBool(); | 231 bool useBounds = random->nextBool(); |
| 234 return GrConvolutionEffect::Create(textures[texIdx], | 232 return GrConvolutionEffect::Create(textures[texIdx], |
| 235 dir, | 233 dir, |
| 236 radius, | 234 radius, |
| 237 kernel, | 235 kernel, |
| 238 useBounds, | 236 useBounds, |
| 239 bounds); | 237 bounds); |
| 240 } | 238 } |
| OLD | NEW |