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>
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,
const GrCaps&,
const FragmentProcessorAnalysis&);
+ static bool CompatibleWithCoverageAsAlpha(const GrXPFactory*, bool colorIsOpaque);
+
protected:
constexpr GrXPFactory() {}
* 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
return false;
}
+ bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override { return false; }
+
GR_DECLARE_XP_FACTORY_TEST;
SkRegion::Op fRegionOp;
bool willReadDstInShader(const GrCaps&, const FragmentProcessorAnalysis&) const override;
+ bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override { return true; }
+
GR_DECLARE_XP_FACTORY_TEST;
SkBlendMode fMode;
return false;
}
+ bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override { return true; }
+
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const FragmentProcessorAnalysis&,
bool hasMixedSamples,
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
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() ||
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);
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);