tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrConvolutionEffect_DEFINED |
| 9 | #define GrConvolutionEffect_DEFINED |
| 10 | |
| 11 | #include "GrCustomStage.h" |
| 12 | #include "GrSamplerState.h" // for MAX_KENEL_WIDTH, FilterDirection |
| 13 | |
bsalomon@google.com | ae4f96a | 2012-05-18 19:54:48 +0000 | [diff] [blame] | 14 | class GrGLConvolutionEffect; |
| 15 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 16 | class GrConvolutionEffect : public GrCustomStage { |
| 17 | |
| 18 | public: |
| 19 | |
| 20 | GrConvolutionEffect(GrSamplerState::FilterDirection direction, |
| 21 | unsigned int kernelWidth, const float* kernel); |
| 22 | virtual ~GrConvolutionEffect(); |
| 23 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 24 | unsigned int width() const { return fKernelWidth; } |
bsalomon@google.com | ae4f96a | 2012-05-18 19:54:48 +0000 | [diff] [blame] | 25 | const float* kernel() const { return fKernel; } |
| 26 | GrSamplerState::FilterDirection direction() const { return fDirection; } |
bsalomon@google.com | 289efe0 | 2012-05-21 20:57:59 +0000 | [diff] [blame^] | 27 | |
bsalomon@google.com | ae4f96a | 2012-05-18 19:54:48 +0000 | [diff] [blame] | 28 | static const char* Name() { return "Convolution"; } |
| 29 | |
| 30 | typedef GrGLConvolutionEffect GLProgramStage; |
bsalomon@google.com | 289efe0 | 2012-05-21 20:57:59 +0000 | [diff] [blame^] | 31 | |
bsalomon@google.com | ae4f96a | 2012-05-18 19:54:48 +0000 | [diff] [blame] | 32 | virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE; |
| 33 | virtual bool isEqual(const GrCustomStage *) const SK_OVERRIDE; |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 34 | |
| 35 | protected: |
| 36 | |
| 37 | GrSamplerState::FilterDirection fDirection; |
| 38 | unsigned int fKernelWidth; |
| 39 | float fKernel[MAX_KERNEL_WIDTH]; |
| 40 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | |
| 44 | typedef GrCustomStage INHERITED; |
| 45 | }; |
| 46 | |
| 47 | #endif |