Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: src/gpu/effects/GrCustomXfermode.cpp

Issue 1287023009: Added tree structure to GrGLFragmentProcessor, i.e. GL instances (Closed) Base URL: https://skia.googlesource.com/skia@cs3_isequal_nonrecursive
Patch Set: moved onSetData from public to protected, onCreateGLInstance from public to private in subclasses Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.cpp ('k') | src/gpu/effects/GrCustomXfermodePriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder (); 452 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder ();
453 const char* dstColor = "bgColor"; 453 const char* dstColor = "bgColor";
454 fsBuilder->codeAppendf("vec4 %s = ", dstColor); 454 fsBuilder->codeAppendf("vec4 %s = ", dstColor);
455 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_str( ), 455 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_str( ),
456 args.fCoords[0].getType()); 456 args.fCoords[0].getType());
457 fsBuilder->codeAppendf(";"); 457 fsBuilder->codeAppendf(";");
458 458
459 emit_custom_xfermode_code(mode, fsBuilder, args.fOutputColor, args.fInpu tColor, dstColor); 459 emit_custom_xfermode_code(mode, fsBuilder, args.fOutputColor, args.fInpu tColor, dstColor);
460 } 460 }
461 461
462 void setData(const GrGLProgramDataManager&, const GrProcessor&) override {}
463
464 static void GenKey(const GrFragmentProcessor& proc, const GrGLSLCaps&, GrPro cessorKeyBuilder* b) { 462 static void GenKey(const GrFragmentProcessor& proc, const GrGLSLCaps&, GrPro cessorKeyBuilder* b) {
465 // The background may come from the dst or from a texture. 463 // The background may come from the dst or from a texture.
466 uint32_t key = proc.numTextures(); 464 uint32_t key = proc.numTextures();
467 SkASSERT(key <= 1); 465 SkASSERT(key <= 1);
468 key |= proc.cast<GrCustomXferFP>().mode() << 1; 466 key |= proc.cast<GrCustomXferFP>().mode() << 1;
469 b->add32(key); 467 b->add32(key);
470 } 468 }
471 469
470 protected:
471 void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override { }
472
472 private: 473 private:
473 typedef GrGLFragmentProcessor INHERITED; 474 typedef GrGLFragmentProcessor INHERITED;
474 }; 475 };
475 476
476 /////////////////////////////////////////////////////////////////////////////// 477 ///////////////////////////////////////////////////////////////////////////////
477 478
478 GrCustomXferFP::GrCustomXferFP(GrProcessorDataManager*, SkXfermode::Mode mode, G rTexture* background) 479 GrCustomXferFP::GrCustomXferFP(GrProcessorDataManager*, SkXfermode::Mode mode, G rTexture* background)
479 : fMode(mode) { 480 : fMode(mode) {
480 this->initClassID<GrCustomXferFP>(); 481 this->initClassID<GrCustomXferFP>();
481 482
482 SkASSERT(background); 483 SkASSERT(background);
483 fBackgroundTransform.reset(kLocal_GrCoordSet, background, 484 fBackgroundTransform.reset(kLocal_GrCoordSet, background,
484 GrTextureParams::kNone_FilterMode); 485 GrTextureParams::kNone_FilterMode);
485 this->addCoordTransform(&fBackgroundTransform); 486 this->addCoordTransform(&fBackgroundTransform);
486 fBackgroundAccess.reset(background); 487 fBackgroundAccess.reset(background);
487 this->addTextureAccess(&fBackgroundAccess); 488 this->addTextureAccess(&fBackgroundAccess);
488 } 489 }
489 490
490 void GrCustomXferFP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB uilder* b) const { 491 void GrCustomXferFP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyB uilder* b) const {
491 GLCustomXferFP::GenKey(*this, caps, b); 492 GLCustomXferFP::GenKey(*this, caps, b);
492 } 493 }
493 494
494 GrGLFragmentProcessor* GrCustomXferFP::createGLInstance() const { 495 GrGLFragmentProcessor* GrCustomXferFP::onCreateGLInstance() const {
495 return SkNEW_ARGS(GLCustomXferFP, (*this)); 496 return SkNEW_ARGS(GLCustomXferFP, (*this));
496 } 497 }
497 498
498 bool GrCustomXferFP::onIsEqual(const GrFragmentProcessor& other) const { 499 bool GrCustomXferFP::onIsEqual(const GrFragmentProcessor& other) const {
499 const GrCustomXferFP& s = other.cast<GrCustomXferFP>(); 500 const GrCustomXferFP& s = other.cast<GrCustomXferFP>();
500 return fMode == s.fMode; 501 return fMode == s.fMode;
501 } 502 }
502 503
503 void GrCustomXferFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { 504 void GrCustomXferFP::onComputeInvariantOutput(GrInvariantOutput* inout) const {
504 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); 505 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 const char* outColor, const GrXferProcessor& pr oc) override { 619 const char* outColor, const GrXferProcessor& pr oc) override {
619 const CustomXP& xp = proc.cast<CustomXP>(); 620 const CustomXP& xp = proc.cast<CustomXP>();
620 SkASSERT(!xp.hasHWBlendEquation()); 621 SkASSERT(!xp.hasHWBlendEquation());
621 622
622 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); 623 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
623 emit_custom_xfermode_code(xp.mode(), fsBuilder, outColor, srcColor, dstC olor); 624 emit_custom_xfermode_code(xp.mode(), fsBuilder, outColor, srcColor, dstC olor);
624 } 625 }
625 626
626 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {} 627 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {}
627 628
628 typedef GrGLFragmentProcessor INHERITED; 629 typedef GrGLXferProcessor INHERITED;
629 }; 630 };
630 631
631 /////////////////////////////////////////////////////////////////////////////// 632 ///////////////////////////////////////////////////////////////////////////////
632 633
633 void CustomXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder * b) const { 634 void CustomXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder * b) const {
634 GLCustomXP::GenKey(*this, caps, b); 635 GLCustomXP::GenKey(*this, caps, b);
635 } 636 }
636 637
637 GrGLXferProcessor* CustomXP::createGLInstance() const { 638 GrGLXferProcessor* CustomXP::createGLInstance() const {
638 SkASSERT(this->willReadDstColor() != this->hasHWBlendEquation()); 639 SkASSERT(this->willReadDstColor() != this->hasHWBlendEquation());
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } 805 }
805 806
806 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); 807 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory);
807 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { 808 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) {
808 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, 809 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1,
809 SkXfermode::kLastSeparableMode); 810 SkXfermode::kLastSeparableMode);
810 811
811 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); 812 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode)));
812 } 813 }
813 814
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.cpp ('k') | src/gpu/effects/GrCustomXfermodePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698