OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "GrMatrixConvolutionEffect.h" | 7 #include "GrMatrixConvolutionEffect.h" |
8 #include "gl/GrGLProcessor.h" | 8 #include "gl/GrGLProcessor.h" |
9 #include "gl/GrGLTexture.h" | 9 #include "gl/GrGLTexture.h" |
10 #include "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 kernel, | 229 kernel, |
230 gain, | 230 gain, |
231 bias, | 231 bias, |
232 kernelOffset, | 232 kernelOffset, |
233 tileMode, | 233 tileMode, |
234 convolveAlpha)); | 234 convolveAlpha)); |
235 } | 235 } |
236 | 236 |
237 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect); | 237 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect); |
238 | 238 |
239 GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(SkRandom* random, | 239 GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData*
d) { |
240 GrContext* context, | 240 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
241 const GrCaps&, | 241 GrProcessorUnitTest::kAlphaTextureIdx; |
242 GrTexture* textures[]
) { | 242 int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE); |
243 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : | 243 int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width); |
244 GrProcessorUnitTest::kAlphaTextureIdx; | |
245 int width = random->nextRangeU(1, MAX_KERNEL_SIZE); | |
246 int height = random->nextRangeU(1, MAX_KERNEL_SIZE / width); | |
247 SkISize kernelSize = SkISize::Make(width, height); | 244 SkISize kernelSize = SkISize::Make(width, height); |
248 SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]); | 245 SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]); |
249 for (int i = 0; i < width * height; i++) { | 246 for (int i = 0; i < width * height; i++) { |
250 kernel.get()[i] = random->nextSScalar1(); | 247 kernel.get()[i] = d->fRandom->nextSScalar1(); |
251 } | 248 } |
252 SkScalar gain = random->nextSScalar1(); | 249 SkScalar gain = d->fRandom->nextSScalar1(); |
253 SkScalar bias = random->nextSScalar1(); | 250 SkScalar bias = d->fRandom->nextSScalar1(); |
254 SkIPoint kernelOffset = SkIPoint::Make(random->nextRangeU(0, kernelSize.widt
h()), | 251 SkIPoint kernelOffset = SkIPoint::Make(d->fRandom->nextRangeU(0, kernelSize.
width()), |
255 random->nextRangeU(0, kernelSize.heig
ht())); | 252 d->fRandom->nextRangeU(0, kernelSize.
height())); |
256 SkIRect bounds = SkIRect::MakeXYWH(random->nextRangeU(0, textures[texIdx]->w
idth()), | 253 SkIRect bounds = SkIRect::MakeXYWH(d->fRandom->nextRangeU(0, d->fTextures[te
xIdx]->width()), |
257 random->nextRangeU(0, textures[texIdx]->h
eight()), | 254 d->fRandom->nextRangeU(0, d->fTextures[te
xIdx]->height()), |
258 random->nextRangeU(0, textures[texIdx]->w
idth()), | 255 d->fRandom->nextRangeU(0, d->fTextures[te
xIdx]->width()), |
259 random->nextRangeU(0, textures[texIdx]->h
eight())); | 256 d->fRandom->nextRangeU(0, d->fTextures[te
xIdx]->height())); |
260 GrTextureDomain::Mode tileMode = static_cast<GrTextureDomain::Mode>(random->
nextRangeU(0, 2)); | 257 GrTextureDomain::Mode tileMode = |
261 bool convolveAlpha = random->nextBool(); | 258 static_cast<GrTextureDomain::Mode>(d->fRandom->nextRangeU(0, 2)); |
262 return GrMatrixConvolutionEffect::Create(textures[texIdx], | 259 bool convolveAlpha = d->fRandom->nextBool(); |
| 260 return GrMatrixConvolutionEffect::Create(d->fTextures[texIdx], |
263 bounds, | 261 bounds, |
264 kernelSize, | 262 kernelSize, |
265 kernel.get(), | 263 kernel.get(), |
266 gain, | 264 gain, |
267 bias, | 265 bias, |
268 kernelOffset, | 266 kernelOffset, |
269 tileMode, | 267 tileMode, |
270 convolveAlpha); | 268 convolveAlpha); |
271 } | 269 } |
OLD | NEW |