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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 const float* bounds() const { return fBounds; } | 58 const float* bounds() const { return fBounds; } |
59 bool useBounds() const { return fUseBounds; } | 59 bool useBounds() const { return fUseBounds; } |
60 | 60 |
61 static const char* Name() { return "Convolution"; } | 61 static const char* Name() { return "Convolution"; } |
62 | 62 |
63 typedef GrGLConvolutionEffect GLProcessor; | 63 typedef GrGLConvolutionEffect GLProcessor; |
64 | 64 |
65 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 65 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
66 | 66 |
67 virtual void getConstantColorComponents(GrColor*, uint32_t* validFlags) cons
t { | |
68 // If the texture was opaque we could know that the output color if we k
new the sum of the | |
69 // kernel values. | |
70 *validFlags = 0; | |
71 } | |
72 | |
73 enum { | 67 enum { |
74 // This was decided based on the min allowed value for the max texture | 68 // This was decided based on the min allowed value for the max texture |
75 // samples per fragment program run in DX9SM2 (32). A sigma param of 4.0 | 69 // samples per fragment program run in DX9SM2 (32). A sigma param of 4.0 |
76 // on a blur filter gives a kernel width of 25 while a sigma of 5.0 | 70 // on a blur filter gives a kernel width of 25 while a sigma of 5.0 |
77 // would exceed a 32 wide kernel. | 71 // would exceed a 32 wide kernel. |
78 kMaxKernelRadius = 12, | 72 kMaxKernelRadius = 12, |
79 // With a C++11 we could have a constexpr version of WidthFromRadius() | 73 // With a C++11 we could have a constexpr version of WidthFromRadius() |
80 // and not have to duplicate this calculation. | 74 // and not have to duplicate this calculation. |
81 kMaxKernelWidth = 2 * kMaxKernelRadius + 1, | 75 kMaxKernelWidth = 2 * kMaxKernelRadius + 1, |
82 }; | 76 }; |
(...skipping 13 matching lines...) Expand all Loading... |
96 | 90 |
97 /// Convolve with a Gaussian kernel | 91 /// Convolve with a Gaussian kernel |
98 GrConvolutionEffect(GrTexture*, Direction, | 92 GrConvolutionEffect(GrTexture*, Direction, |
99 int halfWidth, | 93 int halfWidth, |
100 float gaussianSigma, | 94 float gaussianSigma, |
101 bool useBounds, | 95 bool useBounds, |
102 float bounds[2]); | 96 float bounds[2]); |
103 | 97 |
104 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 98 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
105 | 99 |
| 100 virtual void onComputeInvariantOutput(InvariantOutput* inout) const { |
| 101 // If the texture was opaque we could know that the output color if we k
new the sum of the |
| 102 // kernel values. |
| 103 inout->fValidFlags = 0; |
| 104 inout->fIsSingleComponent = false; |
| 105 } |
| 106 |
106 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 107 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
107 | 108 |
108 typedef Gr1DKernelEffect INHERITED; | 109 typedef Gr1DKernelEffect INHERITED; |
109 }; | 110 }; |
110 | 111 |
111 #endif | 112 #endif |
OLD | NEW |