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

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

Issue 1471053002: Don't create a GXPFactory when blend is SrcOver (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 5 years 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
OLDNEW
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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 690 }
691 691
692 /////////////////////////////////////////////////////////////////////////////// 692 ///////////////////////////////////////////////////////////////////////////////
693 693
694 GrPorterDuffXPFactory::GrPorterDuffXPFactory(SkXfermode::Mode xfermode) 694 GrPorterDuffXPFactory::GrPorterDuffXPFactory(SkXfermode::Mode xfermode)
695 : fXfermode(xfermode) { 695 : fXfermode(xfermode) {
696 SkASSERT(fXfermode <= SkXfermode::kLastCoeffMode); 696 SkASSERT(fXfermode <= SkXfermode::kLastCoeffMode);
697 this->initClassID<GrPorterDuffXPFactory>(); 697 this->initClassID<GrPorterDuffXPFactory>();
698 } 698 }
699 699
700 GrXPFactory* GrPorterDuffXPFactory::Create(SkXfermode::Mode xfermode) { 700 GrXPFactory* GrPorterDuffXPFactory::InternalCreate(SkXfermode::Mode xfermode) {
701 static GrPorterDuffXPFactory gClearPDXPF(SkXfermode::kClear_Mode); 701 static GrPorterDuffXPFactory gClearPDXPF(SkXfermode::kClear_Mode);
702 static GrPorterDuffXPFactory gSrcPDXPF(SkXfermode::kSrc_Mode); 702 static GrPorterDuffXPFactory gSrcPDXPF(SkXfermode::kSrc_Mode);
703 static GrPorterDuffXPFactory gDstPDXPF(SkXfermode::kDst_Mode); 703 static GrPorterDuffXPFactory gDstPDXPF(SkXfermode::kDst_Mode);
704 static GrPorterDuffXPFactory gSrcOverPDXPF(SkXfermode::kSrcOver_Mode); 704 static GrPorterDuffXPFactory gSrcOverPDXPF(SkXfermode::kSrcOver_Mode);
705 static GrPorterDuffXPFactory gDstOverPDXPF(SkXfermode::kDstOver_Mode); 705 static GrPorterDuffXPFactory gDstOverPDXPF(SkXfermode::kDstOver_Mode);
706 static GrPorterDuffXPFactory gSrcInPDXPF(SkXfermode::kSrcIn_Mode); 706 static GrPorterDuffXPFactory gSrcInPDXPF(SkXfermode::kSrcIn_Mode);
707 static GrPorterDuffXPFactory gDstInPDXPF(SkXfermode::kDstIn_Mode); 707 static GrPorterDuffXPFactory gDstInPDXPF(SkXfermode::kDstIn_Mode);
708 static GrPorterDuffXPFactory gSrcOutPDXPF(SkXfermode::kSrcOut_Mode); 708 static GrPorterDuffXPFactory gSrcOutPDXPF(SkXfermode::kSrcOut_Mode);
709 static GrPorterDuffXPFactory gDstOutPDXPF(SkXfermode::kDstOut_Mode); 709 static GrPorterDuffXPFactory gDstOutPDXPF(SkXfermode::kDstOut_Mode);
710 static GrPorterDuffXPFactory gSrcATopPDXPF(SkXfermode::kSrcATop_Mode); 710 static GrPorterDuffXPFactory gSrcATopPDXPF(SkXfermode::kSrcATop_Mode);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 int* outPrimary, 823 int* outPrimary,
824 int* outSecondary) { 824 int* outSecondary) {
825 if (!!strcmp(xp->name(), "Porter Duff")) { 825 if (!!strcmp(xp->name(), "Porter Duff")) {
826 *outPrimary = *outSecondary = -1; 826 *outPrimary = *outSecondary = -1;
827 return; 827 return;
828 } 828 }
829 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula(); 829 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula();
830 *outPrimary = blendFormula.fPrimaryOutputType; 830 *outPrimary = blendFormula.fPrimaryOutputType;
831 *outSecondary = blendFormula.fSecondaryOutputType; 831 *outSecondary = blendFormula.fSecondaryOutputType;
832 } 832 }
833
834
835 //////////////////////////////////////////////////////////////////////////////// ////////////////
836 // SrcOver Global functions
837 //////////////////////////////////////////////////////////////////////////////// ////////////////
838
839 GrXferProcessor* GrCreateSrcOverXferProcessor(const GrCaps& caps,
840 const GrProcOptInfo& colorPOI,
841 const GrProcOptInfo& covPOI,
842 bool hasMixedSamples,
843 const GrXferProcessor::DstTexture* dstTexture) {
844 BlendFormula blendFormula;
845 if (covPOI.isFourChannelOutput()) {
846 if (kRGBA_GrColorComponentFlags == colorPOI.validFlags() &&
847 !caps.shaderCaps()->dualSourceBlendingSupport() &&
848 !caps.shaderCaps()->dstReadInShaderSupport()) {
849 // If we don't have dual source blending or in shader dst reads, we fall
850 // back to this trick for rendering SrcOver LCD text instead of doin g a
851 // dst copy.
852 SkASSERT(!dstTexture || !dstTexture->texture());
853 return PDLCDXferProcessor::Create(SkXfermode::kSrcOver_Mode, colorPO I);
854 }
855 blendFormula = get_lcd_blend_formula(covPOI, SkXfermode::kSrcOver_Mode);
856 } else {
857 blendFormula = get_blend_formula(colorPOI, covPOI, hasMixedSamples,
858 SkXfermode::kSrcOver_Mode);
859 }
860
861 if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlend ingSupport()) {
862 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode ::kSrcOver_Mode);
863 }
864
865 SkASSERT(!dstTexture || !dstTexture->texture());
866 return new PorterDuffXferProcessor(blendFormula);
867 }
868
869 bool GrSrcOverWillNeedDstTexture(const GrCaps& caps,
870 const GrProcOptInfo& colorPOI,
871 const GrProcOptInfo& covPOI,
872 bool hasMixedSamples) {
873 if (caps.shaderCaps()->dstReadInShaderSupport() ||
874 caps.shaderCaps()->dualSourceBlendingSupport()) {
875 return false;
876 }
877
878 // When we have four channel coverage we always need to read the dst in orde r to correctly
879 // blend. The one exception is when we are using srcover mode and we know th e input color
880 // into the XP.
881 if (covPOI.isFourChannelOutput()) {
882 if (kRGBA_GrColorComponentFlags == colorPOI.validFlags() &&
883 !caps.shaderCaps()->dstReadInShaderSupport()) {
884 return false;
885 }
886 return get_lcd_blend_formula(covPOI, SkXfermode::kSrcOver_Mode).hasSecon daryOutput();
887 }
888 // We fallback on the shader XP when the blend formula would use dual source blending but we
889 // don't have support for it.
890 return get_blend_formula(colorPOI, covPOI,
891 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco ndaryOutput();
892 }
893
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698