| OLD | NEW |
| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 const TextureSamplerArray&) SK_OVERRIDE { | 403 const TextureSamplerArray&) SK_OVERRIDE { |
| 404 fMatrixHandle = builder->addUniform(GrGLShaderBuilder::kFragment_Vis
ibility, | 404 fMatrixHandle = builder->addUniform(GrGLShaderBuilder::kFragment_Vis
ibility, |
| 405 kMat44f_GrSLType, | 405 kMat44f_GrSLType, |
| 406 "ColorMatrix"); | 406 "ColorMatrix"); |
| 407 fVectorHandle = builder->addUniform(GrGLShaderBuilder::kFragment_Vis
ibility, | 407 fVectorHandle = builder->addUniform(GrGLShaderBuilder::kFragment_Vis
ibility, |
| 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 = "vec4(1)"; |
| 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->fsCodeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n
", inputColor); | 417 builder->fsCodeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n
", inputColor); |
| 418 builder->fsCodeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZ
eroAlpha) + %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->fsCodeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol
or); | 423 builder->fsCodeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol
or); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 str->append("matrix: ("); | 486 str->append("matrix: ("); |
| 487 for (int i = 0; i < 20; ++i) { | 487 for (int i = 0; i < 20; ++i) { |
| 488 str->appendScalar(fMatrix.fMat[i]); | 488 str->appendScalar(fMatrix.fMat[i]); |
| 489 if (i < 19) { | 489 if (i < 19) { |
| 490 str->append(", "); | 490 str->append(", "); |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 str->append(")"); | 493 str->append(")"); |
| 494 } | 494 } |
| 495 #endif | 495 #endif |
| OLD | NEW |