| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkTableColorFilter.h" | 9 #include "SkTableColorFilter.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 const char* outputColor, | 420 const char* outputColor, |
| 421 const char* inputColor, | 421 const char* inputColor, |
| 422 const TransformedCoordsArray&, | 422 const TransformedCoordsArray&, |
| 423 const TextureSamplerArray& samplers) { | 423 const TextureSamplerArray& samplers) { |
| 424 const char* yoffsets; | 424 const char* yoffsets; |
| 425 fRGBAYValuesUni = builder->addUniform(GrGLFPBuilder::kFragment_Visibility, | 425 fRGBAYValuesUni = builder->addUniform(GrGLFPBuilder::kFragment_Visibility, |
| 426 kVec4f_GrSLType, kDefault_GrSLPrecisio
n, | 426 kVec4f_GrSLType, kDefault_GrSLPrecisio
n, |
| 427 "yoffsets", &yoffsets); | 427 "yoffsets", &yoffsets); |
| 428 static const float kColorScaleFactor = 255.0f / 256.0f; | 428 static const float kColorScaleFactor = 255.0f / 256.0f; |
| 429 static const float kColorOffsetFactor = 1.0f / 512.0f; | 429 static const float kColorOffsetFactor = 1.0f / 512.0f; |
| 430 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 430 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| 431 if (NULL == inputColor) { | 431 if (NULL == inputColor) { |
| 432 // the input color is solid white (all ones). | 432 // the input color is solid white (all ones). |
| 433 static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor; | 433 static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor; |
| 434 fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n", | 434 fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n", |
| 435 kMaxValue, kMaxValue, kMaxValue, kMaxValue); | 435 kMaxValue, kMaxValue, kMaxValue, kMaxValue); |
| 436 | 436 |
| 437 } else { | 437 } else { |
| 438 fsBuilder->codeAppendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", i
nputColor); | 438 fsBuilder->codeAppendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", i
nputColor); |
| 439 fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, non
ZeroAlpha);\n", inputColor); | 439 fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, non
ZeroAlpha);\n", inputColor); |
| 440 fsBuilder->codeAppendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n
", | 440 fsBuilder->codeAppendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n
", |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 618 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
| 619 const uint8_t tableR[256], | 619 const uint8_t tableR[256], |
| 620 const uint8_t tableG[256], | 620 const uint8_t tableG[256], |
| 621 const uint8_t tableB[256]) { | 621 const uint8_t tableB[256]) { |
| 622 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); | 622 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); |
| 623 } | 623 } |
| 624 | 624 |
| 625 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 625 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
| 626 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 626 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
| 627 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 627 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |