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

Side by Side Diff: src/gpu/effects/GrSimpleTextureEffect.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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.cpp ('k') | src/gpu/effects/GrTextureDomainEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrSimpleTextureEffect.h" 8 #include "GrSimpleTextureEffect.h"
9 #include "gl/GrGLEffect.h" 9 #include "gl/GrGLEffect.h"
10 #include "gl/GrGLEffectMatrix.h" 10 #include "gl/GrGLEffectMatrix.h"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 } 25 }
26 26
27 virtual void emitCode(GrGLShaderBuilder* builder, 27 virtual void emitCode(GrGLShaderBuilder* builder,
28 const GrDrawEffect& drawEffect, 28 const GrDrawEffect& drawEffect,
29 EffectKey key, 29 EffectKey key,
30 const char* outputColor, 30 const char* outputColor,
31 const char* inputColor, 31 const char* inputColor,
32 const TextureSamplerArray& samplers) SK_OVERRIDE { 32 const TextureSamplerArray& samplers) SK_OVERRIDE {
33 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture Effect>(); 33 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture Effect>();
34 const char* fsCoordName; 34 SkString fsCoordName;
35 GrSLType fsCoordSLType; 35 GrSLType fsCoordSLType;
36 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { 36 if (GrEffect::kCustom_CoordsType == ste.coordsType()) {
37 SkASSERT(ste.getMatrix().isIdentity()); 37 SkASSERT(ste.getMatrix().isIdentity());
38 SkASSERT(1 == ste.numVertexAttribs()); 38 SkASSERT(1 == ste.numVertexAttribs());
39 fsCoordSLType = kVec2f_GrSLType; 39 fsCoordSLType = kVec2f_GrSLType;
40 const char* vsVaryingName; 40 const char* vsVaryingName;
41 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName , &fsCoordName); 41 const char* fsVaryingNamePtr;
42 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName , &fsVaryingNamePtr);
43 fsCoordName = fsVaryingNamePtr;
42 const char* attrName = 44 const char* attrName =
43 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice s()[0])->c_str(); 45 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice s()[0])->c_str();
44 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName); 46 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName);
45 } else { 47 } else {
46 fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoord Name); 48 fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoord Name);
47 } 49 }
48 builder->fsCodeAppendf("\t%s = ", outputColor); 50 builder->fsCodeAppendf("\t%s = ", outputColor);
49 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha derType, 51 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_Sha derType,
50 inputColor, 52 inputColor,
51 samplers[0], 53 samplers[0],
52 fsCoordName, 54 fsCoordName.c_str(),
53 fsCoordSLType); 55 fsCoordSLType);
54 builder->fsCodeAppend(";\n"); 56 builder->fsCodeAppend(";\n");
55 } 57 }
56 58
57 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCap s&) { 59 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCap s&) {
58 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture Effect>(); 60 const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTexture Effect>();
59 if (GrEffect::kCustom_CoordsType == ste.coordsType()) { 61 if (GrEffect::kCustom_CoordsType == ste.coordsType()) {
60 return 1 << GrGLEffectMatrix::kKeyBits; 62 return 1 << GrGLEffectMatrix::kKeyBits;
61 } else { 63 } else {
62 return GrGLEffectMatrix::GenKey(ste.getMatrix(), 64 return GrGLEffectMatrix::GenKey(ste.getMatrix(),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 }; 122 };
121 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC oordsTypes))]; 123 CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kC oordsTypes))];
122 124
123 if (kCustom_CoordsType == coordsType) { 125 if (kCustom_CoordsType == coordsType) {
124 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p arams); 126 return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], p arams);
125 } else { 127 } else {
126 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 128 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
127 return GrSimpleTextureEffect::Create(textures[texIdx], matrix); 129 return GrSimpleTextureEffect::Create(textures[texIdx], matrix);
128 } 130 }
129 } 131 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.cpp ('k') | src/gpu/effects/GrTextureDomainEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698