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 17 matching lines...) Expand all Loading... |
28 UniformHandle fImageIncrementUni; | 28 UniformHandle fImageIncrementUni; |
29 UniformHandle fBoundsUni; | 29 UniformHandle fBoundsUni; |
30 | 30 |
31 typedef GrGLSLFragmentProcessor INHERITED; | 31 typedef GrGLSLFragmentProcessor INHERITED; |
32 }; | 32 }; |
33 | 33 |
34 void GrGLConvolutionEffect::emitCode(EmitArgs& args) { | 34 void GrGLConvolutionEffect::emitCode(EmitArgs& args) { |
35 const GrConvolutionEffect& ce = args.fFp.cast<GrConvolutionEffect>(); | 35 const GrConvolutionEffect& ce = args.fFp.cast<GrConvolutionEffect>(); |
36 | 36 |
37 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; | 37 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; |
38 fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragm
ent_Visibility, | 38 fImageIncrementUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
39 kVec2f_GrSLType, kDefault_Gr
SLPrecision, | 39 kVec2f_GrSLType, kDefault_Gr
SLPrecision, |
40 "ImageIncrement"); | 40 "ImageIncrement"); |
41 if (ce.useBounds()) { | 41 if (ce.useBounds()) { |
42 fBoundsUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_
Visibility, | 42 fBoundsUni = uniformHandler->addUniform(kFragment_GrShaderFlag, |
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(GrGLSLUniformHandler::kFragment
_Visibility, | 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 GrGLSLFragmentBuilder* 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); |
(...skipping 161 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 |