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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 "ImageIncrement"); | 62 "ImageIncrement"); |
63 if (this->useBounds()) { | 63 if (this->useBounds()) { |
64 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit
y, | 64 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibilit
y, |
65 kVec2f_GrSLType, kDefault_GrSLPrecision
, | 65 kVec2f_GrSLType, kDefault_GrSLPrecision
, |
66 "Bounds"); | 66 "Bounds"); |
67 } | 67 } |
68 fKernelUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibili
ty, | 68 fKernelUni = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibili
ty, |
69 kFloat_GrSLType, kDefault_GrSLPrecisio
n, | 69 kFloat_GrSLType, kDefault_GrSLPrecisio
n, |
70 "Kernel", this->width()); | 70 "Kernel", this->width()); |
71 | 71 |
72 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 72 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
73 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); | 73 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); |
74 | 74 |
75 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); |
76 | 76 |
77 int width = this->width(); | 77 int width = this->width(); |
78 const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni); | 78 const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni); |
79 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); | 79 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); |
80 | 80 |
81 fsBuilder->codeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(
), fRadius, imgInc); | 81 fsBuilder->codeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(
), fRadius, imgInc); |
82 | 82 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 | 237 |
238 bool useBounds = random->nextBool(); | 238 bool useBounds = random->nextBool(); |
239 return GrConvolutionEffect::Create(textures[texIdx], | 239 return GrConvolutionEffect::Create(textures[texIdx], |
240 dir, | 240 dir, |
241 radius, | 241 radius, |
242 kernel, | 242 kernel, |
243 useBounds, | 243 useBounds, |
244 bounds); | 244 bounds); |
245 } | 245 } |
OLD | NEW |