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

Side by Side Diff: src/gpu/effects/GrConvolutionEffect.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/GrConfigConversionEffect.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.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 "GrConvolutionEffect.h" 8 #include "GrConvolutionEffect.h"
9 #include "gl/GrGLEffect.h" 9 #include "gl/GrGLEffect.h"
10 #include "gl/GrGLEffectMatrix.h" 10 #include "gl/GrGLEffectMatrix.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 fUseBounds = c.useBounds(); 55 fUseBounds = c.useBounds();
56 fDirection = c.direction(); 56 fDirection = c.direction();
57 } 57 }
58 58
59 void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder, 59 void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
60 const GrDrawEffect&, 60 const GrDrawEffect&,
61 EffectKey key, 61 EffectKey key,
62 const char* outputColor, 62 const char* outputColor,
63 const char* inputColor, 63 const char* inputColor,
64 const TextureSamplerArray& samplers) { 64 const TextureSamplerArray& samplers) {
65 const char* coords; 65 SkString coords;
66 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); 66 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
67 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Shader Type, 67 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Shader Type,
68 kVec2f_GrSLType, "ImageIncrement"); 68 kVec2f_GrSLType, "ImageIncrement");
69 if (this->useBounds()) { 69 if (this->useBounds()) {
70 fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType , 70 fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType ,
71 kVec2f_GrSLType, "Bounds"); 71 kVec2f_GrSLType, "Bounds");
72 } 72 }
73 fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderTyp e, 73 fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderTyp e,
74 kFloat_GrSLType, "Kernel", this->width ()); 74 kFloat_GrSLType, "Kernel", this->width ());
75 75
76 builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); 76 builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor);
77 77
78 int width = this->width(); 78 int width = this->width();
79 const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni); 79 const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni);
80 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); 80 const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
81 81
82 builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords, fRadius , imgInc); 82 builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords.c_str(), fRadius, imgInc);
83 83
84 // Manually unroll loop because some drivers don't; yields 20-30% speedup. 84 // Manually unroll loop because some drivers don't; yields 20-30% speedup.
85 for (int i = 0; i < width; i++) { 85 for (int i = 0; i < width; i++) {
86 SkString index; 86 SkString index;
87 SkString kernelIndex; 87 SkString kernelIndex;
88 index.appendS32(i); 88 index.appendS32(i);
89 kernel.appendArrayAccess(index.c_str(), &kernelIndex); 89 kernel.appendArrayAccess(index.c_str(), &kernelIndex);
90 builder->fsCodeAppendf("\t\t%s += ", outputColor); 90 builder->fsCodeAppendf("\t\t%s += ", outputColor);
91 builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, sa mplers[0], "coord"); 91 builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, sa mplers[0], "coord");
92 if (this->useBounds()) { 92 if (this->useBounds()) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 237 }
238 238
239 bool useBounds = random->nextBool(); 239 bool useBounds = random->nextBool();
240 return GrConvolutionEffect::Create(textures[texIdx], 240 return GrConvolutionEffect::Create(textures[texIdx],
241 dir, 241 dir,
242 radius, 242 radius,
243 kernel, 243 kernel,
244 useBounds, 244 useBounds,
245 bounds); 245 bounds);
246 } 246 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConfigConversionEffect.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698