blob: df164d51fba43e9c41173679ac4037a2a0ac630a [file] [log] [blame]
tomhudson@google.comd8f856c2012-05-10 12:13:36 +00001/*
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.comae4f96a2012-05-18 19:54:48 +000014class GrGLConvolutionEffect;
15
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000016class GrConvolutionEffect : public GrCustomStage {
17
18public:
19
20 GrConvolutionEffect(GrSamplerState::FilterDirection direction,
21 unsigned int kernelWidth, const float* kernel);
22 virtual ~GrConvolutionEffect();
23
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000024 unsigned int width() const { return fKernelWidth; }
bsalomon@google.comae4f96a2012-05-18 19:54:48 +000025 const float* kernel() const { return fKernel; }
26 GrSamplerState::FilterDirection direction() const { return fDirection; }
bsalomon@google.com289efe02012-05-21 20:57:59 +000027
bsalomon@google.comae4f96a2012-05-18 19:54:48 +000028 static const char* Name() { return "Convolution"; }
29
30 typedef GrGLConvolutionEffect GLProgramStage;
bsalomon@google.com289efe02012-05-21 20:57:59 +000031
bsalomon@google.comae4f96a2012-05-18 19:54:48 +000032 virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
33 virtual bool isEqual(const GrCustomStage *) const SK_OVERRIDE;
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000034
35protected:
36
37 GrSamplerState::FilterDirection fDirection;
38 unsigned int fKernelWidth;
39 float fKernel[MAX_KERNEL_WIDTH];
40
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000041
42private:
43
44 typedef GrCustomStage INHERITED;
45};
46
47#endif