OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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/GrPorterDuffXferProcessor.h" | 8 #include "effects/GrPorterDuffXferProcessor.h" |
9 | 9 |
10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 | 593 |
594 PDLCDXferProcessor::PDLCDXferProcessor(GrColor blendConstant, uint8_t alpha) | 594 PDLCDXferProcessor::PDLCDXferProcessor(GrColor blendConstant, uint8_t alpha) |
595 : fBlendConstant(blendConstant) | 595 : fBlendConstant(blendConstant) |
596 , fAlpha(alpha) { | 596 , fAlpha(alpha) { |
597 this->initClassID<PDLCDXferProcessor>(); | 597 this->initClassID<PDLCDXferProcessor>(); |
598 } | 598 } |
599 | 599 |
600 GrXferProcessor* PDLCDXferProcessor::Create(SkXfermode::Mode xfermode, | 600 GrXferProcessor* PDLCDXferProcessor::Create(SkXfermode::Mode xfermode, |
601 const GrProcOptInfo& colorPOI) { | 601 const GrProcOptInfo& colorPOI) { |
602 if (SkXfermode::kSrcOver_Mode != xfermode) { | 602 if (SkXfermode::kSrcOver_Mode != xfermode) { |
603 return NULL; | 603 return nullptr; |
604 } | 604 } |
605 | 605 |
606 if (kRGBA_GrColorComponentFlags != colorPOI.validFlags()) { | 606 if (kRGBA_GrColorComponentFlags != colorPOI.validFlags()) { |
607 return NULL; | 607 return nullptr; |
608 } | 608 } |
609 | 609 |
610 GrColor blendConstant = GrUnPreMulColor(colorPOI.color()); | 610 GrColor blendConstant = GrUnPreMulColor(colorPOI.color()); |
611 uint8_t alpha = GrColorUnpackA(blendConstant); | 611 uint8_t alpha = GrColorUnpackA(blendConstant); |
612 blendConstant |= (0xff << GrColor_SHIFT_A); | 612 blendConstant |= (0xff << GrColor_SHIFT_A); |
613 | 613 |
614 return new PDLCDXferProcessor(blendConstant, alpha); | 614 return new PDLCDXferProcessor(blendConstant, alpha); |
615 } | 615 } |
616 | 616 |
617 PDLCDXferProcessor::~PDLCDXferProcessor() { | 617 PDLCDXferProcessor::~PDLCDXferProcessor() { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 static GrPorterDuffXPFactory gScreenPDXPF(SkXfermode::kScreen_Mode); | 666 static GrPorterDuffXPFactory gScreenPDXPF(SkXfermode::kScreen_Mode); |
667 | 667 |
668 static GrPorterDuffXPFactory* gFactories[] = { | 668 static GrPorterDuffXPFactory* gFactories[] = { |
669 &gClearPDXPF, &gSrcPDXPF, &gDstPDXPF, &gSrcOverPDXPF, &gDstOverPDXPF, &g
SrcInPDXPF, | 669 &gClearPDXPF, &gSrcPDXPF, &gDstPDXPF, &gSrcOverPDXPF, &gDstOverPDXPF, &g
SrcInPDXPF, |
670 &gDstInPDXPF, &gSrcOutPDXPF, &gDstOutPDXPF, &gSrcATopPDXPF, &gDstATopPDX
PF, &gXorPDXPF, | 670 &gDstInPDXPF, &gSrcOutPDXPF, &gDstOutPDXPF, &gSrcATopPDXPF, &gDstATopPDX
PF, &gXorPDXPF, |
671 &gPlusPDXPF, &gModulatePDXPF, &gScreenPDXPF | 671 &gPlusPDXPF, &gModulatePDXPF, &gScreenPDXPF |
672 }; | 672 }; |
673 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFactories) == SkXfermode::kLastCoeffMode +
1); | 673 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFactories) == SkXfermode::kLastCoeffMode +
1); |
674 | 674 |
675 if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) { | 675 if (xfermode < 0 || xfermode > SkXfermode::kLastCoeffMode) { |
676 return NULL; | 676 return nullptr; |
677 } | 677 } |
678 return SkRef(gFactories[xfermode]); | 678 return SkRef(gFactories[xfermode]); |
679 } | 679 } |
680 | 680 |
681 GrXferProcessor* | 681 GrXferProcessor* |
682 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, | 682 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, |
683 const GrProcOptInfo& colorPOI, | 683 const GrProcOptInfo& colorPOI, |
684 const GrProcOptInfo& covPOI, | 684 const GrProcOptInfo& covPOI, |
685 bool hasMixedSamples, | 685 bool hasMixedSamples, |
686 const DstTexture* dstTexture) const
{ | 686 const DstTexture* dstTexture) const
{ |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 int* outPrimary, | 764 int* outPrimary, |
765 int* outSecondary) { | 765 int* outSecondary) { |
766 if (!!strcmp(xp->name(), "Porter Duff")) { | 766 if (!!strcmp(xp->name(), "Porter Duff")) { |
767 *outPrimary = *outSecondary = -1; | 767 *outPrimary = *outSecondary = -1; |
768 return; | 768 return; |
769 } | 769 } |
770 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); | 770 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); |
771 *outPrimary = blendFormula.fPrimaryOutputType; | 771 *outPrimary = blendFormula.fPrimaryOutputType; |
772 *outSecondary = blendFormula.fSecondaryOutputType; | 772 *outSecondary = blendFormula.fSecondaryOutputType; |
773 } | 773 } |
OLD | NEW |