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 "SkTableColorFilter.h" | 8 #include "SkTableColorFilter.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 rgbaYValues[3] = 0.125; | 407 rgbaYValues[3] = 0.125; |
408 rgbaYValues[0] = 0.375; | 408 rgbaYValues[0] = 0.375; |
409 rgbaYValues[1] = 0.625; | 409 rgbaYValues[1] = 0.625; |
410 rgbaYValues[2] = 0.875; | 410 rgbaYValues[2] = 0.875; |
411 } | 411 } |
412 pdm.set4fv(fRGBAYValuesUni, 1, rgbaYValues); | 412 pdm.set4fv(fRGBAYValuesUni, 1, rgbaYValues); |
413 } | 413 } |
414 | 414 |
415 void GLColorTableEffect::emitCode(EmitArgs& args) { | 415 void GLColorTableEffect::emitCode(EmitArgs& args) { |
416 const char* yoffsets; | 416 const char* yoffsets; |
417 fRGBAYValuesUni = args.fBuilder->addUniform(GrGLFPBuilder::kFragment_Visibil
ity, | 417 fRGBAYValuesUni = args.fBuilder->addUniform(GrGLSLFPBuilder::kFragment_Visib
ility, |
418 kVec4f_GrSLType, kDefault_GrSLPrecisio
n, | 418 kVec4f_GrSLType, kDefault_GrSLPr
ecision, |
419 "yoffsets", &yoffsets); | 419 "yoffsets", &yoffsets); |
420 static const float kColorScaleFactor = 255.0f / 256.0f; | 420 static const float kColorScaleFactor = 255.0f / 256.0f; |
421 static const float kColorOffsetFactor = 1.0f / 512.0f; | 421 static const float kColorOffsetFactor = 1.0f / 512.0f; |
422 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); | 422 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); |
423 if (nullptr == args.fInputColor) { | 423 if (nullptr == args.fInputColor) { |
424 // the input color is solid white (all ones). | 424 // the input color is solid white (all ones). |
425 static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor; | 425 static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor; |
426 fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n", | 426 fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n", |
427 kMaxValue, kMaxValue, kMaxValue, kMaxValue); | 427 kMaxValue, kMaxValue, kMaxValue, kMaxValue); |
428 | 428 |
429 } else { | 429 } else { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 597 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
598 const uint8_t tableR[256], | 598 const uint8_t tableR[256], |
599 const uint8_t tableG[256], | 599 const uint8_t tableG[256], |
600 const uint8_t tableB[256]) { | 600 const uint8_t tableB[256]) { |
601 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); | 601 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); |
602 } | 602 } |
603 | 603 |
604 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 604 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
605 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 605 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
606 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 606 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |