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 #ifndef GrConvolutionEffect_DEFINED | 8 #ifndef GrConvolutionEffect_DEFINED |
9 #define GrConvolutionEffect_DEFINED | 9 #define GrConvolutionEffect_DEFINED |
10 | 10 |
11 #include "Gr1DKernelEffect.h" | 11 #include "Gr1DKernelEffect.h" |
12 | 12 |
13 class GrGLConvolutionEffect; | 13 class GrGLConvolutionEffect; |
14 | 14 |
15 /** | 15 /** |
16 * A convolution effect. The kernel is specified as an array of 2 * half-width | 16 * A convolution effect. The kernel is specified as an array of 2 * half-width |
17 * + 1 weights. Each texel is multiplied by it's weight and summed to determine | 17 * + 1 weights. Each texel is multiplied by it's weight and summed to determine |
18 * the output color. The output color is modulated by the input color. | 18 * the output color. The output color is modulated by the input color. |
19 */ | 19 */ |
20 class GrConvolutionEffect : public Gr1DKernelEffect { | 20 class GrConvolutionEffect : public Gr1DKernelEffect { |
21 | 21 |
22 public: | 22 public: |
23 | 23 |
24 /// Convolve with an arbitrary user-specified kernel | 24 /// Convolve with an arbitrary user-specified kernel |
25 static GrEffectRef* Create(GrTexture* tex, | 25 static GrEffect* Create(GrTexture* tex, |
26 Direction dir, | 26 Direction dir, |
27 int halfWidth, | 27 int halfWidth, |
28 const float* kernel, | 28 const float* kernel, |
29 bool useBounds, | 29 bool useBounds, |
30 float bounds[2]) { | 30 float bounds[2]) { |
31 return SkNEW_ARGS(GrConvolutionEffect, (tex, | 31 return SkNEW_ARGS(GrConvolutionEffect, (tex, |
32 dir, | 32 dir, |
33 halfWidth, | 33 halfWidth, |
34 kernel, | 34 kernel, |
35 useBounds, | 35 useBounds, |
36 bounds)); | 36 bounds)); |
37 } | 37 } |
38 | 38 |
39 /// Convolve with a Gaussian kernel | 39 /// Convolve with a Gaussian kernel |
40 static GrEffectRef* CreateGaussian(GrTexture* tex, | 40 static GrEffect* CreateGaussian(GrTexture* tex, |
41 Direction dir, | 41 Direction dir, |
42 int halfWidth, | 42 int halfWidth, |
43 float gaussianSigma, | 43 float gaussianSigma, |
44 bool useBounds, | 44 bool useBounds, |
45 float bounds[2]) { | 45 float bounds[2]) { |
46 return SkNEW_ARGS(GrConvolutionEffect, (tex, | 46 return SkNEW_ARGS(GrConvolutionEffect, (tex, |
47 dir, | 47 dir, |
48 halfWidth, | 48 halfWidth, |
49 gaussianSigma, | 49 gaussianSigma, |
50 useBounds, | 50 useBounds, |
51 bounds)); | 51 bounds)); |
52 } | 52 } |
53 | 53 |
54 virtual ~GrConvolutionEffect(); | 54 virtual ~GrConvolutionEffect(); |
55 | 55 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 float bounds[2]); | 102 float bounds[2]); |
103 | 103 |
104 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; | 104 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; |
105 | 105 |
106 GR_DECLARE_EFFECT_TEST; | 106 GR_DECLARE_EFFECT_TEST; |
107 | 107 |
108 typedef Gr1DKernelEffect INHERITED; | 108 typedef Gr1DKernelEffect INHERITED; |
109 }; | 109 }; |
110 | 110 |
111 #endif | 111 #endif |
OLD | NEW |