make SkShaderBase::onProgram pure virtual

This makes it easier to see which shaders do not have an SkVM
implementation (tricolor for drawVertices, perlin noise) and lets us
reserve the default onProgram() for other uses, like mutually recursive
F32/Half onProgram(), just as we've done previously for color filters.

I've marked both tricolor and perlin noise as "TODO?" rather than just a
simple "TODO", mostly because they're both intriguing to handle in other
ways, perhaps in externalizable SkSL.

Change-Id: I6ccd14a85dee1519b10d53ecbfc1074916954eca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/353319
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2021-01-13 13:53:05 -06:00 committed by Skia Commit-Bot
parent 57115c0f20
commit e7541d9b08
4 changed files with 21 additions and 10 deletions

View File

@ -16,6 +16,7 @@
#include "src/core/SkRasterClip.h" #include "src/core/SkRasterClip.h"
#include "src/core/SkRasterPipeline.h" #include "src/core/SkRasterPipeline.h"
#include "src/core/SkScan.h" #include "src/core/SkScan.h"
#include "src/core/SkVM.h"
#include "src/core/SkVertState.h" #include "src/core/SkVertState.h"
#include "src/core/SkVerticesPriv.h" #include "src/core/SkVerticesPriv.h"
#include "src/shaders/SkComposeShader.h" #include "src/shaders/SkComposeShader.h"
@ -147,6 +148,15 @@ protected:
return true; return true;
} }
skvm::Color onProgram(skvm::Builder*,
skvm::Coord, skvm::Coord, skvm::Color,
const SkMatrixProvider&, const SkMatrix*,
SkFilterQuality, const SkColorInfo&,
skvm::Uniforms*, SkArenaAlloc*) const override {
// TODO?
return {};
}
private: private:
bool isOpaque() const override { return fIsOpaque; } bool isOpaque() const override { return fIsOpaque; }
// For serialization. This will never be called. // For serialization. This will never be called.

View File

@ -16,6 +16,7 @@
#include "src/core/SkArenaAlloc.h" #include "src/core/SkArenaAlloc.h"
#include "src/core/SkMatrixProvider.h" #include "src/core/SkMatrixProvider.h"
#include "src/core/SkReadBuffer.h" #include "src/core/SkReadBuffer.h"
#include "src/core/SkVM.h"
#include "src/core/SkWriteBuffer.h" #include "src/core/SkWriteBuffer.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
@ -301,6 +302,15 @@ public:
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override; std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
#endif #endif
skvm::Color onProgram(skvm::Builder*,
skvm::Coord, skvm::Coord, skvm::Color,
const SkMatrixProvider&, const SkMatrix*,
SkFilterQuality, const SkColorInfo&,
skvm::Uniforms*, SkArenaAlloc*) const override {
// TODO?
return {};
}
protected: protected:
void flatten(SkWriteBuffer&) const override; void flatten(SkWriteBuffer&) const override;
#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT

View File

@ -238,15 +238,6 @@ skvm::Color SkShaderBase::program(skvm::Builder* p,
return {}; return {};
} }
skvm::Color SkShaderBase::onProgram(skvm::Builder*,
skvm::Coord device, skvm::Coord local, skvm::Color paint,
const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const {
// SkDebugf("cannot onProgram %s\n", this->getTypeName());
return {};
}
// need a cheap way to invert the alpha channel of a shader (i.e. 1 - a) // need a cheap way to invert the alpha channel of a shader (i.e. 1 - a)
sk_sp<SkShader> SkShaderBase::makeInvertAlpha() const { sk_sp<SkShader> SkShaderBase::makeInvertAlpha() const {
return this->makeWithColorFilter(SkColorFilters::Blend(0xFFFFFFFF, SkBlendMode::kSrcOut)); return this->makeWithColorFilter(SkColorFilters::Blend(0xFFFFFFFF, SkBlendMode::kSrcOut));

View File

@ -252,7 +252,7 @@ private:
skvm::Coord device, skvm::Coord local, skvm::Color paint, skvm::Coord device, skvm::Coord local, skvm::Color paint,
const SkMatrixProvider&, const SkMatrix* localM, const SkMatrixProvider&, const SkMatrix* localM,
SkFilterQuality quality, const SkColorInfo& dst, SkFilterQuality quality, const SkColorInfo& dst,
skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const; skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const = 0;
using INHERITED = SkShader; using INHERITED = SkShader;
}; };