From 7ac2e3bfefc2933245de47202bdd4684f5347f84 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Wed, 9 May 2018 14:54:39 -0400 Subject: [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 Commit-Queue: Florin Malita --- experimental/skottie/Skottie.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'experimental') 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 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(-1) == 100) { - // Ignoring static full opacity. - return childNode; - } - + static constexpr ScalarValue kNoopOpacity = 100; auto opacityNode = sksg::OpacityEffect::Make(childNode); - BindProperty(opacity, &ctx->fAnimators, + + if (!BindProperty(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); } -- cgit v1.2.3