| 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/GrGLProcessor.h" | 9 #include "gl/GrGLProcessor.h" |
| 10 #include "gl/GrGLSL.h" | 10 #include "gl/GrGLSL.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 fDirection = c.direction(); | 51 fDirection = c.direction(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void GrGLConvolutionEffect::emitCode(GrGLFPBuilder* builder, | 54 void GrGLConvolutionEffect::emitCode(GrGLFPBuilder* builder, |
| 55 const GrFragmentProcessor&, | 55 const GrFragmentProcessor&, |
| 56 const char* outputColor, | 56 const char* outputColor, |
| 57 const char* inputColor, | 57 const char* inputColor, |
| 58 const TransformedCoordsArray& coords, | 58 const TransformedCoordsArray& coords, |
| 59 const TextureSamplerArray& samplers) { | 59 const TextureSamplerArray& samplers) { |
| 60 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, | 60 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, |
| 61 kVec2f_GrSLType, "ImageIncrement"); | 61 kVec2f_GrSLType, kDefault_GrSLPreci
sion, |
| 62 "ImageIncrement"); |
| 62 if (this->useBounds()) { | 63 if (this->useBounds()) { |
| 63 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit
y, | 64 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit
y, |
| 64 kVec2f_GrSLType, "Bounds"); | 65 kVec2f_GrSLType, kDefault_GrSLPrecision
, |
| 66 "Bounds"); |
| 65 } | 67 } |
| 66 fKernelUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibili
ty, | 68 fKernelUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibili
ty, |
| 67 kFloat_GrSLType, "Kernel", this->width
()); | 69 kFloat_GrSLType, kDefault_GrSLPrecisio
n, |
| 70 "Kernel", this->width()); |
| 68 | 71 |
| 69 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 72 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| 70 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); | 73 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); |
| 71 | 74 |
| 72 fsBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); | 75 fsBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); |
| 73 | 76 |
| 74 int width = this->width(); | 77 int width = this->width(); |
| 75 const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni); | 78 const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni); |
| 76 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); | 79 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); |
| 77 | 80 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 236 } |
| 234 | 237 |
| 235 bool useBounds = random->nextBool(); | 238 bool useBounds = random->nextBool(); |
| 236 return GrConvolutionEffect::Create(textures[texIdx], | 239 return GrConvolutionEffect::Create(textures[texIdx], |
| 237 dir, | 240 dir, |
| 238 radius, | 241 radius, |
| 239 kernel, | 242 kernel, |
| 240 useBounds, | 243 useBounds, |
| 241 bounds); | 244 bounds); |
| 242 } | 245 } |
| OLD | NEW |