| OLD | NEW |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 1 | 7 |
| 2 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 3 #include "SkTableColorFilter.h" | 9 #include "SkTableColorFilter.h" |
| 4 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 5 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
| 6 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
| 7 #include "SkUnPreMultiply.h" | 13 #include "SkUnPreMultiply.h" |
| 8 #include "SkString.h" | 14 #include "SkString.h" |
| 9 | 15 |
| 10 class SkTable_ColorFilter : public SkColorFilter { | 16 class SkTable_ColorFilter : public SkColorFilter { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 #include "gl/builders/GrGLProgramBuilder.h" | 339 #include "gl/builders/GrGLProgramBuilder.h" |
| 334 | 340 |
| 335 class ColorTableEffect : public GrFragmentProcessor { | 341 class ColorTableEffect : public GrFragmentProcessor { |
| 336 public: | 342 public: |
| 337 static GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap, unsi
gned flags); | 343 static GrFragmentProcessor* Create(GrContext* context, SkBitmap bitmap, unsi
gned flags); |
| 338 | 344 |
| 339 virtual ~ColorTableEffect(); | 345 virtual ~ColorTableEffect(); |
| 340 | 346 |
| 341 const char* name() const override { return "ColorTable"; } | 347 const char* name() const override { return "ColorTable"; } |
| 342 | 348 |
| 343 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const overri
de; | 349 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; |
| 344 | 350 |
| 345 GrGLFragmentProcessor* createGLInstance() const override; | 351 GrGLFragmentProcessor* createGLInstance() const override; |
| 346 | 352 |
| 347 const GrTextureStripAtlas* atlas() const { return fAtlas; } | 353 const GrTextureStripAtlas* atlas() const { return fAtlas; } |
| 348 int atlasRow() const { return fRow; } | 354 int atlasRow() const { return fRow; } |
| 349 | 355 |
| 350 private: | 356 private: |
| 351 bool onIsEqual(const GrFragmentProcessor&) const override; | 357 bool onIsEqual(const GrFragmentProcessor&) const override; |
| 352 | 358 |
| 353 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 359 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 373 | 379 |
| 374 virtual void emitCode(GrGLFPBuilder*, | 380 virtual void emitCode(GrGLFPBuilder*, |
| 375 const GrFragmentProcessor&, | 381 const GrFragmentProcessor&, |
| 376 const char* outputColor, | 382 const char* outputColor, |
| 377 const char* inputColor, | 383 const char* inputColor, |
| 378 const TransformedCoordsArray&, | 384 const TransformedCoordsArray&, |
| 379 const TextureSamplerArray&) override; | 385 const TextureSamplerArray&) override; |
| 380 | 386 |
| 381 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; | 387 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; |
| 382 | 388 |
| 383 static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilde
r* b) {} | 389 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der* b) {} |
| 384 | 390 |
| 385 private: | 391 private: |
| 386 UniformHandle fRGBAYValuesUni; | 392 UniformHandle fRGBAYValuesUni; |
| 387 typedef GrGLFragmentProcessor INHERITED; | 393 typedef GrGLFragmentProcessor INHERITED; |
| 388 }; | 394 }; |
| 389 | 395 |
| 390 GLColorTableEffect::GLColorTableEffect(const GrProcessor&) { | 396 GLColorTableEffect::GLColorTableEffect(const GrProcessor&) { |
| 391 } | 397 } |
| 392 | 398 |
| 393 void GLColorTableEffect::setData(const GrGLProgramDataManager& pdm, const GrProc
essor& proc) { | 399 void GLColorTableEffect::setData(const GrGLProgramDataManager& pdm, const GrProc
essor& proc) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 this->initClassID<ColorTableEffect>(); | 500 this->initClassID<ColorTableEffect>(); |
| 495 this->addTextureAccess(&fTextureAccess); | 501 this->addTextureAccess(&fTextureAccess); |
| 496 } | 502 } |
| 497 | 503 |
| 498 ColorTableEffect::~ColorTableEffect() { | 504 ColorTableEffect::~ColorTableEffect() { |
| 499 if (fAtlas) { | 505 if (fAtlas) { |
| 500 fAtlas->unlockRow(fRow); | 506 fAtlas->unlockRow(fRow); |
| 501 } | 507 } |
| 502 } | 508 } |
| 503 | 509 |
| 504 void ColorTableEffect::getGLProcessorKey(const GrGLCaps& caps, | 510 void ColorTableEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
| 505 GrProcessorKeyBuilder* b) const { | 511 GrProcessorKeyBuilder* b) const { |
| 506 GLColorTableEffect::GenKey(*this, caps, b); | 512 GLColorTableEffect::GenKey(*this, caps, b); |
| 507 } | 513 } |
| 508 | 514 |
| 509 GrGLFragmentProcessor* ColorTableEffect::createGLInstance() const { | 515 GrGLFragmentProcessor* ColorTableEffect::createGLInstance() const { |
| 510 return SkNEW_ARGS(GLColorTableEffect, (*this)); | 516 return SkNEW_ARGS(GLColorTableEffect, (*this)); |
| 511 } | 517 } |
| 512 | 518 |
| 513 bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const { | 519 bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 514 // For non-atlased instances, the texture (compared by base class) is suffic
ient to | 520 // For non-atlased instances, the texture (compared by base class) is suffic
ient to |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], | 618 SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], |
| 613 const uint8_t tableR[256], | 619 const uint8_t tableR[256], |
| 614 const uint8_t tableG[256], | 620 const uint8_t tableG[256], |
| 615 const uint8_t tableB[256]) { | 621 const uint8_t tableB[256]) { |
| 616 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); | 622 return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); |
| 617 } | 623 } |
| 618 | 624 |
| 619 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) | 625 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) |
| 620 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) | 626 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) |
| 621 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 627 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |