| 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 "effects/GrCustomXfermode.h" | 8 #include "effects/GrCustomXfermode.h" |
| 9 #include "effects/GrCustomXfermodePriv.h" | 9 #include "effects/GrCustomXfermodePriv.h" |
| 10 | 10 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 default: | 424 default: |
| 425 SkFAIL("Unknown Custom Xfer mode."); | 425 SkFAIL("Unknown Custom Xfer mode."); |
| 426 break; | 426 break; |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 /////////////////////////////////////////////////////////////////////////////// | 430 /////////////////////////////////////////////////////////////////////////////// |
| 431 // Fragment Processor | 431 // Fragment Processor |
| 432 /////////////////////////////////////////////////////////////////////////////// | 432 /////////////////////////////////////////////////////////////////////////////// |
| 433 | 433 |
| 434 GrFragmentProcessor* GrCustomXfermode::CreateFP(GrShaderDataManager* shaderDataM
anager, | 434 GrFragmentProcessor* GrCustomXfermode::CreateFP(GrProcessorDataManager* procData
Manager, |
| 435 SkXfermode::Mode mode, GrTexture
* background) { | 435 SkXfermode::Mode mode, GrTexture
* background) { |
| 436 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 436 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
| 437 return NULL; | 437 return NULL; |
| 438 } else { | 438 } else { |
| 439 return SkNEW_ARGS(GrCustomXferFP, (shaderDataManager, mode, background))
; | 439 return SkNEW_ARGS(GrCustomXferFP, (procDataManager, mode, background)); |
| 440 } | 440 } |
| 441 } | 441 } |
| 442 | 442 |
| 443 /////////////////////////////////////////////////////////////////////////////// | 443 /////////////////////////////////////////////////////////////////////////////// |
| 444 | 444 |
| 445 class GLCustomXferFP : public GrGLFragmentProcessor { | 445 class GLCustomXferFP : public GrGLFragmentProcessor { |
| 446 public: | 446 public: |
| 447 GLCustomXferFP(const GrFragmentProcessor&) {} | 447 GLCustomXferFP(const GrFragmentProcessor&) {} |
| 448 ~GLCustomXferFP() override {}; | 448 ~GLCustomXferFP() override {}; |
| 449 | 449 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 472 key |= proc.cast<GrCustomXferFP>().mode() << 1; | 472 key |= proc.cast<GrCustomXferFP>().mode() << 1; |
| 473 b->add32(key); | 473 b->add32(key); |
| 474 } | 474 } |
| 475 | 475 |
| 476 private: | 476 private: |
| 477 typedef GrGLFragmentProcessor INHERITED; | 477 typedef GrGLFragmentProcessor INHERITED; |
| 478 }; | 478 }; |
| 479 | 479 |
| 480 /////////////////////////////////////////////////////////////////////////////// | 480 /////////////////////////////////////////////////////////////////////////////// |
| 481 | 481 |
| 482 GrCustomXferFP::GrCustomXferFP(GrShaderDataManager*, SkXfermode::Mode mode, GrTe
xture* background) | 482 GrCustomXferFP::GrCustomXferFP(GrProcessorDataManager*, SkXfermode::Mode mode, G
rTexture* background) |
| 483 : fMode(mode) { | 483 : fMode(mode) { |
| 484 this->initClassID<GrCustomXferFP>(); | 484 this->initClassID<GrCustomXferFP>(); |
| 485 | 485 |
| 486 SkASSERT(background); | 486 SkASSERT(background); |
| 487 fBackgroundTransform.reset(kLocal_GrCoordSet, background, | 487 fBackgroundTransform.reset(kLocal_GrCoordSet, background, |
| 488 GrTextureParams::kNone_FilterMode); | 488 GrTextureParams::kNone_FilterMode); |
| 489 this->addCoordTransform(&fBackgroundTransform); | 489 this->addCoordTransform(&fBackgroundTransform); |
| 490 fBackgroundAccess.reset(background); | 490 fBackgroundAccess.reset(background); |
| 491 this->addTextureAccess(&fBackgroundAccess); | 491 this->addTextureAccess(&fBackgroundAccess); |
| 492 } | 492 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 505 } | 505 } |
| 506 | 506 |
| 507 void GrCustomXferFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { | 507 void GrCustomXferFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { |
| 508 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 508 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
| 509 } | 509 } |
| 510 | 510 |
| 511 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCustomXferFP); | 511 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCustomXferFP); |
| 512 GrFragmentProcessor* GrCustomXferFP::TestCreate(GrProcessorTestData* d) { | 512 GrFragmentProcessor* GrCustomXferFP::TestCreate(GrProcessorTestData* d) { |
| 513 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode
::kLastSeparableMode); | 513 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode
::kLastSeparableMode); |
| 514 | 514 |
| 515 return SkNEW_ARGS(GrCustomXferFP, (d->fShaderDataManager, static_cast<SkXfer
mode::Mode>(mode), | 515 return SkNEW_ARGS(GrCustomXferFP, (d->fProcDataManager, static_cast<SkXfermo
de::Mode>(mode), |
| 516 d->fTextures[0])); | 516 d->fTextures[0])); |
| 517 } | 517 } |
| 518 | 518 |
| 519 /////////////////////////////////////////////////////////////////////////////// | 519 /////////////////////////////////////////////////////////////////////////////// |
| 520 // Xfer Processor | 520 // Xfer Processor |
| 521 /////////////////////////////////////////////////////////////////////////////// | 521 /////////////////////////////////////////////////////////////////////////////// |
| 522 | 522 |
| 523 class CustomXP : public GrXferProcessor { | 523 class CustomXP : public GrXferProcessor { |
| 524 public: | 524 public: |
| 525 CustomXP(SkXfermode::Mode mode, GrBlendEquation hwBlendEquation) | 525 CustomXP(SkXfermode::Mode mode, GrBlendEquation hwBlendEquation) |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 } | 813 } |
| 814 | 814 |
| 815 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); | 815 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); |
| 816 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { | 816 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { |
| 817 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, | 817 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, |
| 818 SkXfermode::kLastSeparableMode); | 818 SkXfermode::kLastSeparableMode); |
| 819 | 819 |
| 820 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); | 820 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); |
| 821 } | 821 } |
| 822 | 822 |
| OLD | NEW |