| 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 "GrConvolutionEffect.h" | 8 #include "GrConvolutionEffect.h" |
| 9 #include "gl/GrGLEffect.h" | 9 #include "gl/GrGLEffect.h" |
| 10 #include "gl/GrGLSL.h" | 10 #include "gl/GrGLSL.h" |
| 11 #include "gl/GrGLTexture.h" | 11 #include "gl/GrGLTexture.h" |
| 12 #include "GrTBackendEffectFactory.h" | 12 #include "GrTBackendEffectFactory.h" |
| 13 | 13 |
| 14 // For brevity | 14 // For brevity |
| 15 typedef GrGLUniformManager::UniformHandle UniformHandle; | 15 typedef GrGLUniformManager::UniformHandle UniformHandle; |
| 16 | 16 |
| 17 class GrGLConvolutionEffect : public GrGLEffect { | 17 class GrGLConvolutionEffect : public GrGLEffect { |
| 18 public: | 18 public: |
| 19 GrGLConvolutionEffect(const GrBackendEffectFactory&, const GrDrawEffect&); | 19 GrGLConvolutionEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
| 20 | 20 |
| 21 virtual void emitCode(GrGLShaderBuilder*, | 21 virtual void emitCode(GrGLShaderBuilder*, |
| 22 const GrDrawEffect&, | 22 const GrDrawEffect&, |
| 23 EffectKey, | 23 EffectKey, |
| 24 const char* outputColor, | 24 const char* outputColor, |
| 25 const char* inputColor, | 25 const GrGLSLExpr4& inputColor, |
| 26 const TransformedCoordsArray&, | 26 const TransformedCoordsArray&, |
| 27 const TextureSamplerArray&) SK_OVERRIDE; | 27 const TextureSamplerArray&) SK_OVERRIDE; |
| 28 | 28 |
| 29 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&) SK
_OVERRIDE; | 29 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&) SK
_OVERRIDE; |
| 30 | 30 |
| 31 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); | 31 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); } | 34 int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); } |
| 35 bool useBounds() const { return fUseBounds; } | 35 bool useBounds() const { return fUseBounds; } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 51 const GrConvolutionEffect& c = drawEffect.castEffect<GrConvolutionEffect>(); | 51 const GrConvolutionEffect& c = drawEffect.castEffect<GrConvolutionEffect>(); |
| 52 fRadius = c.radius(); | 52 fRadius = c.radius(); |
| 53 fUseBounds = c.useBounds(); | 53 fUseBounds = c.useBounds(); |
| 54 fDirection = c.direction(); | 54 fDirection = c.direction(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder, | 57 void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder, |
| 58 const GrDrawEffect&, | 58 const GrDrawEffect&, |
| 59 EffectKey key, | 59 EffectKey key, |
| 60 const char* outputColor, | 60 const char* outputColor, |
| 61 const char* inputColor, | 61 const GrGLSLExpr4& inputColor, |
| 62 const TransformedCoordsArray& coords, | 62 const TransformedCoordsArray& coords, |
| 63 const TextureSamplerArray& samplers) { | 63 const TextureSamplerArray& samplers) { |
| 64 SkString coords2D = builder->ensureFSCoords2D(coords, 0); | 64 SkString coords2D = builder->ensureFSCoords2D(coords, 0); |
| 65 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, | 65 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, |
| 66 kVec2f_GrSLType, "ImageIncrement"); | 66 kVec2f_GrSLType, "ImageIncrement"); |
| 67 if (this->useBounds()) { | 67 if (this->useBounds()) { |
| 68 fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility
, | 68 fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility
, |
| 69 kVec2f_GrSLType, "Bounds"); | 69 kVec2f_GrSLType, "Bounds"); |
| 70 } | 70 } |
| 71 fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibilit
y, | 71 fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibilit
y, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool useBounds = random->nextBool(); | 231 bool useBounds = random->nextBool(); |
| 232 return GrConvolutionEffect::Create(textures[texIdx], | 232 return GrConvolutionEffect::Create(textures[texIdx], |
| 233 dir, | 233 dir, |
| 234 radius, | 234 radius, |
| 235 kernel, | 235 kernel, |
| 236 useBounds, | 236 useBounds, |
| 237 bounds); | 237 bounds); |
| 238 } | 238 } |
| OLD | NEW |