Revert "Make it possible to query GrXPFactory for dst texture without GrPipelineAnalysis."
This reverts commit f833215420847565b4c9945aebdc2e7ae182937f.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Make it possible to query GrXPFactory for dst texture without GrPipelineAnalysis.
>
> Change-Id: I8c140eb4e3e5f2d21ecbf8f8f3c8533dc7f50e7c
> Reviewed-on: https://skia-review.googlesource.com/7316
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I790afb9a01422cb4c2d3a4be4ecd20e8c4466b29
Reviewed-on: https://skia-review.googlesource.com/7342
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrXferProcessor.cpp b/src/gpu/GrXferProcessor.cpp
index d88259d..7de0d77 100644
--- a/src/gpu/GrXferProcessor.cpp
+++ b/src/gpu/GrXferProcessor.cpp
@@ -180,40 +180,6 @@
///////////////////////////////////////////////////////////////////////////////
-using ColorType = GrXPFactory::ColorType;
-using CoverageType = GrXPFactory::CoverageType;
-
-ColorType analysis_color_type(const GrPipelineAnalysis& analysis) {
- if (analysis.fColorPOI.validFlags() == kRGBA_GrColorComponentFlags) {
- return GrColorIsOpaque(analysis.fColorPOI.color()) ? ColorType::kOpaqueConstant
- : ColorType::kConstant;
- }
- if ((analysis.fColorPOI.validFlags() & kA_GrColorComponentFlag) &&
- GrColorIsOpaque(analysis.fColorPOI.color())) {
- return ColorType::kOpaque;
- }
- return ColorType::kUnknown;
-}
-
-CoverageType analysis_coverage_type(const GrPipelineAnalysis& analysis) {
- if (analysis.fCoveragePOI.isSolidWhite()) {
- return CoverageType::kNone;
- }
- if (analysis.fCoveragePOI.isLCDCoverage()) {
- return CoverageType::kLCD;
- }
- return CoverageType::kSingleChannel;
-}
-
-bool GrXPFactory::willReadDstColor(const GrCaps& caps, const GrPipelineAnalysis& analysis) const {
- if (analysis.fUsesPLSDstRead) {
- return true;
- }
- ColorType colorType = analysis_color_type(analysis);
- CoverageType coverageType = analysis_coverage_type(analysis);
- return this->willReadDstColor(caps, colorType, coverageType);
-}
-
GrXferProcessor* GrXPFactory::createXferProcessor(const GrPipelineAnalysis& analysis,
bool hasMixedSamples,
const DstTexture* dstTexture,
@@ -234,6 +200,9 @@
}
bool GrXPFactory::willNeedDstTexture(const GrCaps& caps, const GrPipelineAnalysis& analysis) const {
- return !analysis.fUsesPLSDstRead && !caps.shaderCaps()->dstReadInShaderSupport() &&
- this->willReadDstColor(caps, analysis);
+ return (this->willReadDstColor(caps, analysis) && !caps.shaderCaps()->dstReadInShaderSupport());
+}
+
+bool GrXPFactory::willReadDstColor(const GrCaps& caps, const GrPipelineAnalysis& analysis) const {
+ return analysis.fUsesPLSDstRead || this->onWillReadDstColor(caps, analysis);
}
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index f8af7db..070fa2f 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -54,16 +54,15 @@
}
static bool can_use_hw_blend_equation(GrBlendEquation equation,
- bool usePLSRead,
- bool isLCDCoverage,
+ const GrPipelineAnalysis& analysis,
const GrCaps& caps) {
if (!caps.advancedBlendEquationSupport()) {
return false;
}
- if (usePLSRead) {
+ if (analysis.fUsesPLSDstRead) {
return false;
}
- if (isLCDCoverage) {
+ if (analysis.fCoveragePOI.isLCDCoverage()) {
return false; // LCD coverage must be applied after the blend equation.
}
if (caps.canUseAdvancedBlendEquation(equation)) {
@@ -341,7 +340,8 @@
bool hasMixedSamples,
const DstTexture*) const override;
- bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override;
+ bool onWillReadDstColor(const GrCaps&, const GrPipelineAnalysis&) const override;
+
GR_DECLARE_XP_FACTORY_TEST;
@@ -359,20 +359,16 @@
bool hasMixedSamples,
const DstTexture* dstTexture) const {
SkASSERT(GrCustomXfermode::IsSupportedMode(fMode));
- if (can_use_hw_blend_equation(fHWBlendEquation, analysis.fUsesPLSDstRead,
- analysis.fCoveragePOI.isLCDCoverage(), caps)) {
+ if (can_use_hw_blend_equation(fHWBlendEquation, analysis, caps)) {
SkASSERT(!dstTexture || !dstTexture->texture());
return new CustomXP(fMode, fHWBlendEquation);
}
return new CustomXP(dstTexture, hasMixedSamples, fMode);
}
-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);
+bool CustomXPFactory::onWillReadDstColor(const GrCaps& caps,
+ const GrPipelineAnalysis& analysis) const {
+ return !can_use_hw_blend_equation(fHWBlendEquation, analysis, caps);
}
void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h
index f027e3c..9f56ae5 100644
--- a/src/gpu/effects/GrDisableColorXP.h
+++ b/src/gpu/effects/GrDisableColorXP.h
@@ -32,13 +32,15 @@
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 59710eb..7f40906 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -320,17 +320,21 @@
/* screen */ COEFF_FORMULA( kOne_GrBlendCoeff, kISC_GrBlendCoeff),
};
-static BlendFormula get_blend_formula(bool isOpaque,
- bool hasCoverage,
+static BlendFormula get_blend_formula(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
bool hasMixedSamples,
SkBlendMode xfermode) {
SkASSERT((unsigned)xfermode <= (unsigned)SkBlendMode::kLastCoeffMode);
- bool conflatesCoverage = hasCoverage || hasMixedSamples;
- return gBlendTable[isOpaque][conflatesCoverage][(int)xfermode];
+ SkASSERT(!coveragePOI.isLCDCoverage());
+
+ bool conflatesCoverage = !coveragePOI.isSolidWhite() || hasMixedSamples;
+ return gBlendTable[colorPOI.isOpaque()][conflatesCoverage][(int)xfermode];
}
-static BlendFormula get_lcd_blend_formula(SkBlendMode xfermode) {
+static BlendFormula get_lcd_blend_formula(const GrProcOptInfo& coveragePOI,
+ SkBlendMode xfermode) {
SkASSERT((unsigned)xfermode <= (unsigned)SkBlendMode::kLastCoeffMode);
+ SkASSERT(coveragePOI.isLCDCoverage());
return gLCDBlendTable[(int)xfermode];
}
@@ -755,10 +759,9 @@
SkASSERT(!dstTexture || !dstTexture->texture());
return PDLCDXferProcessor::Create(fBlendMode, analysis.fColorPOI);
}
- blendFormula = get_lcd_blend_formula(fBlendMode);
+ blendFormula = get_lcd_blend_formula(analysis.fCoveragePOI, fBlendMode);
} else {
- blendFormula = get_blend_formula(analysis.fColorPOI.isOpaque(),
- !analysis.fCoveragePOI.isSolidWhite(), hasMixedSamples,
+ blendFormula = get_blend_formula(analysis.fColorPOI, analysis.fCoveragePOI, hasMixedSamples,
fBlendMode);
}
@@ -801,8 +804,8 @@
}
}
-bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, ColorType colorType,
- CoverageType coverageType) const {
+bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps,
+ const GrPipelineAnalysis& analysis) const {
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
return false;
}
@@ -810,20 +813,20 @@
// 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 (CoverageType::kLCD == coverageType) {
- if (SkBlendMode::kSrcOver == fBlendMode && ColorTypeIsConstant(colorType) &&
+ if (analysis.fCoveragePOI.isLCDCoverage()) {
+ if (SkBlendMode::kSrcOver == fBlendMode &&
+ kRGBA_GrColorComponentFlags == analysis.fColorPOI.validFlags() &&
!caps.shaderCaps()->dstReadInShaderSupport()) {
return false;
}
- return get_lcd_blend_formula(fBlendMode).hasSecondaryOutput();
+ return get_lcd_blend_formula(analysis.fCoveragePOI, 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(ColorTypeIsOpaque(colorType),
- CoverageType::kSingleChannel == coverageType, kHasMixedSamples,
+ auto formula = get_blend_formula(analysis.fColorPOI, analysis.fCoveragePOI, kHasMixedSamples,
fBlendMode);
return formula.hasSecondaryOutput();
}
@@ -890,7 +893,7 @@
}
BlendFormula blendFormula;
- blendFormula = get_lcd_blend_formula(SkBlendMode::kSrcOver);
+ blendFormula = get_lcd_blend_formula(analysis.fCoveragePOI, SkBlendMode::kSrcOver);
if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlendingSupport()) {
return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkBlendMode::kSrcOver);
}
@@ -914,17 +917,15 @@
!caps.shaderCaps()->dstReadInShaderSupport()) {
return false;
}
- auto formula = get_lcd_blend_formula(SkBlendMode::kSrcOver);
+ auto formula = get_lcd_blend_formula(analysis.fCoveragePOI, 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(isOpaque, hasCoverage, kHasMixedSamples, SkBlendMode::kSrcOver);
+ auto formula = get_blend_formula(analysis.fColorPOI, analysis.fCoveragePOI, kHasMixedSamples,
+ SkBlendMode::kSrcOver);
return formula.hasSecondaryOutput();
}