Reland "Remove deprecated form of SkRuntimeEffect::Make."
This reverts commit e89b50ae054c08fc03ad5e7349d28c6a565e054b.
Reason for revert: landed Android fix at http://ag/13544365 (master) and
http://ag/13554983 (sc-dev)
Original change's description:
> Android roll broke with a compilation error:
> frameworks/base/libs/hwui/jni/Shader.cpp:243:37: error: no matching function for call to 'get'
> sk_sp<SkRuntimeEffect> effect = std::get<0>(result)
>
> Revert "Remove deprecated form of SkRuntimeEffect::Make."
>
> This reverts commit 1cda19436633c283561fe9a51f221ea9bf0ba2a3.
>
> Reason for revert: <INSERT REASONING HERE>
>
> Original change's description:
> > Remove deprecated form of SkRuntimeEffect::Make.
> >
> > Chromium has migrated to the new API at https://crrev.com/c/2675855.
> >
> > Change-Id: Id4af77db2c462348e8031d28f56e543ad619c19c
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367060
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: Brian Osman <brianosman@google.com>
> > Commit-Queue: John Stiles <johnstiles@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
>
> TBR=mtklein@google.com,brianosman@google.com,johnstiles@google.com
>
> Change-Id: Ie18f865f3b7f5b0263db1e52b19cf6faa0500fdd
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368616
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
TBR=mtklein@google.com,brianosman@google.com,stani@google.com,johnstiles@google.com
Change-Id: I9d679013cb275dc80aaaa977b7f1f4da31f36d1e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369037
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 7cbb66c..b845bb1 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -32,6 +32,7 @@
* Updated SkRuntimeEffect::Make() to take an Options struct. It also now returns a Results struct
instead of a tuple.
https://review.skia.org/363785
+ https://review.skia.org/367060
* Changed SkRuntimeEffect::Varying to have lower-case member names, with no 'f' prefix.
https://review.skia.org/365656
diff --git a/bench/ColorFilterBench.cpp b/bench/ColorFilterBench.cpp
index b94ab5e..d92331b 100644
--- a/bench/ColorFilterBench.cpp
+++ b/bench/ColorFilterBench.cpp
@@ -204,14 +204,14 @@
#if SK_SUPPORT_GPU
DEF_BENCH( return new ColorFilterBench("src_runtime", []() {
- static sk_sp<SkRuntimeEffect> gEffect = std::get<0>(
- SkRuntimeEffect::Make(SkString(RuntimeNone_GPU_SRC)));
+ static sk_sp<SkRuntimeEffect> gEffect =
+ SkRuntimeEffect::Make(SkString(RuntimeNone_GPU_SRC)).effect;
sk_sp<SkColorFilter> input = nullptr;
return gEffect->makeColorFilter(SkData::MakeEmpty(), &input, 1);
});)
DEF_BENCH( return new ColorFilterBench("matrix_runtime", []() {
- static sk_sp<SkRuntimeEffect> gEffect = std::get<0>(
- SkRuntimeEffect::Make(SkString(RuntimeColorMatrix_GPU_SRC)));
+ static sk_sp<SkRuntimeEffect> gEffect =
+ SkRuntimeEffect::Make(SkString(RuntimeColorMatrix_GPU_SRC)).effect;
sk_sp<SkColorFilter> input = nullptr;
return gEffect->makeColorFilter(SkData::MakeWithCopy(gColorMatrix, sizeof(gColorMatrix)),
&input, 1);
diff --git a/gm/fp_sample_chaining.cpp b/gm/fp_sample_chaining.cpp
index 5af0606..689aec9 100644
--- a/gm/fp_sample_chaining.cpp
+++ b/gm/fp_sample_chaining.cpp
@@ -316,10 +316,10 @@
SkBitmap bmp = make_test_bitmap();
sk_sp<SkRuntimeEffect> effects[4] = {
- std::get<0>(SkRuntimeEffect::Make(SkString(gConstantMatrixSkSL))),
- std::get<0>(SkRuntimeEffect::Make(SkString(gUniformMatrixSkSL))),
- std::get<0>(SkRuntimeEffect::Make(SkString(gVariableMatrixSkSL))),
- std::get<0>(SkRuntimeEffect::Make(SkString(gExplicitCoordSkSL))),
+ SkRuntimeEffect::Make(SkString(gConstantMatrixSkSL)).effect,
+ SkRuntimeEffect::Make(SkString(gUniformMatrixSkSL)).effect,
+ SkRuntimeEffect::Make(SkString(gVariableMatrixSkSL)).effect,
+ SkRuntimeEffect::Make(SkString(gExplicitCoordSkSL)).effect,
};
canvas->translate(10, 10);
diff --git a/gm/mixercolorfilter.cpp b/gm/mixercolorfilter.cpp
index 5d73024..f76b164 100644
--- a/gm/mixercolorfilter.cpp
+++ b/gm/mixercolorfilter.cpp
@@ -117,7 +117,7 @@
return mix(sample(cf0), sample(cf1), t);
}
)";
- effect = std::get<0>(SkRuntimeEffect::Make(SkString(sksl)));
+ effect = SkRuntimeEffect::Make(SkString(sksl)).effect;
SkASSERT(effect);
}
diff --git a/gm/runtimefunctions.cpp b/gm/runtimefunctions.cpp
index f8b7450..d4fbf16 100644
--- a/gm/runtimefunctions.cpp
+++ b/gm/runtimefunctions.cpp
@@ -39,7 +39,7 @@
void onDraw(SkCanvas* canvas) override {
sk_sp<SkRuntimeEffect> gEffect =
- std::get<0>(SkRuntimeEffect::Make(SkString(RUNTIME_FUNCTIONS_SRC)));
+ SkRuntimeEffect::Make(SkString(RUNTIME_FUNCTIONS_SRC)).effect;
SkASSERT(gEffect);
SkMatrix localM;
diff --git a/gm/runtimeshader.cpp b/gm/runtimeshader.cpp
index 719fbac..ac09a0a 100644
--- a/gm/runtimeshader.cpp
+++ b/gm/runtimeshader.cpp
@@ -356,7 +356,7 @@
surf->getCanvas()->drawLine(0, 0, 100, 100, p);
auto shader = surf->makeImageSnapshot()->makeShader(SkSamplingOptions(SkFilterMode::kLinear));
- SkRuntimeShaderBuilder builder(std::get<0>(SkRuntimeEffect::Make(SkString(scale))));
+ SkRuntimeShaderBuilder builder(SkRuntimeEffect::Make(SkString(scale)).effect);
builder.child("child") = shader;
p.setShader(builder.makeShader(nullptr, false));
diff --git a/gm/vertices.cpp b/gm/vertices.cpp
index 9aaf51a..d8d3a80 100644
--- a/gm/vertices.cpp
+++ b/gm/vertices.cpp
@@ -305,7 +305,7 @@
return vtx_color;
}
)";
- auto[effect, errorText] = SkRuntimeEffect::Make(SkString(gProg));
+ auto [effect, errorText] = SkRuntimeEffect::Make(SkString(gProg));
if (!effect) {
SK_ABORT("RuntimeEffect error: %s\n", errorText.c_str());
}
diff --git a/include/effects/SkRuntimeEffect.h b/include/effects/SkRuntimeEffect.h
index 08b3289..8093588 100644
--- a/include/effects/SkRuntimeEffect.h
+++ b/include/effects/SkRuntimeEffect.h
@@ -87,12 +87,9 @@
static Result Make(SkString sksl, const Options& options);
- // Older/deprecated version of the Make() API:
- using EffectResult = std::tuple<sk_sp<SkRuntimeEffect>, SkString>;
- static EffectResult Make(SkString sksl) {
- Result result = Make(sksl, Options{});
- return EffectResult{std::move(result.effect), std::move(result.errorText)};
- }
+ // 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 Make(SkString sksl) { return Make(std::move(sksl), Options{}); }
sk_sp<SkShader> makeShader(sk_sp<SkData> uniforms,
sk_sp<SkShader> children[],
diff --git a/modules/skottie/src/effects/BlackAndWhiteEffect.cpp b/modules/skottie/src/effects/BlackAndWhiteEffect.cpp
index b84232c..dd1f59e 100644
--- a/modules/skottie/src/effects/BlackAndWhiteEffect.cpp
+++ b/modules/skottie/src/effects/BlackAndWhiteEffect.cpp
@@ -64,7 +64,7 @@
)";
static const SkRuntimeEffect* effect =
- std::get<0>(SkRuntimeEffect::Make(SkString(BLACK_AND_WHITE_EFFECT))).release();
+ SkRuntimeEffect::Make(SkString(BLACK_AND_WHITE_EFFECT)).effect.release();
SkASSERT(effect);
return sk_ref_sp(effect);
diff --git a/modules/skottie/src/effects/BrightnessContrastEffect.cpp b/modules/skottie/src/effects/BrightnessContrastEffect.cpp
index 5acdb33..f0f870d 100644
--- a/modules/skottie/src/effects/BrightnessContrastEffect.cpp
+++ b/modules/skottie/src/effects/BrightnessContrastEffect.cpp
@@ -140,8 +140,8 @@
const AnimationBuilder& abuilder,
sk_sp<sksg::RenderNode> layer)
: INHERITED(sksg::ExternalColorFilter::Make(std::move(layer)))
- , fBrightnessEffect(std::get<0>(SkRuntimeEffect::Make(SkString(BRIGHTNESS_EFFECT))))
- , fContrastEffect(std::get<0>(SkRuntimeEffect::Make(SkString(CONTRAST_EFFECT)))) {
+ , fBrightnessEffect(SkRuntimeEffect::Make(SkString(BRIGHTNESS_EFFECT)).effect)
+ , fContrastEffect(SkRuntimeEffect::Make(SkString(CONTRAST_EFFECT)).effect) {
SkASSERT(fBrightnessEffect);
SkASSERT(fContrastEffect);
diff --git a/modules/skottie/src/effects/DisplacementMapEffect.cpp b/modules/skottie/src/effects/DisplacementMapEffect.cpp
index 94091d1..a3a244b 100644
--- a/modules/skottie/src/effects/DisplacementMapEffect.cpp
+++ b/modules/skottie/src/effects/DisplacementMapEffect.cpp
@@ -55,9 +55,9 @@
static sk_sp<SkRuntimeEffect> displacement_effect_singleton() {
static const SkRuntimeEffect* effect =
- std::get<0>(SkRuntimeEffect::Make(SkString(gDisplacementSkSL))).release();
+ SkRuntimeEffect::Make(SkString(gDisplacementSkSL)).effect.release();
if (0 && !effect) {
- auto err = std::get<1>(SkRuntimeEffect::Make(SkString(gDisplacementSkSL)));
+ auto err = SkRuntimeEffect::Make(SkString(gDisplacementSkSL)).errorText;
printf("!!! %s\n", err.c_str());
}
SkASSERT(effect);
diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp
index 960f475..fb13def 100644
--- a/src/core/SkRuntimeEffect.cpp
+++ b/src/core/SkRuntimeEffect.cpp
@@ -488,7 +488,7 @@
buffer.readString(&sksl);
sk_sp<SkData> uniforms = buffer.readByteArrayAsData();
- auto effect = std::get<0>(SkRuntimeEffect::Make(std::move(sksl)));
+ auto effect = SkRuntimeEffect::Make(std::move(sksl)).effect;
if (!buffer.validate(effect != nullptr)) {
return nullptr;
}
@@ -659,7 +659,7 @@
localMPtr = &localM;
}
- auto effect = std::get<0>(SkRuntimeEffect::Make(std::move(sksl)));
+ auto effect = SkRuntimeEffect::Make(std::move(sksl)).effect;
if (!buffer.validate(effect != nullptr)) {
return nullptr;
}
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index f364c53..8525e7e 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -131,7 +131,7 @@
: fReporter(r), fSurface(std::move(surface)) {}
void build(const char* src) {
- auto[effect, errorText] = SkRuntimeEffect::Make(SkString(src));
+ auto [effect, errorText] = SkRuntimeEffect::Make(SkString(src));
if (!effect) {
REPORT_FAILURE(fReporter, "effect",
SkStringPrintf("Effect didn't compile: %s", errorText.c_str()));
@@ -322,7 +322,7 @@
half4 main() { return half4(x); }
)";
- sk_sp<SkRuntimeEffect> effect = std::get<0>(SkRuntimeEffect::Make(SkString(kSource)));
+ sk_sp<SkRuntimeEffect> effect = SkRuntimeEffect::Make(SkString(kSource)).effect;
REPORTER_ASSERT(r, effect);
// Test passes if this sequence doesn't assert. skbug.com/10667
@@ -341,7 +341,7 @@
half4 main() { return half4(x); }
)";
- sk_sp<SkRuntimeEffect> effect = std::get<0>(SkRuntimeEffect::Make(SkString(kSource)));
+ sk_sp<SkRuntimeEffect> effect = SkRuntimeEffect::Make(SkString(kSource)).effect;
REPORTER_ASSERT(r, effect);
SkRuntimeShaderBuilder b(std::move(effect));