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 <csmartdalton@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Chris Dalton 2019-04-16 11:17:57 -06:00 committed by Skia Commit-Bot
parent 30182b482b
commit 11157ef97a
2 changed files with 30 additions and 61 deletions

View File

@ -19,36 +19,23 @@
*/ */
class DisableColorXP : public GrXferProcessor { class DisableColorXP : public GrXferProcessor {
public: public:
DisableColorXP() DisableColorXP() : INHERITED(kDisableColorXP_ClassID) {}
: INHERITED(kDisableColorXP_ClassID) {}
const char* name() const override { return "Disable Color"; }
GrGLSLXferProcessor* createGLSLInstance() const override;
private: private:
const char* name() const override { return "Disable Color"; }
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override; bool onIsEqual(const GrXferProcessor& xpBase) const override { return true; }
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; return; // No key.
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; typedef GrXferProcessor INHERITED;
}; };
///////////////////////////////////////////////////////////////////////////////
class GLDisableColorXP : public GrGLSLXferProcessor { class GLDisableColorXP : public GrGLSLXferProcessor {
public:
GLDisableColorXP(const GrProcessor&) {}
~GLDisableColorXP() override {}
static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {}
private: private:
void emitOutputsForBlendState(const EmitArgs& args) override { void emitOutputsForBlendState(const EmitArgs& args) override {
if (args.fShaderCaps->mustWriteToFragColor()) { if (args.fShaderCaps->mustWriteToFragColor()) {
@ -72,26 +59,12 @@ private:
typedef GrGLSLXferProcessor INHERITED; typedef GrGLSLXferProcessor INHERITED;
}; };
/////////////////////////////////////////////////////////////////////////////// GrGLSLXferProcessor* DisableColorXP::createGLSLInstance() const {
return new GLDisableColorXP();
void DisableColorXP::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
GLDisableColorXP::GenKey(*this, caps, b);
} }
GrGLSLXferProcessor* DisableColorXP::createGLSLInstance() const { return new GLDisableColorXP(*this); } GrDisableColorXPFactory::GrDisableColorXPFactory()
: fXferProcessor(new DisableColorXP()) {
void DisableColorXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const {
blendInfo->fWriteColor = false;
}
///////////////////////////////////////////////////////////////////////////////
sk_sp<const GrXferProcessor> GrDisableColorXPFactory::makeXferProcessor(
const GrProcessorAnalysisColor&,
GrProcessorAnalysisCoverage,
bool hasMixedSamples,
const GrCaps& caps,
GrClampType clampType) const {
return sk_sp<const GrXferProcessor>(new DisableColorXP);
} }
GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory); GR_DEFINE_XP_FACTORY_TEST(GrDisableColorXPFactory);

View File

@ -23,24 +23,30 @@
#endif #endif
class GrDisableColorXPFactory : public GrXPFactory { class GrDisableColorXPFactory : public GrXPFactory {
public: public:
static const GrXPFactory* Get(); static const GrDisableColorXPFactory* Get() {
static const GrDisableColorXPFactory gDisableColorXPFactory;
return &gDisableColorXPFactory;
}
sk_sp<const GrXferProcessor> makeXferProcessor() const { return fXferProcessor; }
private: private:
constexpr GrDisableColorXPFactory() {} GrDisableColorXPFactory();
AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, AnalysisProperties analysisProperties(
const GrProcessorAnalysisCoverage&, const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, const GrCaps&,
const GrCaps&, GrClampType) const override {
GrClampType) const override {
return AnalysisProperties::kCompatibleWithCoverageAsAlpha | return AnalysisProperties::kCompatibleWithCoverageAsAlpha |
AnalysisProperties::kIgnoresInputColor; AnalysisProperties::kIgnoresInputColor;
} }
sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&, sk_sp<const GrXferProcessor> makeXferProcessor(
GrProcessorAnalysisCoverage, const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, bool hasMixedSamples,
bool hasMixedSamples, const GrCaps&, GrClampType) const override {
const GrCaps&, return this->makeXferProcessor();
GrClampType) const override; }
const sk_sp<const GrXferProcessor> fXferProcessor;
GR_DECLARE_XP_FACTORY_TEST GR_DECLARE_XP_FACTORY_TEST
@ -53,14 +59,4 @@ private:
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #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 #endif