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

Side by Side Diff: src/effects/SkBicubicImageFilter.cpp

Issue 23826002: Rename ShaderType enum to ShaderVisibility (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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/SkArithmeticMode.cpp ('k') | src/effects/SkColorMatrixFilter.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 2013 The Android Open Source Project 2 * Copyright 2013 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 "SkBicubicImageFilter.h" 8 #include "SkBicubicImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 219 }
220 220
221 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, 221 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder,
222 const GrDrawEffect&, 222 const GrDrawEffect&,
223 EffectKey key, 223 EffectKey key,
224 const char* outputColor, 224 const char* outputColor,
225 const char* inputColor, 225 const char* inputColor,
226 const TextureSamplerArray& samplers) { 226 const TextureSamplerArray& samplers) {
227 SkString coords; 227 SkString coords;
228 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); 228 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
229 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderTy pe, 229 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili ty,
230 kMat44f_GrSLType, "Coefficients"); 230 kMat44f_GrSLType, "Coefficients");
231 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Shader Type, 231 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi lity,
232 kVec2f_GrSLType, "ImageIncrement"); 232 kVec2f_GrSLType, "ImageIncrement");
233 233
234 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); 234 const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
235 const char* coeff = builder->getUniformCStr(fCoefficientsUni); 235 const char* coeff = builder->getUniformCStr(fCoefficientsUni);
236 236
237 SkString cubicBlendName; 237 SkString cubicBlendName;
238 238
239 static const GrGLShaderVar gCubicBlendArgs[] = { 239 static const GrGLShaderVar gCubicBlendArgs[] = {
240 GrGLShaderVar("coefficients", kMat44f_GrSLType), 240 GrGLShaderVar("coefficients", kMat44f_GrSLType),
241 GrGLShaderVar("t", kFloat_GrSLType), 241 GrGLShaderVar("t", kFloat_GrSLType),
242 GrGLShaderVar("c0", kVec4f_GrSLType), 242 GrGLShaderVar("c0", kVec4f_GrSLType),
243 GrGLShaderVar("c1", kVec4f_GrSLType), 243 GrGLShaderVar("c1", kVec4f_GrSLType),
244 GrGLShaderVar("c2", kVec4f_GrSLType), 244 GrGLShaderVar("c2", kVec4f_GrSLType),
245 GrGLShaderVar("c3", kVec4f_GrSLType), 245 GrGLShaderVar("c3", kVec4f_GrSLType),
246 }; 246 };
247 builder->emitFunction(GrGLShaderBuilder::kFragment_ShaderType, 247 builder->fsEmitFunction(kVec4f_GrSLType,
248 kVec4f_GrSLType, 248 "cubicBlend",
249 "cubicBlend", 249 SK_ARRAY_COUNT(gCubicBlendArgs),
250 SK_ARRAY_COUNT(gCubicBlendArgs), 250 gCubicBlendArgs,
251 gCubicBlendArgs, 251 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n"
252 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" 252 "\tvec4 c = coefficients * ts;\n"
253 "\tvec4 c = coefficients * ts;\n" 253 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3; \n",
254 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;\n ", 254 &cubicBlendName);
255 &cubicBlendName);
256 builder->fsCodeAppendf("\tvec2 coord = %s - %s * vec2(0.5, 0.5);\n", coords. c_str(), imgInc); 255 builder->fsCodeAppendf("\tvec2 coord = %s - %s * vec2(0.5, 0.5);\n", coords. c_str(), imgInc);
257 builder->fsCodeAppendf("\tvec2 f = fract(coord / %s);\n", imgInc); 256 builder->fsCodeAppendf("\tvec2 f = fract(coord / %s);\n", imgInc);
258 for (int y = 0; y < 4; ++y) { 257 for (int y = 0; y < 4; ++y) {
259 for (int x = 0; x < 4; ++x) { 258 for (int x = 0; x < 4; ++x) {
260 SkString coord; 259 SkString coord;
261 coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1); 260 coord.printf("coord + %s * vec2(%d, %d)", imgInc, x - 1, y - 1);
262 builder->fsCodeAppendf("\tvec4 s%d%d = ", x, y); 261 builder->fsCodeAppendf("\tvec4 s%d%d = ", x, y);
263 builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType , 262 builder->fsAppendTextureLookup(samplers[0], coord.c_str());
264 samplers[0],
265 coord.c_str());
266 builder->fsCodeAppend(";\n"); 263 builder->fsCodeAppend(";\n");
267 } 264 }
268 builder->fsCodeAppendf("\tvec4 s%d = %s(%s, f.x, s0%d, s1%d, s2%d, s3%d) ;\n", y, cubicBlendName.c_str(), coeff, y, y, y, y); 265 builder->fsCodeAppendf("\tvec4 s%d = %s(%s, f.x, s0%d, s1%d, s2%d, s3%d) ;\n", y, cubicBlendName.c_str(), coeff, y, y, y, y);
269 } 266 }
270 builder->fsCodeAppendf("\t%s = %s(%s, f.y, s0, s1, s2, s3);\n", outputColor, cubicBlendName.c_str(), coeff); 267 builder->fsCodeAppendf("\t%s = %s(%s, f.y, s0, s1, s2, s3);\n", outputColor, cubicBlendName.c_str(), coeff);
271 } 268 }
272 269
273 GrGLEffect::EffectKey GrGLBicubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { 270 GrGLEffect::EffectKey GrGLBicubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
274 const GrBicubicEffect& bicubic = drawEffect.castEffect<GrBicubicEffect>(); 271 const GrBicubicEffect& bicubic = drawEffect.castEffect<GrBicubicEffect>();
275 EffectKey matrixKey = GrGLEffectMatrix::GenKey(bicubic.getMatrix(), 272 EffectKey matrixKey = GrGLEffectMatrix::GenKey(bicubic.getMatrix(),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 GrPaint paint; 363 GrPaint paint;
367 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un ref(); 364 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un ref();
368 SkRect srcRect; 365 SkRect srcRect;
369 srcBM.getBounds(&srcRect); 366 srcBM.getBounds(&srcRect);
370 context->drawRectToRect(paint, dstRect, srcRect); 367 context->drawRectToRect(paint, dstRect, srcRect);
371 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul t); 368 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul t);
372 } 369 }
373 #endif 370 #endif
374 371
375 /////////////////////////////////////////////////////////////////////////////// 372 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698