tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrConvolutionEffect.h" |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 9 | #include "glsl/GrGLSLFragmentProcessor.h" |
egdaniel | 2d721d3 | 2015-11-11 13:06:05 -0800 | [diff] [blame] | 10 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 11 | #include "glsl/GrGLSLProgramDataManager.h" |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame^] | 12 | #include "glsl/GrGLSLUniformHandler.h" |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 13 | |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 14 | // For brevity |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 15 | typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
bsalomon@google.com | 032b221 | 2012-07-16 13:36:18 +0000 | [diff] [blame] | 16 | |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 17 | class GrGLConvolutionEffect : public GrGLSLFragmentProcessor { |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 18 | public: |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 19 | GrGLConvolutionEffect(const GrProcessor&); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 20 | |
wangyix | 7c157a9 | 2015-07-22 15:08:53 -0700 | [diff] [blame] | 21 | virtual void emitCode(EmitArgs&) override; |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 22 | |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 23 | static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 24 | |
wangyix | b1daa86 | 2015-08-18 11:29:31 -0700 | [diff] [blame] | 25 | protected: |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 26 | void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&) override; |
wangyix | b1daa86 | 2015-08-18 11:29:31 -0700 | [diff] [blame] | 27 | |
ericrk | 0f38612 | 2015-07-21 13:15:47 -0700 | [diff] [blame] | 28 | private: |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 29 | int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); } |
| 30 | bool useBounds() const { return fUseBounds; } |
| 31 | Gr1DKernelEffect::Direction direction() const { return fDirection; } |
| 32 | |
| 33 | int fRadius; |
| 34 | bool fUseBounds; |
| 35 | Gr1DKernelEffect::Direction fDirection; |
| 36 | UniformHandle fKernelUni; |
| 37 | UniformHandle fImageIncrementUni; |
| 38 | UniformHandle fBoundsUni; |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 39 | |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 40 | typedef GrGLSLFragmentProcessor INHERITED; |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 43 | GrGLConvolutionEffect::GrGLConvolutionEffect(const GrProcessor& processor) { |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 44 | const GrConvolutionEffect& c = processor.cast<GrConvolutionEffect>(); |
bsalomon@google.com | b505a12 | 2012-05-31 18:40:36 +0000 | [diff] [blame] | 45 | fRadius = c.radius(); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 46 | fUseBounds = c.useBounds(); |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 47 | fDirection = c.direction(); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 48 | } |
| 49 | |
wangyix | 7c157a9 | 2015-07-22 15:08:53 -0700 | [diff] [blame] | 50 | void GrGLConvolutionEffect::emitCode(EmitArgs& args) { |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame^] | 51 | GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
| 52 | fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility, |
| 53 | kVec2f_GrSLType, kDefault_GrSLPrecision, |
| 54 | "ImageIncrement"); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 55 | if (this->useBounds()) { |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame^] | 56 | fBoundsUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility, |
| 57 | kVec2f_GrSLType, kDefault_GrSLPrecision, |
| 58 | "Bounds"); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 59 | } |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame^] | 60 | fKernelUni = uniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility, |
| 61 | kFloat_GrSLType, kDefault_GrSLPrecision, |
| 62 | "Kernel", this->width()); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 63 | |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 64 | GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 65 | SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 66 | |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 67 | fragBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", args.fOutputColor); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 68 | |
| 69 | int width = this->width(); |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame^] | 70 | const GrGLSLShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni); |
| 71 | const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 72 | |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 73 | fragBuilder->codeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(), fRadius, imgInc); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 74 | |
| 75 | // Manually unroll loop because some drivers don't; yields 20-30% speedup. |
| 76 | for (int i = 0; i < width; i++) { |
| 77 | SkString index; |
| 78 | SkString kernelIndex; |
| 79 | index.appendS32(i); |
| 80 | kernel.appendArrayAccess(index.c_str(), &kernelIndex); |
| 81 | |
| 82 | if (this->useBounds()) { |
| 83 | // We used to compute a bool indicating whether we're in bounds or not, cast it to a |
| 84 | // float, and then mul weight*texture_sample by the float. However, the Adreno 430 seems |
| 85 | // to have a bug that caused corruption. |
egdaniel | 7ea439b | 2015-12-03 09:20:44 -0800 | [diff] [blame^] | 86 | const char* bounds = uniformHandler->getUniformCStr(fBoundsUni); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 87 | const char* component = this->direction() == Gr1DKernelEffect::kY_Direction ? "y" : "x"; |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 88 | fragBuilder->codeAppendf("if (coord.%s >= %s.x && coord.%s <= %s.y) {", |
| 89 | component, bounds, component, bounds); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 90 | } |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 91 | fragBuilder->codeAppendf("\t\t%s += ", args.fOutputColor); |
| 92 | fragBuilder->appendTextureLookup(args.fSamplers[0], "coord"); |
| 93 | fragBuilder->codeAppendf(" * %s;\n", kernelIndex.c_str()); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 94 | if (this->useBounds()) { |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 95 | fragBuilder->codeAppend("}"); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 96 | } |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 97 | fragBuilder->codeAppendf("\t\tcoord += %s;\n", imgInc); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | SkString modulate; |
wangyix | 7c157a9 | 2015-07-22 15:08:53 -0700 | [diff] [blame] | 101 | GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor); |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 102 | fragBuilder->codeAppend(modulate.c_str()); |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 103 | } |
| 104 | |
egdaniel | 018fb62 | 2015-10-28 07:26:40 -0700 | [diff] [blame] | 105 | void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
| 106 | const GrProcessor& processor) { |
ericrk | 7a787b4 | 2015-07-21 14:06:16 -0700 | [diff] [blame] | 107 | const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>(); |
| 108 | GrTexture& texture = *conv.texture(0); |
| 109 | // the code we generated was for a specific kernel radius |
| 110 | SkASSERT(conv.radius() == fRadius); |
| 111 | float imageIncrement[2] = { 0 }; |
| 112 | float ySign = texture.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; |
| 113 | switch (conv.direction()) { |
| 114 | case Gr1DKernelEffect::kX_Direction: |
| 115 | imageIncrement[0] = 1.0f / texture.width(); |
| 116 | break; |
| 117 | case Gr1DKernelEffect::kY_Direction: |
| 118 | imageIncrement[1] = ySign / texture.height(); |
| 119 | break; |
| 120 | default: |
| 121 | SkFAIL("Unknown filter direction."); |
| 122 | } |
| 123 | pdman.set2fv(fImageIncrementUni, 1, imageIncrement); |
| 124 | if (conv.useBounds()) { |
| 125 | const float* bounds = conv.bounds(); |
| 126 | if (Gr1DKernelEffect::kY_Direction == conv.direction() && |
| 127 | texture.origin() != kTopLeft_GrSurfaceOrigin) { |
| 128 | pdman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]); |
| 129 | } else { |
| 130 | pdman.set2f(fBoundsUni, bounds[0], bounds[1]); |
| 131 | } |
| 132 | } |
| 133 | pdman.set1fv(fKernelUni, this->width(), conv.kernel()); |
| 134 | } |
| 135 | |
| 136 | void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&, |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 137 | GrProcessorKeyBuilder* b) { |
| 138 | const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>(); |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 139 | uint32_t key = conv.radius(); |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 140 | key <<= 2; |
| 141 | if (conv.useBounds()) { |
| 142 | key |= 0x2; |
| 143 | key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0; |
| 144 | } |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 145 | b->add32(key); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 146 | } |
| 147 | |
bsalomon@google.com | b505a12 | 2012-05-31 18:40:36 +0000 | [diff] [blame] | 148 | /////////////////////////////////////////////////////////////////////////////// |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 149 | |
bsalomon | 4a33952 | 2015-10-06 08:40:50 -0700 | [diff] [blame] | 150 | GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture, |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 151 | Direction direction, |
bsalomon@google.com | b505a12 | 2012-05-31 18:40:36 +0000 | [diff] [blame] | 152 | int radius, |
senorblanco@chromium.org | 194d775 | 2013-07-24 22:19:24 +0000 | [diff] [blame] | 153 | const float* kernel, |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 154 | bool useBounds, |
| 155 | float bounds[2]) |
bsalomon | 4a33952 | 2015-10-06 08:40:50 -0700 | [diff] [blame] | 156 | : INHERITED(texture, direction, radius), fUseBounds(useBounds) { |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 157 | this->initClassID<GrConvolutionEffect>(); |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 158 | SkASSERT(radius <= kMaxKernelRadius); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 159 | SkASSERT(kernel); |
bsalomon@google.com | b505a12 | 2012-05-31 18:40:36 +0000 | [diff] [blame] | 160 | int width = this->width(); |
bsalomon@google.com | b4a55b7 | 2012-11-02 20:45:37 +0000 | [diff] [blame] | 161 | for (int i = 0; i < width; i++) { |
| 162 | fKernel[i] = kernel[i]; |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 163 | } |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 164 | memcpy(fBounds, bounds, sizeof(fBounds)); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 165 | } |
| 166 | |
bsalomon | 4a33952 | 2015-10-06 08:40:50 -0700 | [diff] [blame] | 167 | GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture, |
tomhudson@google.com | fde2c0a | 2012-07-16 12:23:32 +0000 | [diff] [blame] | 168 | Direction direction, |
| 169 | int radius, |
senorblanco@chromium.org | 194d775 | 2013-07-24 22:19:24 +0000 | [diff] [blame] | 170 | float gaussianSigma, |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 171 | bool useBounds, |
| 172 | float bounds[2]) |
bsalomon | 4a33952 | 2015-10-06 08:40:50 -0700 | [diff] [blame] | 173 | : INHERITED(texture, direction, radius), fUseBounds(useBounds) { |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 174 | this->initClassID<GrConvolutionEffect>(); |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 175 | SkASSERT(radius <= kMaxKernelRadius); |
tomhudson@google.com | fde2c0a | 2012-07-16 12:23:32 +0000 | [diff] [blame] | 176 | int width = this->width(); |
| 177 | |
| 178 | float sum = 0.0f; |
| 179 | float denom = 1.0f / (2.0f * gaussianSigma * gaussianSigma); |
| 180 | for (int i = 0; i < width; ++i) { |
| 181 | float x = static_cast<float>(i - this->radius()); |
| 182 | // Note that the constant term (1/(sqrt(2*pi*sigma^2)) of the Gaussian |
| 183 | // is dropped here, since we renormalize the kernel below. |
| 184 | fKernel[i] = sk_float_exp(- x * x * denom); |
| 185 | sum += fKernel[i]; |
| 186 | } |
| 187 | // Normalize the kernel |
| 188 | float scale = 1.0f / sum; |
| 189 | for (int i = 0; i < width; ++i) { |
| 190 | fKernel[i] *= scale; |
| 191 | } |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 192 | memcpy(fBounds, bounds, sizeof(fBounds)); |
tomhudson@google.com | fde2c0a | 2012-07-16 12:23:32 +0000 | [diff] [blame] | 193 | } |
| 194 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 195 | GrConvolutionEffect::~GrConvolutionEffect() { |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 196 | } |
| 197 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 198 | void GrConvolutionEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| 199 | GrProcessorKeyBuilder* b) const { |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 200 | GrGLConvolutionEffect::GenKey(*this, caps, b); |
| 201 | } |
| 202 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 203 | GrGLSLFragmentProcessor* GrConvolutionEffect::onCreateGLSLInstance() const { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 204 | return new GrGLConvolutionEffect(*this); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 205 | } |
| 206 | |
bsalomon | 0e08fc1 | 2014-10-15 08:19:04 -0700 | [diff] [blame] | 207 | bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
joshualitt | 49586be | 2014-09-16 08:21:41 -0700 | [diff] [blame] | 208 | const GrConvolutionEffect& s = sBase.cast<GrConvolutionEffect>(); |
bsalomon | 420d7e9 | 2014-10-16 09:18:09 -0700 | [diff] [blame] | 209 | return (this->radius() == s.radius() && |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 210 | this->direction() == s.direction() && |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 211 | this->useBounds() == s.useBounds() && |
| 212 | 0 == memcmp(fBounds, s.fBounds, sizeof(fBounds)) && |
tomhudson@google.com | d0c1a06 | 2012-07-12 17:23:52 +0000 | [diff] [blame] | 213 | 0 == memcmp(fKernel, s.fKernel, this->width() * sizeof(float))); |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 214 | } |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 215 | |
| 216 | /////////////////////////////////////////////////////////////////////////////// |
| 217 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 218 | GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvolutionEffect); |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 219 | |
bsalomon | c21b09e | 2015-08-28 18:46:56 -0700 | [diff] [blame] | 220 | const GrFragmentProcessor* GrConvolutionEffect::TestCreate(GrProcessorTestData* d) { |
joshualitt | 0067ff5 | 2015-07-08 14:26:19 -0700 | [diff] [blame] | 221 | int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : |
| 222 | GrProcessorUnitTest::kAlphaTextureIdx; |
| 223 | Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction; |
| 224 | int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius); |
bungeman@google.com | 4348663 | 2013-08-20 15:20:34 +0000 | [diff] [blame] | 225 | float kernel[kMaxKernelWidth]; |
| 226 | for (size_t i = 0; i < SK_ARRAY_COUNT(kernel); ++i) { |
joshualitt | 0067ff5 | 2015-07-08 14:26:19 -0700 | [diff] [blame] | 227 | kernel[i] = d->fRandom->nextSScalar1(); |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 228 | } |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 229 | float bounds[2]; |
bungeman@google.com | 4348663 | 2013-08-20 15:20:34 +0000 | [diff] [blame] | 230 | for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) { |
joshualitt | 0067ff5 | 2015-07-08 14:26:19 -0700 | [diff] [blame] | 231 | bounds[i] = d->fRandom->nextF(); |
senorblanco@chromium.org | 194d775 | 2013-07-24 22:19:24 +0000 | [diff] [blame] | 232 | } |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 233 | |
joshualitt | 0067ff5 | 2015-07-08 14:26:19 -0700 | [diff] [blame] | 234 | bool useBounds = d->fRandom->nextBool(); |
bsalomon | 4a33952 | 2015-10-06 08:40:50 -0700 | [diff] [blame] | 235 | return GrConvolutionEffect::Create(d->fTextures[texIdx], |
senorblanco@chromium.org | 194d775 | 2013-07-24 22:19:24 +0000 | [diff] [blame] | 236 | dir, |
| 237 | radius, |
| 238 | kernel, |
senorblanco@chromium.org | e8232bc | 2013-07-29 18:45:44 +0000 | [diff] [blame] | 239 | useBounds, |
| 240 | bounds); |
bsalomon@google.com | 0a7672f | 2012-08-03 18:12:20 +0000 | [diff] [blame] | 241 | } |