diff options
author | 2018-05-09 14:54:39 -0400 | |
---|---|---|
committer | 2018-05-09 19:23:31 +0000 | |
commit | 7ac2e3bfefc2933245de47202bdd4684f5347f84 (patch) | |
tree | 11ced319ddc3c2f0826497f43c7bb9b05e372454 /experimental | |
parent | eab50eb9c6117c2a9d0e5648f89cebbb4dbd9d30 (diff) |
[skottie] Simplify AttachOpacity
BindProperty can already check for no-op static props, so let's use it.
TBR=
Change-Id: If1c327871702b57ad9e6db9a8b112c6775cb7f53
Reviewed-on: https://skia-review.googlesource.com/127140
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental')
-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); } |