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 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; | |
67 | |
68 GrGLFragmentProcessor* createGLInstance() const override; | 66 GrGLFragmentProcessor* createGLInstance() const override; |
69 | 67 |
70 enum { | 68 enum { |
71 // This was decided based on the min allowed value for the max texture | 69 // This was decided based on the min allowed value for the max texture |
72 // samples per fragment program run in DX9SM2 (32). A sigma param of 4.0 | 70 // samples per fragment program run in DX9SM2 (32). A sigma param of 4.0 |
73 // on a blur filter gives a kernel width of 25 while a sigma of 5.0 | 71 // on a blur filter gives a kernel width of 25 while a sigma of 5.0 |
74 // would exceed a 32 wide kernel. | 72 // would exceed a 32 wide kernel. |
75 kMaxKernelRadius = 12, | 73 kMaxKernelRadius = 12, |
76 // With a C++11 we could have a constexpr version of WidthFromRadius() | 74 // With a C++11 we could have a constexpr version of WidthFromRadius() |
77 // and not have to duplicate this calculation. | 75 // and not have to duplicate this calculation. |
(...skipping 15 matching lines...) Expand all Loading... |
93 float bounds[2]); | 91 float bounds[2]); |
94 | 92 |
95 /// Convolve with a Gaussian kernel | 93 /// Convolve with a Gaussian kernel |
96 GrConvolutionEffect(GrProcessorDataManager*, | 94 GrConvolutionEffect(GrProcessorDataManager*, |
97 GrTexture*, Direction, | 95 GrTexture*, Direction, |
98 int halfWidth, | 96 int halfWidth, |
99 float gaussianSigma, | 97 float gaussianSigma, |
100 bool useBounds, | 98 bool useBounds, |
101 float bounds[2]); | 99 float bounds[2]); |
102 | 100 |
| 101 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; |
| 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 |