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

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

Issue 900883002: Revert of Move DstCopy on gpu into the GrXferProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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/GrCoverageSetOpXP.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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 492 }
493 } 493 }
494 494
495 /////////////////////////////////////////////////////////////////////////////// 495 ///////////////////////////////////////////////////////////////////////////////
496 496
497 class GLCustomXP : public GrGLXferProcessor { 497 class GLCustomXP : public GrGLXferProcessor {
498 public: 498 public:
499 GLCustomXP(const GrXferProcessor&) {} 499 GLCustomXP(const GrXferProcessor&) {}
500 ~GLCustomXP() SK_OVERRIDE {} 500 ~GLCustomXP() SK_OVERRIDE {}
501 501
502 void emitCode(const EmitArgs& args) SK_OVERRIDE {
503 SkXfermode::Mode mode = args.fXP.cast<GrCustomXP>().mode();
504 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
505 const char* dstColor = fsBuilder->dstColor();
506
507 emit_custom_xfermode_code(mode, fsBuilder, args.fOutputPrimary, args.fIn putColor, dstColor);
508
509 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
510 args.fOutputPrimary, args.fOutputPrimary, args.fI nputCoverage,
511 args.fInputCoverage, dstColor);
512 }
513
514 void setData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVERR IDE {}
515
502 static void GenKey(const GrXferProcessor& proc, const GrGLCaps&, GrProcessor KeyBuilder* b) { 516 static void GenKey(const GrXferProcessor& proc, const GrGLCaps&, GrProcessor KeyBuilder* b) {
503 uint32_t key = proc.numTextures(); 517 uint32_t key = proc.numTextures();
504 SkASSERT(key <= 1); 518 SkASSERT(key <= 1);
505 key |= proc.cast<GrCustomXP>().mode() << 1; 519 key |= proc.cast<GrCustomXP>().mode() << 1;
506 b->add32(key); 520 b->add32(key);
507 } 521 }
508 522
509 private: 523 private:
510 void onEmitCode(const EmitArgs& args) SK_OVERRIDE {
511 SkXfermode::Mode mode = args.fXP.cast<GrCustomXP>().mode();
512 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
513 const char* dstColor = fsBuilder->dstColor();
514
515 emit_custom_xfermode_code(mode, fsBuilder, args.fOutputPrimary, args.fIn putColor, dstColor);
516
517 fsBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
518 args.fOutputPrimary, args.fOutputPrimary, args.fI nputCoverage,
519 args.fInputCoverage, dstColor);
520 }
521
522 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVE RRIDE {}
523
524 typedef GrGLFragmentProcessor INHERITED; 524 typedef GrGLFragmentProcessor INHERITED;
525 }; 525 };
526 526
527 /////////////////////////////////////////////////////////////////////////////// 527 ///////////////////////////////////////////////////////////////////////////////
528 528
529 GrCustomXP::GrCustomXP(SkXfermode::Mode mode, const GrDeviceCoordTexture* dstCop y, 529 GrCustomXP::GrCustomXP(SkXfermode::Mode mode)
530 bool willReadDstColor) 530 : fMode(mode) {
531 : INHERITED(dstCopy, willReadDstColor), fMode(mode) {
532 this->initClassID<GrCustomXP>(); 531 this->initClassID<GrCustomXP>();
532 this->setWillReadDstColor();
533 } 533 }
534 534
535 void GrCustomXP::onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder * b) const { 535 void GrCustomXP::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
536 GLCustomXP::GenKey(*this, caps, b); 536 GLCustomXP::GenKey(*this, caps, b);
537 } 537 }
538 538
539 GrGLXferProcessor* GrCustomXP::createGLInstance() const { 539 GrGLXferProcessor* GrCustomXP::createGLInstance() const {
540 return SkNEW_ARGS(GLCustomXP, (*this)); 540 return SkNEW_ARGS(GLCustomXP, (*this));
541 } 541 }
542 542
543 bool GrCustomXP::onIsEqual(const GrXferProcessor& other) const { 543 bool GrCustomXP::onIsEqual(const GrXferProcessor& other) const {
544 const GrCustomXP& s = other.cast<GrCustomXP>(); 544 const GrCustomXP& s = other.cast<GrCustomXP>();
545 return fMode == s.fMode; 545 return fMode == s.fMode;
(...skipping 24 matching lines...) Expand all
570 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); 570 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory);
571 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand, 571 GrXPFactory* GrCustomXPFactory::TestCreate(SkRandom* rand,
572 GrContext*, 572 GrContext*,
573 const GrDrawTargetCaps&, 573 const GrDrawTargetCaps&,
574 GrTexture*[]) { 574 GrTexture*[]) {
575 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas tSeparableMode); 575 int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLas tSeparableMode);
576 576
577 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); 577 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode)));
578 } 578 }
579 579
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCoverageSetOpXP.cpp ('k') | src/gpu/effects/GrCustomXfermodePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698