Make the generic SkRuntimeEffect::Make factories private
All clients have been moved to the stage-specific factories. The old
flexible factories are still used internally (for now), but this
prevents any new usage from creeping in accidentally.
Bug: skia:11813
Change-Id: I6c34dfd19b396541f9a0e2f9eab8a51591ed8b70
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402156
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index d549a30..8c9d93f 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -17,6 +17,11 @@
new Ganesh architecture both rely on full MSAA, and any platform where mixed samples is
supported will ultimately not use the old architecture.
+ * SkRuntimeEffect::Make has been removed. It is replaced by MakeForShader and MakeForColorFilter.
+ These functions do stricter error checking on the SkSL, to ensure it is valid for a particular
+ stage of the Skia pipeline.
+ https://review.skia.org/402156
+
* * *
Milestone 91
diff --git a/include/effects/SkRuntimeEffect.h b/include/effects/SkRuntimeEffect.h
index 40b2c2b..dc9c62e 100644
--- a/include/effects/SkRuntimeEffect.h
+++ b/include/effects/SkRuntimeEffect.h
@@ -102,10 +102,6 @@
// Most shaders don't use the input color, so that parameter is optional.
static Result MakeForShader(SkString sksl, const Options&);
- // [DEPRECATED] Make supports SkSL that is legal as either an SkShader or SkColorFilter.
- // makeColorFilter might return nullptr, if the effect is dependent on position in any way.
- static Result Make(SkString sksl, const Options&);
-
// We can't use a default argument for `options` due to a bug in Clang.
// https://bugs.llvm.org/show_bug.cgi?id=36684
static Result MakeForColorFilter(SkString sksl) {
@@ -114,9 +110,6 @@
static Result MakeForShader(SkString sksl) {
return MakeForShader(std::move(sksl), Options{});
}
- static Result Make(SkString sksl) {
- return Make(std::move(sksl), Options{});
- }
static Result MakeForColorFilter(std::unique_ptr<SkSL::Program> program);
@@ -182,6 +175,14 @@
#endif
private:
+ // For internal use: Make supports SkSL that is legal as either an SkShader or SkColorFilter.
+ // makeColorFilter might return nullptr, if the effect is dependent on position in any way.
+ static Result Make(SkString sksl, const Options&);
+
+ static Result Make(SkString sksl) {
+ return Make(std::move(sksl), Options{});
+ }
+
enum Flags {
kUsesSampleCoords_Flag = 0x1,
kAllowColorFilter_Flag = 0x2,
@@ -216,12 +217,14 @@
FilterColorInfo getFilterColorInfo();
#if SK_SUPPORT_GPU
- friend class GrSkSLFP; // fBaseProgram, fSampleUsages
- friend class GrGLSLSkSLFP; //
+ friend class GrSkSLFP; // fBaseProgram, fSampleUsages
+ friend class GrGLSLSkSLFP; //
+ friend class GrRuntimeFPBuilder; // Make
#endif
friend class SkRTShader; // fBaseProgram, fMain
friend class SkRuntimeColorFilter; //
+ friend sk_sp<SkRuntimeEffect> SkMakeCachedRuntimeEffect(SkString);
uint32_t fHash;
SkString fSkSL;
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index edb4733..47d5449 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -14,6 +14,7 @@
#include "include/effects/SkRuntimeEffect.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkColorSpacePriv.h"
+#include "src/core/SkRuntimeEffectPriv.h"
#include "src/core/SkTLazy.h"
#include "src/gpu/GrColor.h"
#include "src/gpu/GrFragmentProcessor.h"
@@ -76,7 +77,7 @@
DEF_TEST(SkRuntimeEffectInvalidColorFilters, r) {
auto test = [r](const char* sksl) {
- auto [effect, errorText] = SkRuntimeEffect::Make(SkString(sksl));
+ auto effect = SkMakeCachedRuntimeEffect(sksl);
REPORTER_ASSERT(r, effect);
sk_sp<SkData> uniforms = SkData::MakeUninitialized(effect->uniformSize());