blob: 4fdddd9c5a43010c1bb19e8a31a70f6b376189dc [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; }
27
28 static const char* Name() { return "Convolution"; }
29
30 typedef GrGLConvolutionEffect GLProgramStage;
31
32 virtual const char* name() const SK_OVERRIDE;
33 virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
34 virtual bool isEqual(const GrCustomStage *) const SK_OVERRIDE;
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000035
36protected:
37
38 GrSamplerState::FilterDirection fDirection;
39 unsigned int fKernelWidth;
40 float fKernel[MAX_KERNEL_WIDTH];
41
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000042
43private:
44
45 typedef GrCustomStage INHERITED;
46};
47
48#endif