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

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

Issue 12547012: Make GrGLEffects use an interface to append their code. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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/SkBlendImageFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkColorMatrixFilter.h" 8 #include "SkColorMatrixFilter.h"
9 #include "SkColorMatrix.h" 9 #include "SkColorMatrix.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 fVectorHandle = builder->addUniform(GrGLShaderBuilder::kFragment_Sha derType, 407 fVectorHandle = builder->addUniform(GrGLShaderBuilder::kFragment_Sha derType,
408 kVec4f_GrSLType, 408 kVec4f_GrSLType,
409 "ColorMatrixVector"); 409 "ColorMatrixVector");
410 410
411 if (NULL == inputColor) { 411 if (NULL == inputColor) {
412 // could optimize this case, but we aren't for now. 412 // could optimize this case, but we aren't for now.
413 inputColor = GrGLSLOnesVecf(4); 413 inputColor = GrGLSLOnesVecf(4);
414 } 414 }
415 // The max() is to guard against 0 / 0 during unpremul when the inco ming color is 415 // The max() is to guard against 0 / 0 during unpremul when the inco ming color is
416 // transparent black. 416 // transparent black.
417 builder->fFSCode.appendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001); \n", inputColor); 417 builder->fsCodeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n ", inputColor);
418 builder->fFSCode.appendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, no nZeroAlpha) + %s;\n", 418 builder->fsCodeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZ eroAlpha) + %s;\n",
419 outputColor, 419 outputColor,
420 builder->getUniformCStr(fMatrixHandle), 420 builder->getUniformCStr(fMatrixHandle),
421 inputColor, 421 inputColor,
422 builder->getUniformCStr(fVectorHandle)); 422 builder->getUniformCStr(fVectorHandle));
423 builder->fFSCode.appendf("\t%s.rgb *= %s.a;\n", outputColor, outputC olor); 423 builder->fsCodeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol or);
424 } 424 }
425 425
426 virtual void setData(const GrGLUniformManager& uniManager, 426 virtual void setData(const GrGLUniformManager& uniManager,
427 const GrEffectStage& stage) SK_OVERRIDE { 427 const GrEffectStage& stage) SK_OVERRIDE {
428 const ColorMatrixEffect& cme = GetEffectFromStage<ColorMatrixEffect> (stage); 428 const ColorMatrixEffect& cme = GetEffectFromStage<ColorMatrixEffect> (stage);
429 const float* m = cme.fMatrix.fMat; 429 const float* m = cme.fMatrix.fMat;
430 // The GL matrix is transposed from SkColorMatrix. 430 // The GL matrix is transposed from SkColorMatrix.
431 GrGLfloat mt[] = { 431 GrGLfloat mt[] = {
432 m[0], m[5], m[10], m[15], 432 m[0], m[5], m[10], m[15],
433 m[1], m[6], m[11], m[16], 433 m[1], m[6], m[11], m[16],
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 colorMatrix.fMat[i] = random->nextSScalar1(); 470 colorMatrix.fMat[i] = random->nextSScalar1();
471 } 471 }
472 return ColorMatrixEffect::Create(colorMatrix); 472 return ColorMatrixEffect::Create(colorMatrix);
473 } 473 }
474 474
475 GrEffectRef* SkColorMatrixFilter::asNewEffect(GrContext*) const { 475 GrEffectRef* SkColorMatrixFilter::asNewEffect(GrContext*) const {
476 return ColorMatrixEffect::Create(fMatrix); 476 return ColorMatrixEffect::Create(fMatrix);
477 } 477 }
478 478
479 #endif 479 #endif
OLDNEW
« no previous file with comments | « src/effects/SkBlendImageFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698