aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-01-20 19:06:29 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-20 20:04:01 +0000
commit5be6c95fa95a518ab109339df4695d6dda6e2419 (patch)
tree2ebd8ff44d7701764ece1e87d183009c07dfedb0 /src/gpu/effects
parentaaedae7acb609ac9c914ca435ed845f0139916c0 (diff)
Revert "Revert "Make it possible to query GrXPFactory for dst texture without GrPipelineAnalysis.""
This reverts commit 3329cceab5feca230df1caee16be045249228dc1. Reason for revert: Bot failures are unrelated to the original change. Change-Id: I21b5927dc4384a25930bdefe16e57bcc9276ffa4 Reviewed-on: https://skia-review.googlesource.com/7347 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrCustomXfermode.cpp22
-rw-r--r--src/gpu/effects/GrDisableColorXP.h6
-rw-r--r--src/gpu/effects/GrPorterDuffXferProcessor.cpp43
3 files changed, 36 insertions, 35 deletions
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index 070fa2ffe0..f8af7db8a0 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -54,15 +54,16 @@ static constexpr GrBlendEquation hw_blend_equation(SkBlendMode mode) {
}
static bool can_use_hw_blend_equation(GrBlendEquation equation,
- const GrPipelineAnalysis& analysis,
+ bool usePLSRead,
+ bool isLCDCoverage,
const GrCaps& caps) {
if (!caps.advancedBlendEquationSupport()) {
return false;
}
- if (analysis.fUsesPLSDstRead) {
+ if (usePLSRead) {
return false;
}
- if (analysis.fCoveragePOI.isLCDCoverage()) {
+ if (isLCDCoverage) {
return false; // LCD coverage must be applied after the blend equation.
}
if (caps.canUseAdvancedBlendEquation(equation)) {
@@ -340,8 +341,7 @@ private:
bool hasMixedSamples,
const DstTexture*) const override;
- bool onWillReadDstColor(const GrCaps&, const GrPipelineAnalysis&) const override;
-
+ bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override;
GR_DECLARE_XP_FACTORY_TEST;
@@ -359,16 +359,20 @@ GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps,
bool hasMixedSamples,
const DstTexture* dstTexture) const {
SkASSERT(GrCustomXfermode::IsSupportedMode(fMode));
- if (can_use_hw_blend_equation(fHWBlendEquation, analysis, caps)) {
+ if (can_use_hw_blend_equation(fHWBlendEquation, analysis.fUsesPLSDstRead,
+ analysis.fCoveragePOI.isLCDCoverage(), caps)) {
SkASSERT(!dstTexture || !dstTexture->texture());
return new CustomXP(fMode, fHWBlendEquation);
}
return new CustomXP(dstTexture, hasMixedSamples, fMode);
}
-bool CustomXPFactory::onWillReadDstColor(const GrCaps& caps,
- const GrPipelineAnalysis& analysis) const {
- return !can_use_hw_blend_equation(fHWBlendEquation, analysis, caps);
+bool CustomXPFactory::willReadDstColor(const GrCaps& caps, ColorType colorType,
+ CoverageType coverageType) const {
+ // This should not be called if we're using PLS dst read.
+ static constexpr bool kUsesPLSRead = false;
+ return !can_use_hw_blend_equation(fHWBlendEquation, kUsesPLSRead,
+ CoverageType::kLCD == coverageType, caps);
}
void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h
index 9f56ae5afe..f027e3c3bb 100644
--- a/src/gpu/effects/GrDisableColorXP.h
+++ b/src/gpu/effects/GrDisableColorXP.h
@@ -32,15 +32,13 @@ public:
private:
constexpr GrDisableColorXPFactory() {}
+ bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override { return false; }
+
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrPipelineAnalysis&,
bool hasMixedSamples,
const DstTexture* dstTexture) const override;
- bool onWillReadDstColor(const GrCaps&, const GrPipelineAnalysis&) const override {
- return false;
- }
-
GR_DECLARE_XP_FACTORY_TEST;
typedef GrXPFactory INHERITED;
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index 7f409065f4..59710ebfc0 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -320,21 +320,17 @@ static const BlendFormula gLCDBlendTable[(int)SkBlendMode::kLastCoeffMode + 1] =
/* screen */ COEFF_FORMULA( kOne_GrBlendCoeff, kISC_GrBlendCoeff),
};
-static BlendFormula get_blend_formula(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI,
+static BlendFormula get_blend_formula(bool isOpaque,
+ bool hasCoverage,
bool hasMixedSamples,
SkBlendMode xfermode) {
SkASSERT((unsigned)xfermode <= (unsigned)SkBlendMode::kLastCoeffMode);
- SkASSERT(!coveragePOI.isLCDCoverage());
-
- bool conflatesCoverage = !coveragePOI.isSolidWhite() || hasMixedSamples;
- return gBlendTable[colorPOI.isOpaque()][conflatesCoverage][(int)xfermode];
+ bool conflatesCoverage = hasCoverage || hasMixedSamples;
+ return gBlendTable[isOpaque][conflatesCoverage][(int)xfermode];
}
-static BlendFormula get_lcd_blend_formula(const GrProcOptInfo& coveragePOI,
- SkBlendMode xfermode) {
+static BlendFormula get_lcd_blend_formula(SkBlendMode xfermode) {
SkASSERT((unsigned)xfermode <= (unsigned)SkBlendMode::kLastCoeffMode);
- SkASSERT(coveragePOI.isLCDCoverage());
return gLCDBlendTable[(int)xfermode];
}
@@ -759,9 +755,10 @@ GrXferProcessor* GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps
SkASSERT(!dstTexture || !dstTexture->texture());
return PDLCDXferProcessor::Create(fBlendMode, analysis.fColorPOI);
}
- blendFormula = get_lcd_blend_formula(analysis.fCoveragePOI, fBlendMode);
+ blendFormula = get_lcd_blend_formula(fBlendMode);
} else {
- blendFormula = get_blend_formula(analysis.fColorPOI, analysis.fCoveragePOI, hasMixedSamples,
+ blendFormula = get_blend_formula(analysis.fColorPOI.isOpaque(),
+ !analysis.fCoveragePOI.isSolidWhite(), hasMixedSamples,
fBlendMode);
}
@@ -804,8 +801,8 @@ void GrPorterDuffXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorP
}
}
-bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps,
- const GrPipelineAnalysis& analysis) const {
+bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, ColorType colorType,
+ CoverageType coverageType) const {
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
return false;
}
@@ -813,20 +810,20 @@ bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps,
// 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 (analysis.fCoveragePOI.isLCDCoverage()) {
- if (SkBlendMode::kSrcOver == fBlendMode &&
- kRGBA_GrColorComponentFlags == analysis.fColorPOI.validFlags() &&
+ if (CoverageType::kLCD == coverageType) {
+ if (SkBlendMode::kSrcOver == fBlendMode && ColorTypeIsConstant(colorType) &&
!caps.shaderCaps()->dstReadInShaderSupport()) {
return false;
}
- return get_lcd_blend_formula(analysis.fCoveragePOI, fBlendMode).hasSecondaryOutput();
+ return get_lcd_blend_formula(fBlendMode).hasSecondaryOutput();
}
// We fallback on the shader XP when the blend formula would use dual source blending but we
// don't have support for it.
static const bool kHasMixedSamples = false;
SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without dual source blending.
- auto formula = get_blend_formula(analysis.fColorPOI, analysis.fCoveragePOI, kHasMixedSamples,
+ auto formula = get_blend_formula(ColorTypeIsOpaque(colorType),
+ CoverageType::kSingleChannel == coverageType, kHasMixedSamples,
fBlendMode);
return formula.hasSecondaryOutput();
}
@@ -893,7 +890,7 @@ GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
}
BlendFormula blendFormula;
- blendFormula = get_lcd_blend_formula(analysis.fCoveragePOI, SkBlendMode::kSrcOver);
+ blendFormula = get_lcd_blend_formula(SkBlendMode::kSrcOver);
if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlendingSupport()) {
return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkBlendMode::kSrcOver);
}
@@ -917,15 +914,17 @@ bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps,
!caps.shaderCaps()->dstReadInShaderSupport()) {
return false;
}
- auto formula = get_lcd_blend_formula(analysis.fCoveragePOI, SkBlendMode::kSrcOver);
+ auto formula = get_lcd_blend_formula(SkBlendMode::kSrcOver);
return formula.hasSecondaryOutput();
}
// We fallback on the shader XP when the blend formula would use dual source blending but we
// don't have support for it.
static const bool kHasMixedSamples = false;
+ bool isOpaque = analysis.fColorPOI.isOpaque();
+ bool hasCoverage = !analysis.fCoveragePOI.isSolidWhite();
SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without dual source blending.
- auto formula = get_blend_formula(analysis.fColorPOI, analysis.fCoveragePOI, kHasMixedSamples,
- SkBlendMode::kSrcOver);
+ auto formula =
+ get_blend_formula(isOpaque, hasCoverage, kHasMixedSamples, SkBlendMode::kSrcOver);
return formula.hasSecondaryOutput();
}