[skottie] Cleanup: track animator scoping in AnimationBuilder
Instead of passing an explicit scope all over, keep track of the current
scope in AnimationBuilder.
Removes a bunch or redundant plumbing.
TBR=
Change-Id: I9e587f4ae7a1d12f86d13f30144816492a4ce147
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229762
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/modules/skottie/src/Composition.cpp b/modules/skottie/src/Composition.cpp
index f7209b9..3efad42 100644
--- a/modules/skottie/src/Composition.cpp
+++ b/modules/skottie/src/Composition.cpp
@@ -17,8 +17,7 @@
namespace skottie {
namespace internal {
-sk_sp<sksg::RenderNode> AnimationBuilder::attachNestedAnimation(const char* name,
- AnimatorScope* ascope) const {
+sk_sp<sksg::RenderNode> AnimationBuilder::attachNestedAnimation(const char* name) const {
class SkottieSGAdapter final : public sksg::RenderNode {
public:
explicit SkottieSGAdapter(sk_sp<Animation> animation)
@@ -79,16 +78,15 @@
return nullptr;
}
- ascope->push_back(sk_make_sp<SkottieAnimatorAdapter>(animation,
- animation->duration() / fDuration));
+ fCurrentAnimatorScope->push_back(
+ sk_make_sp<SkottieAnimatorAdapter>(animation, animation->duration() / fDuration));
return sk_make_sp<SkottieSGAdapter>(std::move(animation));
}
sk_sp<sksg::RenderNode> AnimationBuilder::attachAssetRef(
- const skjson::ObjectValue& jlayer, AnimatorScope* ascope,
- const std::function<sk_sp<sksg::RenderNode>(const skjson::ObjectValue&,
- AnimatorScope*)>& func) const {
+ const skjson::ObjectValue& jlayer,
+ const std::function<sk_sp<sksg::RenderNode>(const skjson::ObjectValue&)>& func) const {
const auto refId = ParseDefault<SkString>(jlayer["refId"], SkString());
if (refId.isEmpty()) {
@@ -97,7 +95,7 @@
}
if (refId.startsWith("$")) {
- return this->attachNestedAnimation(refId.c_str() + 1, ascope);
+ return this->attachNestedAnimation(refId.c_str() + 1);
}
const auto* asset_info = fAssets.find(refId);
@@ -113,14 +111,14 @@
}
asset_info->fIsAttaching = true;
- auto asset = func(*asset_info->fAsset, ascope);
+ auto asset = func(*asset_info->fAsset);
asset_info->fIsAttaching = false;
return asset;
}
-sk_sp<sksg::RenderNode> AnimationBuilder::attachComposition(const skjson::ObjectValue& jcomp,
- AnimatorScope* scope) const {
+sk_sp<sksg::RenderNode> AnimationBuilder::attachComposition(
+ const skjson::ObjectValue& jcomp) const {
const skjson::ArrayValue* jlayers = jcomp["layers"];
if (!jlayers) return nullptr;
@@ -138,7 +136,7 @@
layers.reserve(jlayers->size());
for (const auto& l : *jlayers) {
- if (auto layer = this->attachLayer(l, scope, &layerCtx)) {
+ if (auto layer = this->attachLayer(l, &layerCtx)) {
layers.push_back(std::move(layer));
}
}