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 "gl/GrGLEffect.h" | 9 #include "gl/GrGLEffect.h" |
10 #include "gl/GrGLEffectMatrix.h" | 10 #include "gl/GrGLEffectMatrix.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 this->direction() == s.direction() && | 212 this->direction() == s.direction() && |
213 this->useBounds() == s.useBounds() && | 213 this->useBounds() == s.useBounds() && |
214 0 == memcmp(fBounds, s.fBounds, sizeof(fBounds)) && | 214 0 == memcmp(fBounds, s.fBounds, sizeof(fBounds)) && |
215 0 == memcmp(fKernel, s.fKernel, this->width() * sizeof(float))); | 215 0 == memcmp(fKernel, s.fKernel, this->width() * sizeof(float))); |
216 } | 216 } |
217 | 217 |
218 /////////////////////////////////////////////////////////////////////////////// | 218 /////////////////////////////////////////////////////////////////////////////// |
219 | 219 |
220 GR_DEFINE_EFFECT_TEST(GrConvolutionEffect); | 220 GR_DEFINE_EFFECT_TEST(GrConvolutionEffect); |
221 | 221 |
222 GrEffectRef* GrConvolutionEffect::TestCreate(SkMWCRandom* random, | 222 GrEffectRef* GrConvolutionEffect::TestCreate(SkRandom* random, |
223 GrContext*, | 223 GrContext*, |
224 const GrDrawTargetCaps&, | 224 const GrDrawTargetCaps&, |
225 GrTexture* textures[]) { | 225 GrTexture* textures[]) { |
226 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 226 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
227 GrEffectUnitTest::kAlphaTextureIdx; | 227 GrEffectUnitTest::kAlphaTextureIdx; |
228 Direction dir = random->nextBool() ? kX_Direction : kY_Direction; | 228 Direction dir = random->nextBool() ? kX_Direction : kY_Direction; |
229 int radius = random->nextRangeU(1, kMaxKernelRadius); | 229 int radius = random->nextRangeU(1, kMaxKernelRadius); |
230 float kernel[kMaxKernelWidth]; | 230 float kernel[kMaxKernelWidth]; |
231 for (size_t i = 0; i < SK_ARRAY_COUNT(kernel); ++i) { | 231 for (size_t i = 0; i < SK_ARRAY_COUNT(kernel); ++i) { |
232 kernel[i] = random->nextSScalar1(); | 232 kernel[i] = random->nextSScalar1(); |
233 } | 233 } |
234 float bounds[2]; | 234 float bounds[2]; |
235 for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) { | 235 for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) { |
236 bounds[i] = random->nextF(); | 236 bounds[i] = random->nextF(); |
237 } | 237 } |
238 | 238 |
239 bool useBounds = random->nextBool(); | 239 bool useBounds = random->nextBool(); |
240 return GrConvolutionEffect::Create(textures[texIdx], | 240 return GrConvolutionEffect::Create(textures[texIdx], |
241 dir, | 241 dir, |
242 radius, | 242 radius, |
243 kernel, | 243 kernel, |
244 useBounds, | 244 useBounds, |
245 bounds); | 245 bounds); |
246 } | 246 } |
OLD | NEW |