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 #include "GrInvariantOutput.h" | 12 #include "GrInvariantOutput.h" |
13 | 13 |
14 class GrGLConvolutionEffect; | |
15 | |
16 /** | 14 /** |
17 * A convolution effect. The kernel is specified as an array of 2 * half-width | 15 * A convolution effect. The kernel is specified as an array of 2 * half-width |
18 * + 1 weights. Each texel is multiplied by it's weight and summed to determine | 16 * + 1 weights. Each texel is multiplied by it's weight and summed to determine |
19 * the output color. The output color is modulated by the input color. | 17 * the output color. The output color is modulated by the input color. |
20 */ | 18 */ |
21 class GrConvolutionEffect : public Gr1DKernelEffect { | 19 class GrConvolutionEffect : public Gr1DKernelEffect { |
22 | 20 |
23 public: | 21 public: |
24 | 22 |
25 /// Convolve with an arbitrary user-specified kernel | 23 /// Convolve with an arbitrary user-specified kernel |
(...skipping 26 matching lines...) Expand all Loading... |
52 bounds)); | 50 bounds)); |
53 } | 51 } |
54 | 52 |
55 virtual ~GrConvolutionEffect(); | 53 virtual ~GrConvolutionEffect(); |
56 | 54 |
57 const float* kernel() const { return fKernel; } | 55 const float* kernel() const { return fKernel; } |
58 | 56 |
59 const float* bounds() const { return fBounds; } | 57 const float* bounds() const { return fBounds; } |
60 bool useBounds() const { return fUseBounds; } | 58 bool useBounds() const { return fUseBounds; } |
61 | 59 |
62 static const char* Name() { return "Convolution"; } | 60 virtual const char* name() const SK_OVERRIDE { return "Convolution"; } |
63 | 61 |
64 typedef GrGLConvolutionEffect GLProcessor; | 62 virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) cons
t SK_OVERRIDE; |
65 | 63 |
66 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 64 virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; |
67 | 65 |
68 enum { | 66 enum { |
69 // This was decided based on the min allowed value for the max texture | 67 // This was decided based on the min allowed value for the max texture |
70 // samples per fragment program run in DX9SM2 (32). A sigma param of 4.0 | 68 // samples per fragment program run in DX9SM2 (32). A sigma param of 4.0 |
71 // on a blur filter gives a kernel width of 25 while a sigma of 5.0 | 69 // on a blur filter gives a kernel width of 25 while a sigma of 5.0 |
72 // would exceed a 32 wide kernel. | 70 // would exceed a 32 wide kernel. |
73 kMaxKernelRadius = 12, | 71 kMaxKernelRadius = 12, |
74 // With a C++11 we could have a constexpr version of WidthFromRadius() | 72 // With a C++11 we could have a constexpr version of WidthFromRadius() |
75 // and not have to duplicate this calculation. | 73 // and not have to duplicate this calculation. |
76 kMaxKernelWidth = 2 * kMaxKernelRadius + 1, | 74 kMaxKernelWidth = 2 * kMaxKernelRadius + 1, |
(...skipping 26 matching lines...) Expand all Loading... |
103 // kernel values. | 101 // kernel values. |
104 inout->mulByUnknownColor(); | 102 inout->mulByUnknownColor(); |
105 } | 103 } |
106 | 104 |
107 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 105 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
108 | 106 |
109 typedef Gr1DKernelEffect INHERITED; | 107 typedef Gr1DKernelEffect INHERITED; |
110 }; | 108 }; |
111 | 109 |
112 #endif | 110 #endif |
OLD | NEW |