Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: src/effects/SkPerlinNoiseShader.cpp

Issue 23706003: Fix case where GrGLEffectMatrix gives back a dangling ptr for the coords var name. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rob's comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkPerlinNoiseShader.cpp
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 1d26920c501db288e86babd562c02f34616630c5..720fcf27ededdf3841a933d6e3b35d17cd0cff19 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -749,7 +749,7 @@ void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder,
const TextureSamplerArray&) {
sk_ignore_unused_variable(inputColor);
- const char* vCoords;
+ SkString vCoords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &vCoords);
fSeedUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
@@ -904,7 +904,7 @@ void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder,
// There are rounding errors if the floor operation is not performed here
builder->fsCodeAppendf(
"\t\tvec3 %s = vec3(floor((%s*vec3(%s, 1.0)).xy) * vec2(0.66) * %s, 0.0);\n",
- noiseVecIni, invMatrixUni, vCoords, baseFrequencyUni);
+ noiseVecIni, invMatrixUni, vCoords.c_str(), baseFrequencyUni);
// Perturb the texcoords with three components of noise
builder->fsCodeAppendf("\t\t%s += 0.1 * vec3(%s(%s + vec3( 0.0, 0.0, %s)),"
@@ -965,7 +965,7 @@ void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder,
const TextureSamplerArray& samplers) {
sk_ignore_unused_variable(inputColor);
- const char* vCoords;
+ SkString vCoords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &vCoords);
fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
@@ -1148,7 +1148,7 @@ void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder,
// There are rounding errors if the floor operation is not performed here
builder->fsCodeAppendf("\n\t\tvec2 %s = floor((%s * vec3(%s, 1.0)).xy) * %s;",
- noiseVec, invMatrixUni, vCoords, baseFrequencyUni);
+ noiseVec, invMatrixUni, vCoords.c_str(), baseFrequencyUni);
// Clear the color accumulator
builder->fsCodeAppendf("\n\t\t%s = vec4(0.0);", outputColor);
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698