Make GrRuntimeFPBuilder use stage-specific effect factories
Change-Id: If055fca832dc48212229e2ff9c714962bfa56a3e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402456 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
2b8fd2e8e0
commit
4cd134cc03
@ -203,11 +203,12 @@ void GrFragmentProcessor::cloneAndRegisterAllChildProcessors(const GrFragmentPro
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MakeColor(SkPMColor4f color) {
|
||||
// Use ColorFilter signature/factory to get the constant output for constant input optimization
|
||||
static constexpr char kCode[] = R"(
|
||||
uniform half4 color;
|
||||
half4 main() { return color; }
|
||||
half4 main(half4 inColor) { return color; }
|
||||
)";
|
||||
auto builder = GrRuntimeFPBuilder::Make<kCode>();
|
||||
auto builder = GrRuntimeFPBuilder::Make<kCode, SkRuntimeEffect::MakeForColorFilter>();
|
||||
builder.uniform("color") = color;
|
||||
return builder.makeFP();
|
||||
}
|
||||
|
@ -65,8 +65,10 @@ class GrRuntimeFPBuilder : public SkRuntimeEffectBuilder<std::unique_ptr<GrFragm
|
||||
public:
|
||||
~GrRuntimeFPBuilder();
|
||||
|
||||
template <const char* CODE> static GrRuntimeFPBuilder Make() {
|
||||
static const SkRuntimeEffect::Result gResult = SkRuntimeEffect::Make(SkString(CODE));
|
||||
// NOTE: We use a static variable as a cache. CODE and MAKE must remain template parameters.
|
||||
template <const char* CODE, SkRuntimeEffect::Result (*MAKE)(SkString sksl)>
|
||||
static GrRuntimeFPBuilder Make() {
|
||||
static const SkRuntimeEffect::Result gResult = MAKE(SkString(CODE));
|
||||
#ifdef SK_DEBUG
|
||||
if (!gResult.effect) {
|
||||
SK_ABORT("Code failed: %s", gResult.errorText.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user