| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 kVec2f_GrSLType, kDefault_GrSLPr
ecision, | 43 kVec2f_GrSLType, kDefault_GrSLPr
ecision, |
| 44 "Bounds"); | 44 "Bounds"); |
| 45 } | 45 } |
| 46 | 46 |
| 47 int width = Gr1DKernelEffect::WidthFromRadius(ce.radius()); | 47 int width = Gr1DKernelEffect::WidthFromRadius(ce.radius()); |
| 48 | 48 |
| 49 fKernelUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag, | 49 fKernelUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag, |
| 50 kFloat_GrSLType, kDefault_GrSLP
recision, | 50 kFloat_GrSLType, kDefault_GrSLP
recision, |
| 51 "Kernel", width); | 51 "Kernel", width); |
| 52 | 52 |
| 53 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 53 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 54 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); | 54 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
| 55 | 55 |
| 56 fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor); | 56 fragBuilder->codeAppendf("%s = vec4(0, 0, 0, 0);", args.fOutputColor); |
| 57 | 57 |
| 58 const GrGLSLShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUn
i); | 58 const GrGLSLShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUn
i); |
| 59 const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni); | 59 const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni); |
| 60 | 60 |
| 61 fragBuilder->codeAppendf("vec2 coord = %s - %d.0 * %s;", coords2D.c_str(), c
e.radius(), imgInc); | 61 fragBuilder->codeAppendf("vec2 coord = %s - %d.0 * %s;", coords2D.c_str(), c
e.radius(), imgInc); |
| 62 | 62 |
| 63 // Manually unroll loop because some drivers don't; yields 20-30% speedup. | 63 // Manually unroll loop because some drivers don't; yields 20-30% speedup. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 bool useBounds = d->fRandom->nextBool(); | 223 bool useBounds = d->fRandom->nextBool(); |
| 224 return GrConvolutionEffect::Create(d->fTextures[texIdx], | 224 return GrConvolutionEffect::Create(d->fTextures[texIdx], |
| 225 dir, | 225 dir, |
| 226 radius, | 226 radius, |
| 227 kernel, | 227 kernel, |
| 228 useBounds, | 228 useBounds, |
| 229 bounds); | 229 bounds); |
| 230 } | 230 } |
| OLD | NEW |