| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 unsigned fFlags; | 370 unsigned fFlags; |
| 371 | 371 |
| 372 GrTextureStripAtlas* fAtlas; | 372 GrTextureStripAtlas* fAtlas; |
| 373 int fRow; | 373 int fRow; |
| 374 | 374 |
| 375 typedef GrFragmentProcessor INHERITED; | 375 typedef GrFragmentProcessor INHERITED; |
| 376 }; | 376 }; |
| 377 | 377 |
| 378 class GLColorTableEffect : public GrGLSLFragmentProcessor { | 378 class GLColorTableEffect : public GrGLSLFragmentProcessor { |
| 379 public: | 379 public: |
| 380 GLColorTableEffect(const GrProcessor&); | 380 void emitCode(EmitArgs&) override; |
| 381 | |
| 382 virtual void emitCode(EmitArgs&) override; | |
| 383 | 381 |
| 384 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der* b) {} | 382 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der* b) {} |
| 385 | 383 |
| 386 protected: | 384 protected: |
| 387 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 385 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
| 388 | 386 |
| 389 private: | 387 private: |
| 390 UniformHandle fRGBAYValuesUni; | 388 UniformHandle fRGBAYValuesUni; |
| 391 typedef GrGLSLFragmentProcessor INHERITED; | 389 typedef GrGLSLFragmentProcessor INHERITED; |
| 392 }; | 390 }; |
| 393 | 391 |
| 394 GLColorTableEffect::GLColorTableEffect(const GrProcessor&) { | |
| 395 } | |
| 396 | |
| 397 void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const Gr
Processor& proc) { | 392 void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const Gr
Processor& proc) { |
| 398 // The textures are organized in a strip where the rows are ordered a, r, g,
b. | 393 // The textures are organized in a strip where the rows are ordered a, r, g,
b. |
| 399 float rgbaYValues[4]; | 394 float rgbaYValues[4]; |
| 400 const ColorTableEffect& cte = proc.cast<ColorTableEffect>(); | 395 const ColorTableEffect& cte = proc.cast<ColorTableEffect>(); |
| 401 if (cte.atlas()) { | 396 if (cte.atlas()) { |
| 402 SkScalar yDelta = cte.atlas()->getNormalizedTexelHeight(); | 397 SkScalar yDelta = cte.atlas()->getNormalizedTexelHeight(); |
| 403 rgbaYValues[3] = cte.atlas()->getYOffset(cte.atlasRow()) + SK_ScalarHalf
* yDelta; | 398 rgbaYValues[3] = cte.atlas()->getYOffset(cte.atlasRow()) + SK_ScalarHalf
* yDelta; |
| 404 rgbaYValues[0] = rgbaYValues[3] + yDelta; | 399 rgbaYValues[0] = rgbaYValues[3] + yDelta; |
| 405 rgbaYValues[1] = rgbaYValues[0] + yDelta; | 400 rgbaYValues[1] = rgbaYValues[0] + yDelta; |
| 406 rgbaYValues[2] = rgbaYValues[1] + yDelta; | 401 rgbaYValues[2] = rgbaYValues[1] + yDelta; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 fAtlas->unlockRow(fRow); | 495 fAtlas->unlockRow(fRow); |
| 501 } | 496 } |
| 502 } | 497 } |
| 503 | 498 |
| 504 void ColorTableEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 499 void ColorTableEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| 505 GrProcessorKeyBuilder* b) const { | 500 GrProcessorKeyBuilder* b) const { |
| 506 GLColorTableEffect::GenKey(*this, caps, b); | 501 GLColorTableEffect::GenKey(*this, caps, b); |
| 507 } | 502 } |
| 508 | 503 |
| 509 GrGLSLFragmentProcessor* ColorTableEffect::onCreateGLSLInstance() const { | 504 GrGLSLFragmentProcessor* ColorTableEffect::onCreateGLSLInstance() const { |
| 510 return new GLColorTableEffect(*this); | 505 return new GLColorTableEffect; |
| 511 } | 506 } |
| 512 | 507 |
| 513 bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const { | 508 bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 514 // For non-atlased instances, the texture (compared by base class) is suffic
ient to | 509 // For non-atlased instances, the texture (compared by base class) is suffic
ient to |
| 515 // differentiate different tables. For atlased instances we ensure they are
using the | 510 // differentiate different tables. For atlased instances we ensure they are
using the |
| 516 // same row. | 511 // same row. |
| 517 const ColorTableEffect& that = other.cast<ColorTableEffect>(); | 512 const ColorTableEffect& that = other.cast<ColorTableEffect>(); |
| 518 SkASSERT(SkToBool(fAtlas) == SkToBool(that.fAtlas)); | 513 SkASSERT(SkToBool(fAtlas) == SkToBool(that.fAtlas)); |
| 519 // Ok to always do this comparison since both would be -1 if non-atlased. | 514 // Ok to always do this comparison since both would be -1 if non-atlased. |
| 520 return fRow == that.fRow; | 515 return fRow == that.fRow; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 593 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
| 599 const uint8_t tableR[256], | 594 const uint8_t tableR[256], |
| 600 const uint8_t tableG[256], | 595 const uint8_t tableG[256], |
| 601 const uint8_t tableB[256]) { | 596 const uint8_t tableB[256]) { |
| 602 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); | 597 return new SkTable_ColorFilter(tableA, tableR, tableG, tableB); |
| 603 } | 598 } |
| 604 | 599 |
| 605 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 600 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
| 606 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 601 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
| 607 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 602 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |