| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  155  |  155  | 
|  156 GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() { |  156 GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() { | 
|  157 } |  157 } | 
|  158  |  158  | 
|  159 void GrMatrixConvolutionEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |  159 void GrMatrixConvolutionEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 
|  160                                                   GrProcessorKeyBuilder* b) cons
     t { |  160                                                   GrProcessorKeyBuilder* b) cons
     t { | 
|  161     GrGLMatrixConvolutionEffect::GenKey(*this, caps, b); |  161     GrGLMatrixConvolutionEffect::GenKey(*this, caps, b); | 
|  162 } |  162 } | 
|  163  |  163  | 
|  164 GrGLFragmentProcessor* GrMatrixConvolutionEffect::onCreateGLInstance() const  { |  164 GrGLFragmentProcessor* GrMatrixConvolutionEffect::onCreateGLInstance() const  { | 
|  165     return SkNEW_ARGS(GrGLMatrixConvolutionEffect, (*this)); |  165     return new GrGLMatrixConvolutionEffect(*this); | 
|  166 } |  166 } | 
|  167  |  167  | 
|  168 bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) cons
     t { |  168 bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) cons
     t { | 
|  169     const GrMatrixConvolutionEffect& s = sBase.cast<GrMatrixConvolutionEffect>()
     ; |  169     const GrMatrixConvolutionEffect& s = sBase.cast<GrMatrixConvolutionEffect>()
     ; | 
|  170     return fKernelSize == s.kernelSize() && |  170     return fKernelSize == s.kernelSize() && | 
|  171            !memcmp(fKernel, s.kernel(), |  171            !memcmp(fKernel, s.kernel(), | 
|  172                    fKernelSize.width() * fKernelSize.height() * sizeof(float)) &
     & |  172                    fKernelSize.width() * fKernelSize.height() * sizeof(float)) &
     & | 
|  173            fGain == s.gain() && |  173            fGain == s.gain() && | 
|  174            fBias == s.bias() && |  174            fBias == s.bias() && | 
|  175            fKernelOffset == s.kernelOffset() && |  175            fKernelOffset == s.kernelOffset() && | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  209        // is dropped here, since we renormalize the kernel below. |  209        // is dropped here, since we renormalize the kernel below. | 
|  210         kernel[y * width + x] = xyTerm; |  210         kernel[y * width + x] = xyTerm; | 
|  211         sum += xyTerm; |  211         sum += xyTerm; | 
|  212       } |  212       } | 
|  213     } |  213     } | 
|  214     // Normalize the kernel |  214     // Normalize the kernel | 
|  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 SkNEW_ARGS(GrMatrixConvolutionEffect, (procDataManager, |  219     return new GrMatrixConvolutionEffect(procDataManager, texture, bounds, kerne
     lSize, kernel, gain, | 
|  220                                                   texture, |  220                                          bias, kernelOffset, tileMode, convolveA
     lpha); | 
|  221                                                   bounds, |  | 
|  222                                                   kernelSize, |  | 
|  223                                                   kernel, |  | 
|  224                                                   gain, |  | 
|  225                                                   bias, |  | 
|  226                                                   kernelOffset, |  | 
|  227                                                   tileMode, |  | 
|  228                                                   convolveAlpha)); |  | 
|  229 } |  221 } | 
|  230  |  222  | 
|  231 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect); |  223 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect); | 
|  232  |  224  | 
|  233 GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* 
     d) { |  225 GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(GrProcessorTestData* 
     d) { | 
|  234     int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
      : |  226     int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
      : | 
|  235                                           GrProcessorUnitTest::kAlphaTextureIdx; |  227                                           GrProcessorUnitTest::kAlphaTextureIdx; | 
|  236     int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE); |  228     int width = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE); | 
|  237     int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width); |  229     int height = d->fRandom->nextRangeU(1, MAX_KERNEL_SIZE / width); | 
|  238     SkISize kernelSize = SkISize::Make(width, height); |  230     SkISize kernelSize = SkISize::Make(width, height); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
|  255                                              d->fTextures[texIdx], |  247                                              d->fTextures[texIdx], | 
|  256                                              bounds, |  248                                              bounds, | 
|  257                                              kernelSize, |  249                                              kernelSize, | 
|  258                                              kernel.get(), |  250                                              kernel.get(), | 
|  259                                              gain, |  251                                              gain, | 
|  260                                              bias, |  252                                              bias, | 
|  261                                              kernelOffset, |  253                                              kernelOffset, | 
|  262                                              tileMode, |  254                                              tileMode, | 
|  263                                              convolveAlpha); |  255                                              convolveAlpha); | 
|  264 } |  256 } | 
| OLD | NEW |