| 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 | 7 |
| 8 #ifndef GrMatrixConvolutionEffect_DEFINED | 8 #ifndef GrMatrixConvolutionEffect_DEFINED |
| 9 #define GrMatrixConvolutionEffect_DEFINED | 9 #define GrMatrixConvolutionEffect_DEFINED |
| 10 | 10 |
| 11 #include "GrSingleTextureEffect.h" | 11 #include "GrSingleTextureEffect.h" |
| 12 #include "GrInvariantOutput.h" | 12 #include "GrInvariantOutput.h" |
| 13 #include "GrTextureDomain.h" | 13 #include "GrTextureDomain.h" |
| 14 | 14 |
| 15 // A little bit less than the minimum # uniforms required by DX9SM2 (32). | 15 // A little bit less than the minimum # uniforms required by DX9SM2 (32). |
| 16 // Allows for a 5x5 kernel (or 25x1, for that matter). | 16 // Allows for a 5x5 kernel (or 25x1, for that matter). |
| 17 #define MAX_KERNEL_SIZE 25 | 17 #define MAX_KERNEL_SIZE 25 |
| 18 | 18 |
| 19 class GrMatrixConvolutionEffect : public GrSingleTextureEffect { | 19 class GrMatrixConvolutionEffect : public GrSingleTextureEffect { |
| 20 public: | 20 public: |
| 21 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, | 21 static GrFragmentProcessor* Create(GrTexture* texture, |
| 22 GrTexture* texture, | |
| 23 const SkIRect& bounds, | 22 const SkIRect& bounds, |
| 24 const SkISize& kernelSize, | 23 const SkISize& kernelSize, |
| 25 const SkScalar* kernel, | 24 const SkScalar* kernel, |
| 26 SkScalar gain, | 25 SkScalar gain, |
| 27 SkScalar bias, | 26 SkScalar bias, |
| 28 const SkIPoint& kernelOffset, | 27 const SkIPoint& kernelOffset, |
| 29 GrTextureDomain::Mode tileMode, | 28 GrTextureDomain::Mode tileMode, |
| 30 bool convolveAlpha) { | 29 bool convolveAlpha) { |
| 31 return new GrMatrixConvolutionEffect(procDataManager, texture, bounds, k
ernelSize, kernel, | 30 return new GrMatrixConvolutionEffect(texture, bounds, kernelSize, kernel
, gain, bias, |
| 32 gain, bias, kernelOffset, tileMode,
convolveAlpha); | 31 kernelOffset, tileMode, convolveAlp
ha); |
| 33 } | 32 } |
| 34 | 33 |
| 35 static GrFragmentProcessor* CreateGaussian(GrProcessorDataManager*, | 34 static GrFragmentProcessor* CreateGaussian(GrTexture* texture, |
| 36 GrTexture* texture, | |
| 37 const SkIRect& bounds, | 35 const SkIRect& bounds, |
| 38 const SkISize& kernelSize, | 36 const SkISize& kernelSize, |
| 39 SkScalar gain, | 37 SkScalar gain, |
| 40 SkScalar bias, | 38 SkScalar bias, |
| 41 const SkIPoint& kernelOffset, | 39 const SkIPoint& kernelOffset, |
| 42 GrTextureDomain::Mode tileMode, | 40 GrTextureDomain::Mode tileMode, |
| 43 bool convolveAlpha, | 41 bool convolveAlpha, |
| 44 SkScalar sigmaX, | 42 SkScalar sigmaX, |
| 45 SkScalar sigmaY); | 43 SkScalar sigmaY); |
| 46 | 44 |
| 47 virtual ~GrMatrixConvolutionEffect(); | 45 virtual ~GrMatrixConvolutionEffect(); |
| 48 | 46 |
| 49 const SkIRect& bounds() const { return fBounds; } | 47 const SkIRect& bounds() const { return fBounds; } |
| 50 const SkISize& kernelSize() const { return fKernelSize; } | 48 const SkISize& kernelSize() const { return fKernelSize; } |
| 51 const float* kernelOffset() const { return fKernelOffset; } | 49 const float* kernelOffset() const { return fKernelOffset; } |
| 52 const float* kernel() const { return fKernel; } | 50 const float* kernel() const { return fKernel; } |
| 53 float gain() const { return fGain; } | 51 float gain() const { return fGain; } |
| 54 float bias() const { return fBias; } | 52 float bias() const { return fBias; } |
| 55 bool convolveAlpha() const { return fConvolveAlpha; } | 53 bool convolveAlpha() const { return fConvolveAlpha; } |
| 56 const GrTextureDomain& domain() const { return fDomain; } | 54 const GrTextureDomain& domain() const { return fDomain; } |
| 57 | 55 |
| 58 const char* name() const override { return "MatrixConvolution"; } | 56 const char* name() const override { return "MatrixConvolution"; } |
| 59 | 57 |
| 60 private: | 58 private: |
| 61 GrMatrixConvolutionEffect(GrProcessorDataManager*, | 59 GrMatrixConvolutionEffect(GrTexture*, |
| 62 GrTexture*, | |
| 63 const SkIRect& bounds, | 60 const SkIRect& bounds, |
| 64 const SkISize& kernelSize, | 61 const SkISize& kernelSize, |
| 65 const SkScalar* kernel, | 62 const SkScalar* kernel, |
| 66 SkScalar gain, | 63 SkScalar gain, |
| 67 SkScalar bias, | 64 SkScalar bias, |
| 68 const SkIPoint& kernelOffset, | 65 const SkIPoint& kernelOffset, |
| 69 GrTextureDomain::Mode tileMode, | 66 GrTextureDomain::Mode tileMode, |
| 70 bool convolveAlpha); | 67 bool convolveAlpha); |
| 71 | 68 |
| 72 GrGLFragmentProcessor* onCreateGLInstance() const override; | 69 GrGLFragmentProcessor* onCreateGLInstance() const override; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 88 float fKernelOffset[2]; | 85 float fKernelOffset[2]; |
| 89 bool fConvolveAlpha; | 86 bool fConvolveAlpha; |
| 90 GrTextureDomain fDomain; | 87 GrTextureDomain fDomain; |
| 91 | 88 |
| 92 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 89 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 93 | 90 |
| 94 typedef GrSingleTextureEffect INHERITED; | 91 typedef GrSingleTextureEffect INHERITED; |
| 95 }; | 92 }; |
| 96 | 93 |
| 97 #endif | 94 #endif |
| OLD | NEW |