diff options
-rw-r--r-- | experimental/skottie/Skottie.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/experimental/skottie/Skottie.cpp b/experimental/skottie/Skottie.cpp index 0ac1b4ed71..381c9be422 100644 --- a/experimental/skottie/Skottie.cpp +++ b/experimental/skottie/Skottie.cpp @@ -124,21 +124,17 @@ sk_sp<sksg::RenderNode> AttachOpacity(const json::ValueRef& jtransform, AttachCo if (!jtransform.isObject() || !childNode) return childNode; - // This is more peeky than other attachers, because we want to avoid redundant opacity - // nodes for the extremely common case of static opaciy == 100. - const auto opacity = jtransform["o"]; - if (!opacity["a"].toDefault(true) && - opacity["k"].toDefault<int>(-1) == 100) { - // Ignoring static full opacity. - return childNode; - } - + static constexpr ScalarValue kNoopOpacity = 100; auto opacityNode = sksg::OpacityEffect::Make(childNode); - BindProperty<ScalarValue>(opacity, &ctx->fAnimators, + + if (!BindProperty<ScalarValue>(jtransform["o"], &ctx->fAnimators, [opacityNode](const ScalarValue& o) { // BM opacity is [0..100] opacityNode->setOpacity(o * 0.01f); - }); + }, &kNoopOpacity)) { + // We can ignore static full opacity. + return childNode; + } return std::move(opacityNode); } |