Add query to GrXPFactory about coverage-as-alpha optimization
This will be needed to have GrDrawOps that haven't yet built pipelines. Change-Id: If5292aaa5dc9f98dccbe27be98960b630332158d Reviewed-on: https://skia-review.googlesource.com/9480 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
4f7062378e
commit
780b41fc10
@ -197,6 +197,13 @@ bool GrXPFactory::WillNeedDstTexture(const GrXPFactory* factory, const GrCaps& c
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GrXPFactory::CompatibleWithCoverageAsAlpha(const GrXPFactory* factory, bool colorIsOpaque) {
|
||||
if (factory) {
|
||||
return factory->compatibleWithCoverageAsAlpha(colorIsOpaque);
|
||||
}
|
||||
return GrPorterDuffXPFactory::SrcOverIsCompatibleWithCoverageAsAlpha();
|
||||
}
|
||||
|
||||
GrXferProcessor* GrXPFactory::createXferProcessor(const FragmentProcessorAnalysis& analysis,
|
||||
bool hasMixedSamples,
|
||||
const DstTexture* dstTexture,
|
||||
|
@ -313,6 +313,8 @@ public:
|
||||
const GrCaps&,
|
||||
const FragmentProcessorAnalysis&);
|
||||
|
||||
static bool CompatibleWithCoverageAsAlpha(const GrXPFactory*, bool colorIsOpaque);
|
||||
|
||||
protected:
|
||||
constexpr GrXPFactory() {}
|
||||
|
||||
@ -330,6 +332,8 @@ private:
|
||||
* shader.
|
||||
*/
|
||||
virtual bool willReadDstInShader(const GrCaps&, const FragmentProcessorAnalysis&) const = 0;
|
||||
|
||||
virtual bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const = 0;
|
||||
};
|
||||
#if defined(__GNUC__) || defined(__clang)
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -45,6 +45,8 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override { return false; }
|
||||
|
||||
GR_DECLARE_XP_FACTORY_TEST;
|
||||
|
||||
SkRegion::Op fRegionOp;
|
||||
|
@ -331,6 +331,8 @@ private:
|
||||
|
||||
bool willReadDstInShader(const GrCaps&, const FragmentProcessorAnalysis&) const override;
|
||||
|
||||
bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override { return true; }
|
||||
|
||||
GR_DECLARE_XP_FACTORY_TEST;
|
||||
|
||||
SkBlendMode fMode;
|
||||
|
@ -32,6 +32,8 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override { return true; }
|
||||
|
||||
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
|
||||
const FragmentProcessorAnalysis&,
|
||||
bool hasMixedSamples,
|
||||
|
@ -791,6 +791,11 @@ bool GrPorterDuffXPFactory::willReadDstInShader(const GrCaps& caps,
|
||||
return formula.hasSecondaryOutput();
|
||||
}
|
||||
|
||||
bool GrPorterDuffXPFactory::compatibleWithCoverageAsAlpha(bool colorIsOpaque) const {
|
||||
// We assume we have coverage (or else this doesn't matter).
|
||||
return gBlendTable[colorIsOpaque][1][(int)fBlendMode].canTweakAlphaForCoverage();
|
||||
}
|
||||
|
||||
GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
@ -868,14 +873,6 @@ bool GrPorterDuffXPFactory::WillSrcOverReadDst(const FragmentProcessorAnalysis&
|
||||
return analysis.hasCoverage() || !analysis.isOutputColorOpaque();
|
||||
}
|
||||
|
||||
bool GrPorterDuffXPFactory::IsSrcOverPreCoverageBlendedColorConstant(
|
||||
const GrProcOptInfo& colorInput, GrColor* color) {
|
||||
if (!colorInput.isOpaque()) {
|
||||
return false;
|
||||
}
|
||||
return colorInput.hasKnownOutputColor(color);
|
||||
}
|
||||
|
||||
bool GrPorterDuffXPFactory::WillSrcOverNeedDstTexture(const GrCaps& caps,
|
||||
const FragmentProcessorAnalysis& analysis) {
|
||||
if (caps.shaderCaps()->dstReadInShaderSupport() ||
|
||||
|
@ -38,9 +38,8 @@ public:
|
||||
static const GrXferProcessor& SimpleSrcOverXP();
|
||||
|
||||
static bool WillSrcOverReadDst(const FragmentProcessorAnalysis& analysis);
|
||||
static bool IsSrcOverPreCoverageBlendedColorConstant(const GrProcOptInfo& colorInput,
|
||||
GrColor* color);
|
||||
static bool WillSrcOverNeedDstTexture(const GrCaps&, const FragmentProcessorAnalysis&);
|
||||
static bool SrcOverIsCompatibleWithCoverageAsAlpha() { return true; }
|
||||
|
||||
private:
|
||||
constexpr GrPorterDuffXPFactory(SkBlendMode);
|
||||
@ -54,6 +53,8 @@ private:
|
||||
|
||||
bool willReadDstInShader(const GrCaps&, const FragmentProcessorAnalysis&) const override;
|
||||
|
||||
bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override;
|
||||
|
||||
GR_DECLARE_XP_FACTORY_TEST;
|
||||
static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, int* outSecondary);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user