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

Side by Side Diff: src/effects/SkMorphologyImageFilter.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/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkPerlinNoiseShader.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 "SkMorphologyImageFilter.h" 8 #include "SkMorphologyImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 319 }
320 320
321 void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder, 321 void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder,
322 const GrDrawEffect&, 322 const GrDrawEffect&,
323 EffectKey key, 323 EffectKey key,
324 const char* outputColor, 324 const char* outputColor,
325 const char* inputColor, 325 const char* inputColor,
326 const TextureSamplerArray& samplers) { 326 const TextureSamplerArray& samplers) {
327 SkString coords; 327 SkString coords;
328 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); 328 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
329 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Shader Type, 329 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi lity,
330 kVec2f_GrSLType, "ImageIncrement"); 330 kVec2f_GrSLType, "ImageIncrement");
331 331
332 const char* func; 332 const char* func;
333 switch (fType) { 333 switch (fType) {
334 case GrMorphologyEffect::kErode_MorphologyType: 334 case GrMorphologyEffect::kErode_MorphologyType:
335 builder->fsCodeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", outputColor); 335 builder->fsCodeAppendf("\t\t%s = vec4(1, 1, 1, 1);\n", outputColor);
336 func = "min"; 336 func = "min";
337 break; 337 break;
338 case GrMorphologyEffect::kDilate_MorphologyType: 338 case GrMorphologyEffect::kDilate_MorphologyType:
339 builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor); 339 builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor);
340 func = "max"; 340 func = "max";
341 break; 341 break;
342 default: 342 default:
343 GrCrash("Unexpected type"); 343 GrCrash("Unexpected type");
344 func = ""; // suppress warning 344 func = ""; // suppress warning
345 break; 345 break;
346 } 346 }
347 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); 347 const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
348 348
349 builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords.c_str(), fRadius, imgInc); 349 builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords.c_str(), fRadius, imgInc);
350 builder->fsCodeAppendf("\t\tfor (int i = 0; i < %d; i++) {\n", this->width() ); 350 builder->fsCodeAppendf("\t\tfor (int i = 0; i < %d; i++) {\n", this->width() );
351 builder->fsCodeAppendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor) ; 351 builder->fsCodeAppendf("\t\t\t%s = %s(%s, ", outputColor, func, outputColor) ;
352 builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, sample rs[0], "coord"); 352 builder->fsAppendTextureLookup(samplers[0], "coord");
353 builder->fsCodeAppend(");\n"); 353 builder->fsCodeAppend(");\n");
354 builder->fsCodeAppendf("\t\t\tcoord += %s;\n", imgInc); 354 builder->fsCodeAppendf("\t\t\tcoord += %s;\n", imgInc);
355 builder->fsCodeAppend("\t\t}\n"); 355 builder->fsCodeAppend("\t\t}\n");
356 SkString modulate; 356 SkString modulate;
357 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); 357 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor);
358 builder->fsCodeAppend(modulate.c_str()); 358 builder->fsCodeAppend(modulate.c_str());
359 } 359 }
360 360
361 GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrDrawEffect& drawEffec t, 361 GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrDrawEffect& drawEffec t,
362 const GrGLCaps&) { 362 const GrGLCaps&) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 523 }
524 GrTexture* input = inputBM.getTexture(); 524 GrTexture* input = inputBM.getTexture();
525 SkIRect bounds; 525 SkIRect bounds;
526 src.getBounds(&bounds); 526 src.getBounds(&bounds);
527 SkAutoTUnref<GrTexture> resultTex(apply_morphology(input, bounds, 527 SkAutoTUnref<GrTexture> resultTex(apply_morphology(input, bounds,
528 GrMorphologyEffect::kErode_MorphologyType, radius())); 528 GrMorphologyEffect::kErode_MorphologyType, radius()));
529 return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(), result); 529 return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(), result);
530 } 530 }
531 531
532 #endif 532 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698