| 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/GrGLFragmentProcessor.h" | 8 #include "gl/GrGLFragmentProcessor.h" |
| 9 #include "gl/GrGLTexture.h" | 9 #include "gl/GrGLTexture.h" |
| 10 #include "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 float scale = 1.0f / sum; | 215 float scale = 1.0f / sum; |
| 216 for (int i = 0; i < width * height; ++i) { | 216 for (int i = 0; i < width * height; ++i) { |
| 217 kernel[i] *= scale; | 217 kernel[i] *= scale; |
| 218 } | 218 } |
| 219 return new GrMatrixConvolutionEffect(procDataManager, texture, bounds, kerne
lSize, kernel, gain, | 219 return new GrMatrixConvolutionEffect(procDataManager, texture, bounds, kerne
lSize, kernel, gain, |
| 220 bias, kernelOffset, tileMode, convolveA
lpha); | 220 bias, kernelOffset, tileMode, convolveA
lpha); |
| 221 } | 221 } |
| 222 | 222 |
| 223 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect); | 223 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect); |
| 224 | 224 |
| 225 const GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTest
Data* d) { | 225 GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData*
d) { |
| 226 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: | 226 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
| 227 GrProcessorUnitTest::kAlphaTextureIdx; | 227 GrProcessorUnitTest::kAlphaTextureIdx; |
| 228 int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE); | 228 int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE); |
| 229 int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width); | 229 int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width); |
| 230 SkISize kernelSize = SkISize::Make(width, height); | 230 SkISize kernelSize = SkISize::Make(width, height); |
| 231 SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]); | 231 SkAutoTDeleteArray<SkScalar> kernel(new SkScalar[width * height]); |
| 232 for (int i = 0; i < width * height; i++) { | 232 for (int i = 0; i < width * height; i++) { |
| 233 kernel.get()[i] = d->fRandom->nextSScalar1(); | 233 kernel.get()[i] = d->fRandom->nextSScalar1(); |
| 234 } | 234 } |
| 235 SkScalar gain = d->fRandom->nextSScalar1(); | 235 SkScalar gain = d->fRandom->nextSScalar1(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 247 d->fTextures[texIdx], | 247 d->fTextures[texIdx], |
| 248 bounds, | 248 bounds, |
| 249 kernelSize, | 249 kernelSize, |
| 250 kernel.get(), | 250 kernel.get(), |
| 251 gain, | 251 gain, |
| 252 bias, | 252 bias, |
| 253 kernelOffset, | 253 kernelOffset, |
| 254 tileMode, | 254 tileMode, |
| 255 convolveAlpha); | 255 convolveAlpha); |
| 256 } | 256 } |
| OLD | NEW |