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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 if (ce.useBounds()) { | 75 if (ce.useBounds()) { |
76 // We used to compute a bool indicating whether we're in bounds or n
ot, cast it to a | 76 // We used to compute a bool indicating whether we're in bounds or n
ot, cast it to a |
77 // float, and then mul weight*texture_sample by the float. However,
the Adreno 430 seems | 77 // float, and then mul weight*texture_sample by the float. However,
the Adreno 430 seems |
78 // to have a bug that caused corruption. | 78 // to have a bug that caused corruption. |
79 const char* bounds = uniformHandler->getUniformCStr(fBoundsUni); | 79 const char* bounds = uniformHandler->getUniformCStr(fBoundsUni); |
80 const char* component = ce.direction() == Gr1DKernelEffect::kY_Direc
tion ? "y" : "x"; | 80 const char* component = ce.direction() == Gr1DKernelEffect::kY_Direc
tion ? "y" : "x"; |
81 fragBuilder->codeAppendf("if (coord.%s >= %s.x && coord.%s <= %s.y)
{", | 81 fragBuilder->codeAppendf("if (coord.%s >= %s.x && coord.%s <= %s.y)
{", |
82 component, bounds, component, bounds); | 82 component, bounds, component, bounds); |
83 } | 83 } |
84 fragBuilder->codeAppendf("\t\t%s += ", args.fOutputColor); | 84 fragBuilder->codeAppendf("\t\t%s += ", args.fOutputColor); |
85 fragBuilder->appendTextureLookup(args.fTexSamplers[0], "coord"); | 85 fragBuilder->appendTextureLookup(uniformHandler->getSampler(args.fTexSam
plers[0]), "coord"); |
86 fragBuilder->codeAppendf(" * %s;\n", kernelIndex.c_str()); | 86 fragBuilder->codeAppendf(" * %s;\n", kernelIndex.c_str()); |
87 if (ce.useBounds()) { | 87 if (ce.useBounds()) { |
88 fragBuilder->codeAppend("}"); | 88 fragBuilder->codeAppend("}"); |
89 } | 89 } |
90 fragBuilder->codeAppendf("\t\tcoord += %s;\n", imgInc); | 90 fragBuilder->codeAppendf("\t\tcoord += %s;\n", imgInc); |
91 } | 91 } |
92 | 92 |
93 SkString modulate; | 93 SkString modulate; |
94 GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor); | 94 GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor); |
95 fragBuilder->codeAppend(modulate.c_str()); | 95 fragBuilder->codeAppend(modulate.c_str()); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 | 229 |
230 bool useBounds = d->fRandom->nextBool(); | 230 bool useBounds = d->fRandom->nextBool(); |
231 return GrConvolutionEffect::Create(d->fTextures[texIdx], | 231 return GrConvolutionEffect::Create(d->fTextures[texIdx], |
232 dir, | 232 dir, |
233 radius, | 233 radius, |
234 kernel, | 234 kernel, |
235 useBounds, | 235 useBounds, |
236 bounds); | 236 bounds); |
237 } | 237 } |
OLD | NEW |