| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 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 "SkColorMatrixFilter.h" | 8 #include "SkColorMatrixFilter.h" |
| 9 #include "SkColorMatrix.h" | 9 #include "SkColorMatrix.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 kMat44f_GrSLType, kDefault_GrSLP
recision, | 437 kMat44f_GrSLType, kDefault_GrSLP
recision, |
| 438 "ColorMatrix"); | 438 "ColorMatrix"); |
| 439 fVectorHandle = builder->addUniform(GrGLProgramBuilder::kFragment_Vi
sibility, | 439 fVectorHandle = builder->addUniform(GrGLProgramBuilder::kFragment_Vi
sibility, |
| 440 kVec4f_GrSLType, kDefault_GrSLPr
ecision, | 440 kVec4f_GrSLType, kDefault_GrSLPr
ecision, |
| 441 "ColorMatrixVector"); | 441 "ColorMatrixVector"); |
| 442 | 442 |
| 443 if (NULL == inputColor) { | 443 if (NULL == inputColor) { |
| 444 // could optimize this case, but we aren't for now. | 444 // could optimize this case, but we aren't for now. |
| 445 inputColor = "vec4(1)"; | 445 inputColor = "vec4(1)"; |
| 446 } | 446 } |
| 447 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder
(); | 447 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder()
; |
| 448 // The max() is to guard against 0 / 0 during unpremul when the inco
ming color is | 448 // The max() is to guard against 0 / 0 during unpremul when the inco
ming color is |
| 449 // transparent black. | 449 // transparent black. |
| 450 fsBuilder->codeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n
", inputColor); | 450 fsBuilder->codeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n
", inputColor); |
| 451 fsBuilder->codeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZ
eroAlpha) + %s;\n", | 451 fsBuilder->codeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZ
eroAlpha) + %s;\n", |
| 452 outputColor, | 452 outputColor, |
| 453 builder->getUniformCStr(fMatrixHandle), | 453 builder->getUniformCStr(fMatrixHandle), |
| 454 inputColor, | 454 inputColor, |
| 455 builder->getUniformCStr(fVectorHandle)); | 455 builder->getUniformCStr(fVectorHandle)); |
| 456 fsBuilder->codeAppendf("\t%s = clamp(%s, 0.0, 1.0);\n", outputColor,
outputColor); | 456 fsBuilder->codeAppendf("\t%s = clamp(%s, 0.0, 1.0);\n", outputColor,
outputColor); |
| 457 fsBuilder->codeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol
or); | 457 fsBuilder->codeAppendf("\t%s.rgb *= %s.a;\n", outputColor, outputCol
or); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 str->append("matrix: ("); | 577 str->append("matrix: ("); |
| 578 for (int i = 0; i < 20; ++i) { | 578 for (int i = 0; i < 20; ++i) { |
| 579 str->appendScalar(fMatrix.fMat[i]); | 579 str->appendScalar(fMatrix.fMat[i]); |
| 580 if (i < 19) { | 580 if (i < 19) { |
| 581 str->append(", "); | 581 str->append(", "); |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 str->append(")"); | 584 str->append(")"); |
| 585 } | 585 } |
| 586 #endif | 586 #endif |
| OLD | NEW |