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 #include "GrConvolutionEffect.h" | 8 #include "GrConvolutionEffect.h" |
9 #include "glsl/GrGLSLFragmentProcessor.h" | 9 #include "glsl/GrGLSLFragmentProcessor.h" |
10 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 10 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 float scale = 1.0f / sum; | 187 float scale = 1.0f / sum; |
188 for (int i = 0; i < width; ++i) { | 188 for (int i = 0; i < width; ++i) { |
189 fKernel[i] *= scale; | 189 fKernel[i] *= scale; |
190 } | 190 } |
191 memcpy(fBounds, bounds, sizeof(fBounds)); | 191 memcpy(fBounds, bounds, sizeof(fBounds)); |
192 } | 192 } |
193 | 193 |
194 GrConvolutionEffect::~GrConvolutionEffect() { | 194 GrConvolutionEffect::~GrConvolutionEffect() { |
195 } | 195 } |
196 | 196 |
197 void GrConvolutionEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 197 void GrConvolutionEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
198 GrProcessorKeyBuilder* b) const { | 198 GrProcessorKeyBuilder* b) const
{ |
199 GrGLConvolutionEffect::GenKey(*this, caps, b); | 199 GrGLConvolutionEffect::GenKey(*this, caps, b); |
200 } | 200 } |
201 | 201 |
202 GrGLSLFragmentProcessor* GrConvolutionEffect::onCreateGLInstance() const { | 202 GrGLSLFragmentProcessor* GrConvolutionEffect::onCreateGLSLInstance() const { |
203 return new GrGLConvolutionEffect(*this); | 203 return new GrGLConvolutionEffect(*this); |
204 } | 204 } |
205 | 205 |
206 bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 206 bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
207 const GrConvolutionEffect& s = sBase.cast<GrConvolutionEffect>(); | 207 const GrConvolutionEffect& s = sBase.cast<GrConvolutionEffect>(); |
208 return (this->radius() == s.radius() && | 208 return (this->radius() == s.radius() && |
209 this->direction() == s.direction() && | 209 this->direction() == s.direction() && |
210 this->useBounds() == s.useBounds() && | 210 this->useBounds() == s.useBounds() && |
211 0 == memcmp(fBounds, s.fBounds, sizeof(fBounds)) && | 211 0 == memcmp(fBounds, s.fBounds, sizeof(fBounds)) && |
212 0 == memcmp(fKernel, s.fKernel, this->width() * sizeof(float))); | 212 0 == memcmp(fKernel, s.fKernel, this->width() * sizeof(float))); |
(...skipping 18 matching lines...) Expand all Loading... |
231 } | 231 } |
232 | 232 |
233 bool useBounds = d->fRandom->nextBool(); | 233 bool useBounds = d->fRandom->nextBool(); |
234 return GrConvolutionEffect::Create(d->fTextures[texIdx], | 234 return GrConvolutionEffect::Create(d->fTextures[texIdx], |
235 dir, | 235 dir, |
236 radius, | 236 radius, |
237 kernel, | 237 kernel, |
238 useBounds, | 238 useBounds, |
239 bounds); | 239 bounds); |
240 } | 240 } |
OLD | NEW |