| 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 24 matching lines...) Expand all Loading... |
| 35 static sk_sp<GrFragmentProcessor> MakeGaussian(GrTexture* tex, | 35 static sk_sp<GrFragmentProcessor> MakeGaussian(GrTexture* tex, |
| 36 Direction dir, | 36 Direction dir, |
| 37 int halfWidth, | 37 int halfWidth, |
| 38 float gaussianSigma, | 38 float gaussianSigma, |
| 39 bool useBounds, | 39 bool useBounds, |
| 40 float bounds[2]) { | 40 float bounds[2]) { |
| 41 return sk_sp<GrFragmentProcessor>( | 41 return sk_sp<GrFragmentProcessor>( |
| 42 new GrConvolutionEffect(tex, dir, halfWidth, gaussianSigma, useBound
s, bounds)); | 42 new GrConvolutionEffect(tex, dir, halfWidth, gaussianSigma, useBound
s, bounds)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 /// Convolve with an arbitrary user-specified kernel |
| 46 static sk_sp<GrFragmentProcessor> Make(GrTextureProxy* tex, |
| 47 Direction dir, |
| 48 int halfWidth, |
| 49 const float* kernel, |
| 50 bool useBounds, |
| 51 float bounds[2]) { |
| 52 return sk_sp<GrFragmentProcessor>( |
| 53 new GrConvolutionEffect(tex, dir, halfWidth, kernel, useBounds, boun
ds)); |
| 54 } |
| 55 |
| 56 /// Convolve with a Gaussian kernel |
| 57 static sk_sp<GrFragmentProcessor> MakeGaussian(GrTextureProxy* tex, |
| 58 Direction dir, |
| 59 int halfWidth, |
| 60 float gaussianSigma, |
| 61 bool useBounds, |
| 62 float bounds[2]) { |
| 63 return sk_sp<GrFragmentProcessor>( |
| 64 new GrConvolutionEffect(tex, dir, halfWidth, gaussianSigma, useBound
s, bounds)); |
| 65 } |
| 66 |
| 45 virtual ~GrConvolutionEffect(); | 67 virtual ~GrConvolutionEffect(); |
| 46 | 68 |
| 47 const float* kernel() const { return fKernel; } | 69 const float* kernel() const { return fKernel; } |
| 48 | 70 |
| 49 const float* bounds() const { return fBounds; } | 71 const float* bounds() const { return fBounds; } |
| 50 bool useBounds() const { return fUseBounds; } | 72 bool useBounds() const { return fUseBounds; } |
| 51 | 73 |
| 52 const char* name() const override { return "Convolution"; } | 74 const char* name() const override { return "Convolution"; } |
| 53 | 75 |
| 54 enum { | 76 enum { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 bool useBounds, | 97 bool useBounds, |
| 76 float bounds[2]); | 98 float bounds[2]); |
| 77 | 99 |
| 78 /// Convolve with a Gaussian kernel | 100 /// Convolve with a Gaussian kernel |
| 79 GrConvolutionEffect(GrTexture*, Direction, | 101 GrConvolutionEffect(GrTexture*, Direction, |
| 80 int halfWidth, | 102 int halfWidth, |
| 81 float gaussianSigma, | 103 float gaussianSigma, |
| 82 bool useBounds, | 104 bool useBounds, |
| 83 float bounds[2]); | 105 float bounds[2]); |
| 84 | 106 |
| 107 GrConvolutionEffect(GrTextureProxy*, Direction, |
| 108 int halfWidth, |
| 109 const float* kernel, |
| 110 bool useBounds, |
| 111 float bounds[2]); |
| 112 |
| 113 /// Convolve with a Gaussian kernel |
| 114 GrConvolutionEffect(GrTextureProxy*, Direction, |
| 115 int halfWidth, |
| 116 float gaussianSigma, |
| 117 bool useBounds, |
| 118 float bounds[2]); |
| 119 |
| 85 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 120 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
| 86 | 121 |
| 87 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; | 122 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; |
| 88 | 123 |
| 89 bool onIsEqual(const GrFragmentProcessor&) const override; | 124 bool onIsEqual(const GrFragmentProcessor&) const override; |
| 90 | 125 |
| 91 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 126 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 92 // If the texture was opaque we could know that the output color if we k
new the sum of the | 127 // If the texture was opaque we could know that the output color if we k
new the sum of the |
| 93 // kernel values. | 128 // kernel values. |
| 94 inout->mulByUnknownFourComponents(); | 129 inout->mulByUnknownFourComponents(); |
| 95 } | 130 } |
| 96 | 131 |
| 97 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 132 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 98 | 133 |
| 99 typedef Gr1DKernelEffect INHERITED; | 134 typedef Gr1DKernelEffect INHERITED; |
| 100 }; | 135 }; |
| 101 | 136 |
| 102 #endif | 137 #endif |
| OLD | NEW |