aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-11-23 13:20:41 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-23 13:20:42 -0800
commitc4b72720e75313079212e69e46a5ef7c474b2305 (patch)
treeb0bf74db86503bd22684bb3107613db4e6625244 /src/gpu/effects
parent60ce86d4718dab83f33488ec41710ad6763fc7f8 (diff)
Don't create a GXPFactory when blend is SrcOver
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp3
-rw-r--r--src/gpu/effects/GrCustomXfermode.cpp4
-rw-r--r--src/gpu/effects/GrDisableColorXP.h4
-rw-r--r--src/gpu/effects/GrPorterDuffXferProcessor.cpp62
4 files changed, 65 insertions, 8 deletions
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 2510b5c9d7..4df894b40a 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -223,6 +223,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
tempTex, false, *pmToUPMRule, SkMatrix::I()));
paint1.addColorFragmentProcessor(pmToUPM1);
+ paint1.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkAutoTUnref<GrDrawContext> readDrawContext(
@@ -241,6 +242,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
paint2.addColorFragmentProcessor(upmToPM);
+ paint2.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
SkAutoTUnref<GrDrawContext> tempDrawContext(
context->drawContext(tempTex->asRenderTarget()));
@@ -255,6 +257,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
kSrcRect);
paint3.addColorFragmentProcessor(pmToUPM2);
+ paint3.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
readDrawContext.reset(context->drawContext(readTex->asRenderTarget()));
if (!readDrawContext) {
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index 6b3a20ec2d..90ab030d24 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -321,10 +321,6 @@ class CustomXPFactory : public GrXPFactory {
public:
CustomXPFactory(SkXfermode::Mode mode);
- bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const override {
- return true;
- }
-
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
GrXPFactory::InvariantBlendedColor*) const override;
diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h
index caa0eecec8..a79dd9b971 100644
--- a/src/gpu/effects/GrDisableColorXP.h
+++ b/src/gpu/effects/GrDisableColorXP.h
@@ -17,10 +17,6 @@ class GrDisableColorXPFactory : public GrXPFactory {
public:
static GrXPFactory* Create() { return new GrDisableColorXPFactory; }
- bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const override {
- return true;
- }
-
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
GrXPFactory::InvariantBlendedColor* blendedColor) const override {
blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags;
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index 4245caafed..2323c67040 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -830,3 +830,65 @@ void GrPorterDuffXPFactory::TestGetXPOutputTypes(const GrXferProcessor* xp,
*outPrimary = blendFormula.fPrimaryOutputType;
*outSecondary = blendFormula.fSecondaryOutputType;
}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+// SrcOver Global functions
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
+ const GrCaps& caps,
+ const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& covPOI,
+ bool hasMixedSamples,
+ const GrXferProcessor::DstTexture* dstTexture) {
+ BlendFormula blendFormula;
+ if (covPOI.isFourChannelOutput()) {
+ if (kRGBA_GrColorComponentFlags == colorPOI.validFlags() &&
+ !caps.shaderCaps()->dualSourceBlendingSupport() &&
+ !caps.shaderCaps()->dstReadInShaderSupport()) {
+ // If we don't have dual source blending or in shader dst reads, we fall
+ // back to this trick for rendering SrcOver LCD text instead of doing a
+ // dst copy.
+ SkASSERT(!dstTexture || !dstTexture->texture());
+ return PDLCDXferProcessor::Create(SkXfermode::kSrcOver_Mode, colorPOI);
+ }
+ blendFormula = get_lcd_blend_formula(covPOI, SkXfermode::kSrcOver_Mode);
+ } else {
+ blendFormula = get_blend_formula(colorPOI, covPOI, hasMixedSamples,
+ SkXfermode::kSrcOver_Mode);
+ }
+
+ if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlendingSupport()) {
+ return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode::kSrcOver_Mode);
+ }
+
+ SkASSERT(!dstTexture || !dstTexture->texture());
+ return new PorterDuffXferProcessor(blendFormula);
+}
+
+bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps,
+ const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& covPOI,
+ bool hasMixedSamples) {
+ if (caps.shaderCaps()->dstReadInShaderSupport() ||
+ caps.shaderCaps()->dualSourceBlendingSupport()) {
+ return false;
+ }
+
+ // When we have four channel coverage we always need to read the dst in order to correctly
+ // blend. The one exception is when we are using srcover mode and we know the input color
+ // into the XP.
+ if (covPOI.isFourChannelOutput()) {
+ if (kRGBA_GrColorComponentFlags == colorPOI.validFlags() &&
+ !caps.shaderCaps()->dstReadInShaderSupport()) {
+ return false;
+ }
+ return get_lcd_blend_formula(covPOI, SkXfermode::kSrcOver_Mode).hasSecondaryOutput();
+ }
+ // We fallback on the shader XP when the blend formula would use dual source blending but we
+ // don't have support for it.
+ return get_blend_formula(colorPOI, covPOI,
+ hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSecondaryOutput();
+}
+