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

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

Issue 196133006: Colormatrix GPU fix with saturated alpha. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix typo Created 6 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 | « expectations/gm/ignored-tests.txt ('k') | no next file » | 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 inputColor = "vec4(1)"; 417 inputColor = "vec4(1)";
418 } 418 }
419 // The max() is to guard against 0 / 0 during unpremul when the inco ming color is 419 // The max() is to guard against 0 / 0 during unpremul when the inco ming color is
420 // transparent black. 420 // transparent black.
421 builder->fsCodeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n ", inputColor); 421 builder->fsCodeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n ", inputColor);
422 builder->fsCodeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZ eroAlpha) + %s;\n", 422 builder->fsCodeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZ eroAlpha) + %s;\n",
423 outputColor, 423 outputColor,
424 builder->getUniformCStr(fMatrixHandle), 424 builder->getUniformCStr(fMatrixHandle),
425 inputColor, 425 inputColor,
426 builder->getUniformCStr(fVectorHandle)); 426 builder->getUniformCStr(fVectorHandle));
427 builder->fsCodeAppendf("\t%s = clamp(%s, 0.0, 1.0);\n", outputColor, outputColor);
427 builder->fsCodeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol or); 428 builder->fsCodeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol or);
428 } 429 }
429 430
430 virtual void setData(const GrGLUniformManager& uniManager, 431 virtual void setData(const GrGLUniformManager& uniManager,
431 const GrDrawEffect& drawEffect) SK_OVERRIDE { 432 const GrDrawEffect& drawEffect) SK_OVERRIDE {
432 const ColorMatrixEffect& cme = drawEffect.castEffect<ColorMatrixEffe ct>(); 433 const ColorMatrixEffect& cme = drawEffect.castEffect<ColorMatrixEffe ct>();
433 const float* m = cme.fMatrix.fMat; 434 const float* m = cme.fMatrix.fMat;
434 // The GL matrix is transposed from SkColorMatrix. 435 // The GL matrix is transposed from SkColorMatrix.
435 GrGLfloat mt[] = { 436 GrGLfloat mt[] = {
436 m[0], m[5], m[10], m[15], 437 m[0], m[5], m[10], m[15],
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 str->append("matrix: ("); 491 str->append("matrix: (");
491 for (int i = 0; i < 20; ++i) { 492 for (int i = 0; i < 20; ++i) {
492 str->appendScalar(fMatrix.fMat[i]); 493 str->appendScalar(fMatrix.fMat[i]);
493 if (i < 19) { 494 if (i < 19) {
494 str->append(", "); 495 str->append(", ");
495 } 496 }
496 } 497 }
497 str->append(")"); 498 str->append(")");
498 } 499 }
499 #endif 500 #endif
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698