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

Side by Side Diff: src/effects/SkMagnifierImageFilter.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/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.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 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkMagnifierImageFilter.h" 9 #include "SkMagnifierImageFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 : INHERITED(factory) 120 : INHERITED(factory)
121 , fEffectMatrix(drawEffect.castEffect<GrMagnifierEffect>().coordsType()) { 121 , fEffectMatrix(drawEffect.castEffect<GrMagnifierEffect>().coordsType()) {
122 } 122 }
123 123
124 void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder, 124 void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder,
125 const GrDrawEffect&, 125 const GrDrawEffect&,
126 EffectKey key, 126 EffectKey key,
127 const char* outputColor, 127 const char* outputColor,
128 const char* inputColor, 128 const char* inputColor,
129 const TextureSamplerArray& samplers) { 129 const TextureSamplerArray& samplers) {
130 const char* coords; 130 SkString coords;
131 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); 131 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
132 fOffsetVar = builder->addUniform( 132 fOffsetVar = builder->addUniform(
133 GrGLShaderBuilder::kFragment_ShaderType | 133 GrGLShaderBuilder::kFragment_ShaderType |
134 GrGLShaderBuilder::kVertex_ShaderType, 134 GrGLShaderBuilder::kVertex_ShaderType,
135 kVec2f_GrSLType, "uOffset"); 135 kVec2f_GrSLType, "uOffset");
136 fZoomVar = builder->addUniform( 136 fZoomVar = builder->addUniform(
137 GrGLShaderBuilder::kFragment_ShaderType | 137 GrGLShaderBuilder::kFragment_ShaderType |
138 GrGLShaderBuilder::kVertex_ShaderType, 138 GrGLShaderBuilder::kVertex_ShaderType,
139 kVec2f_GrSLType, "uZoom"); 139 kVec2f_GrSLType, "uZoom");
140 fInsetVar = builder->addUniform( 140 fInsetVar = builder->addUniform(
141 GrGLShaderBuilder::kFragment_ShaderType | 141 GrGLShaderBuilder::kFragment_ShaderType |
142 GrGLShaderBuilder::kVertex_ShaderType, 142 GrGLShaderBuilder::kVertex_ShaderType,
143 kVec2f_GrSLType, "uInset"); 143 kVec2f_GrSLType, "uInset");
144 144
145 builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords); 145 builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords.c_str());
146 builder->fsCodeAppendf("\t\tvec2 zoom_coord = %s + %s / %s;\n", 146 builder->fsCodeAppendf("\t\tvec2 zoom_coord = %s + %s / %s;\n",
147 builder->getUniformCStr(fOffsetVar), 147 builder->getUniformCStr(fOffsetVar),
148 coords, 148 coords.c_str(),
149 builder->getUniformCStr(fZoomVar)); 149 builder->getUniformCStr(fZoomVar));
150 150
151 builder->fsCodeAppend("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\ n"); 151 builder->fsCodeAppend("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\ n");
152 152
153 builder->fsCodeAppendf("\t\tdelta = delta / %s;\n", builder->getUniformCStr( fInsetVar)); 153 builder->fsCodeAppendf("\t\tdelta = delta / %s;\n", builder->getUniformCStr( fInsetVar));
154 154
155 builder->fsCodeAppend("\t\tfloat weight = 0.0;\n"); 155 builder->fsCodeAppend("\t\tfloat weight = 0.0;\n");
156 builder->fsCodeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n"); 156 builder->fsCodeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
157 builder->fsCodeAppend("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n"); 157 builder->fsCodeAppend("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n");
158 builder->fsCodeAppend("\t\t\tfloat dist = length(delta);\n"); 158 builder->fsCodeAppend("\t\t\tfloat dist = length(delta);\n");
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); 343 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1);
344 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); 344 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1);
345 345
346 *dptr = sptr[y_val * width + x_val]; 346 *dptr = sptr[y_val * width + x_val];
347 dptr++; 347 dptr++;
348 } 348 }
349 } 349 }
350 return true; 350 return true;
351 } 351 }
OLDNEW
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698