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 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 virtual ~GrConvolutionEffect(); | 57 virtual ~GrConvolutionEffect(); |
58 | 58 |
59 const float* kernel() const { return fKernel; } | 59 const float* kernel() const { return fKernel; } |
60 | 60 |
61 const float* bounds() const { return fBounds; } | 61 const float* bounds() const { return fBounds; } |
62 bool useBounds() const { return fUseBounds; } | 62 bool useBounds() const { return fUseBounds; } |
63 | 63 |
64 const char* name() const override { return "Convolution"; } | 64 const char* name() const override { return "Convolution"; } |
65 | 65 |
66 GrGLFragmentProcessor* createGLInstance() const override; | |
67 | |
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, |
77 }; | 75 }; |
(...skipping 13 matching lines...) Expand all Loading... |
91 float bounds[2]); | 89 float bounds[2]); |
92 | 90 |
93 /// Convolve with a Gaussian kernel | 91 /// Convolve with a Gaussian kernel |
94 GrConvolutionEffect(GrProcessorDataManager*, | 92 GrConvolutionEffect(GrProcessorDataManager*, |
95 GrTexture*, Direction, | 93 GrTexture*, Direction, |
96 int halfWidth, | 94 int halfWidth, |
97 float gaussianSigma, | 95 float gaussianSigma, |
98 bool useBounds, | 96 bool useBounds, |
99 float bounds[2]); | 97 float bounds[2]); |
100 | 98 |
| 99 GrGLFragmentProcessor* onCreateGLInstance() const override; |
| 100 |
101 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; | 101 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; |
102 | 102 |
103 bool onIsEqual(const GrFragmentProcessor&) const override; | 103 bool onIsEqual(const GrFragmentProcessor&) const override; |
104 | 104 |
105 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 105 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
106 // If the texture was opaque we could know that the output color if we k
new the sum of the | 106 // If the texture was opaque we could know that the output color if we k
new the sum of the |
107 // kernel values. | 107 // kernel values. |
108 inout->mulByUnknownFourComponents(); | 108 inout->mulByUnknownFourComponents(); |
109 } | 109 } |
110 | 110 |
111 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 111 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
112 | 112 |
113 typedef Gr1DKernelEffect INHERITED; | 113 typedef Gr1DKernelEffect INHERITED; |
114 }; | 114 }; |
115 | 115 |
116 #endif | 116 #endif |
OLD | NEW |