From e9c375cd3d9d761593adb511f018fe48aff1b757 Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Tue, 16 Apr 2019 19:19:43 +0000 Subject: [PATCH] Revert "Add GrDisableColorXPFactory::makeXferProcessor()" This reverts commit 11157ef97ae2c5bf844ed6b7f4cbda829f5f24af. Reason for revert: breaking bots Original change's description: > Add GrDisableColorXPFactory::makeXferProcessor() > > This allows us to access the actual XP for working directly with > pipelines. > > Bug: skia: > Change-Id: I71e7c2e9d69f464685e28b4f4a85847f0496b864 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/208345 > Commit-Queue: Chris Dalton > Reviewed-by: Greg Daniel TBR=egdaniel@google.com,csmartdalton@google.com Change-Id: Ia12f17d955702b13f33753b352cb3ae232881175 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/skia/+/208662 Reviewed-by: Greg Daniel Commit-Queue: Greg Daniel --- src/gpu/effects/GrDisableColorXP.cpp | 53 +++++++++++++++++++++------- src/gpu/effects/GrDisableColorXP.h | 38 +++++++++++--------- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/gpu/effects/GrDisableColorXP.cpp b/src/gpu/effects/GrDisableColorXP.cpp index 9f4ff53f4c..dfbf903842 100644 --- a/src/gpu/effects/GrDisableColorXP.cpp +++ b/src/gpu/effects/GrDisableColorXP.cpp @@ -19,23 +19,36 @@ */ class DisableColorXP : public GrXferProcessor { public: - DisableColorXP() : INHERITED(kDisableColorXP_ClassID) {} + DisableColorXP() + : INHERITED(kDisableColorXP_ClassID) {} + + const char* name() const override { return "Disable Color"; } + + GrGLSLXferProcessor* createGLSLInstance() const override; private: - const char* name() const override { return "Disable Color"; } - bool onIsEqual(const GrXferProcessor& xpBase) const override { return true; } - void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { - return; // No key. + + void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override; + + void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; + + bool onIsEqual(const GrXferProcessor& xpBase) const override { + return true; } - void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { - blendInfo->fWriteColor = false; - } - GrGLSLXferProcessor* createGLSLInstance() const override; typedef GrXferProcessor INHERITED; }; +/////////////////////////////////////////////////////////////////////////////// + class GLDisableColorXP : public GrGLSLXferProcessor { +public: + GLDisableColorXP(const GrProcessor&) {} + + ~GLDisableColorXP() override {} + + static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {} + private: void emitOutputsForBlendState(const EmitArgs& args) override { if (args.fShaderCaps->mustWriteToFragColor()) { @@ -59,12 +72,26 @@ private: typedef GrGLSLXferProcessor INHERITED; }; -GrGLSLXferProcessor* DisableColorXP::createGLSLInstance() const { - return new GLDisableColorXP(); +/////////////////////////////////////////////////////////////////////////////// + +void DisableColorXP::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { + GLDisableColorXP::GenKey(*this, caps, b); } -GrDisableColorXPFactory::GrDisableColorXPFactory() - : fXferProcessor(new DisableColorXP()) { +GrGLSLXferProcessor* DisableColorXP::createGLSLInstance() const { return new GLDisableColorXP(*this); } + +void DisableColorXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const { + blendInfo->fWriteColor = false; +} + +/////////////////////////////////////////////////////////////////////////////// +sk_sp GrDisableColorXPFactory::makeXferProcessor( + const GrProcessorAnalysisColor&, + GrProcessorAnalysisCoverage, + bool hasMixedSamples, + const GrCaps& caps, + GrClampType clampType) const { + return sk_sp(new DisableColorXP); } GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h index 41384c2f03..5e522645b7 100644 --- a/src/gpu/effects/GrDisableColorXP.h +++ b/src/gpu/effects/GrDisableColorXP.h @@ -23,30 +23,24 @@ #endif class GrDisableColorXPFactory : public GrXPFactory { public: - static const GrDisableColorXPFactory* Get() { - static const GrDisableColorXPFactory gDisableColorXPFactory; - return &gDisableColorXPFactory; - } - - sk_sp makeXferProcessor() const { return fXferProcessor; } + static const GrXPFactory* Get(); private: - GrDisableColorXPFactory(); + constexpr GrDisableColorXPFactory() {} - AnalysisProperties analysisProperties( - const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, const GrCaps&, - GrClampType) const override { + AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, + const GrProcessorAnalysisCoverage&, + const GrCaps&, + GrClampType) const override { return AnalysisProperties::kCompatibleWithCoverageAsAlpha | AnalysisProperties::kIgnoresInputColor; } - sk_sp makeXferProcessor( - const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, bool hasMixedSamples, - const GrCaps&, GrClampType) const override { - return this->makeXferProcessor(); - } - - const sk_sp fXferProcessor; + sk_sp makeXferProcessor(const GrProcessorAnalysisColor&, + GrProcessorAnalysisCoverage, + bool hasMixedSamples, + const GrCaps&, + GrClampType) const override; GR_DECLARE_XP_FACTORY_TEST @@ -59,4 +53,14 @@ private: #pragma clang diagnostic pop #endif +inline const GrXPFactory* GrDisableColorXPFactory::Get() { + // If this is constructed as static constexpr by cl.exe (2015 SP2) the vtable is null. +#ifdef SK_BUILD_FOR_WIN + static const GrDisableColorXPFactory gDisableColorXPFactory; +#else + static constexpr const GrDisableColorXPFactory gDisableColorXPFactory; +#endif + return &gDisableColorXPFactory; +} + #endif