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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 } | 330 } |
331 | 331 |
332 #if SK_SUPPORT_GPU | 332 #if SK_SUPPORT_GPU |
333 | 333 |
334 #include "GrFragmentProcessor.h" | 334 #include "GrFragmentProcessor.h" |
335 #include "GrInvariantOutput.h" | 335 #include "GrInvariantOutput.h" |
336 #include "SkGr.h" | 336 #include "SkGr.h" |
337 #include "effects/GrTextureStripAtlas.h" | 337 #include "effects/GrTextureStripAtlas.h" |
338 #include "glsl/GrGLSLFragmentProcessor.h" | 338 #include "glsl/GrGLSLFragmentProcessor.h" |
339 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 339 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
340 #include "glsl/GrGLSLProgramBuilder.h" | |
341 #include "glsl/GrGLSLProgramDataManager.h" | 340 #include "glsl/GrGLSLProgramDataManager.h" |
| 341 #include "glsl/GrGLSLUniformHandler.h" |
342 | 342 |
343 class ColorTableEffect : public GrFragmentProcessor { | 343 class ColorTableEffect : public GrFragmentProcessor { |
344 public: | 344 public: |
345 static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap
, unsigned flags); | 345 static const GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap
, unsigned flags); |
346 | 346 |
347 virtual ~ColorTableEffect(); | 347 virtual ~ColorTableEffect(); |
348 | 348 |
349 const char* name() const override { return "ColorTable"; } | 349 const char* name() const override { return "ColorTable"; } |
350 | 350 |
351 const GrTextureStripAtlas* atlas() const { return fAtlas; } | 351 const GrTextureStripAtlas* atlas() const { return fAtlas; } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 rgbaYValues[3] = 0.125; | 408 rgbaYValues[3] = 0.125; |
409 rgbaYValues[0] = 0.375; | 409 rgbaYValues[0] = 0.375; |
410 rgbaYValues[1] = 0.625; | 410 rgbaYValues[1] = 0.625; |
411 rgbaYValues[2] = 0.875; | 411 rgbaYValues[2] = 0.875; |
412 } | 412 } |
413 pdm.set4fv(fRGBAYValuesUni, 1, rgbaYValues); | 413 pdm.set4fv(fRGBAYValuesUni, 1, rgbaYValues); |
414 } | 414 } |
415 | 415 |
416 void GLColorTableEffect::emitCode(EmitArgs& args) { | 416 void GLColorTableEffect::emitCode(EmitArgs& args) { |
417 const char* yoffsets; | 417 const char* yoffsets; |
418 fRGBAYValuesUni = args.fBuilder->addUniform(GrGLSLFPBuilder::kFragment_Visib
ility, | 418 fRGBAYValuesUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFr
agment_Visibility, |
419 kVec4f_GrSLType, kDefault_GrSLPr
ecision, | 419 kVec4f_GrSLType, kDefault
_GrSLPrecision, |
420 "yoffsets", &yoffsets); | 420 "yoffsets", &yoffsets); |
421 static const float kColorScaleFactor = 255.0f / 256.0f; | 421 static const float kColorScaleFactor = 255.0f / 256.0f; |
422 static const float kColorOffsetFactor = 1.0f / 512.0f; | 422 static const float kColorOffsetFactor = 1.0f / 512.0f; |
423 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 423 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
424 if (nullptr == args.fInputColor) { | 424 if (nullptr == args.fInputColor) { |
425 // the input color is solid white (all ones). | 425 // the input color is solid white (all ones). |
426 static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor; | 426 static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor; |
427 fragBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n", | 427 fragBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n", |
428 kMaxValue, kMaxValue, kMaxValue, kMaxValue); | 428 kMaxValue, kMaxValue, kMaxValue, kMaxValue); |
429 | 429 |
430 } else { | 430 } else { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 598 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
599 const uint8_t tableR[256], | 599 const uint8_t tableR[256], |
600 const uint8_t tableG[256], | 600 const uint8_t tableG[256], |
601 const uint8_t tableB[256]) { | 601 const uint8_t tableB[256]) { |
602 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); | 602 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); |
603 } | 603 } |
604 | 604 |
605 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 605 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
606 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 606 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
607 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 607 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |