diff options
author | Florin Malita <fmalita@chromium.org> | 2018-06-21 12:28:14 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-21 16:52:48 +0000 |
commit | 5361935cd07f2a5d52386eca59596493914eb15a (patch) | |
tree | 506e753d5ceecfa3ce9c3b8d266cf264176ffff1 /modules/skottie/src | |
parent | c110e7941e4e051ad9004412de7b419da8bcf270 (diff) |
[skottie] Simplify AttachMask
Minor cleanup: BindProperty reports whether a non-default property was
applied or bound for animation -- use this mechanism to detect
fully-opaque masks.
TBR=
Change-Id: I3bd9429842621309d0c6bd966ef748917e498c66
Reviewed-on: https://skia-review.googlesource.com/136623
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'modules/skottie/src')
-rw-r--r-- | modules/skottie/src/Skottie.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/skottie/src/Skottie.cpp b/modules/skottie/src/Skottie.cpp index a5b4bc8648..a4c796c869 100644 --- a/modules/skottie/src/Skottie.cpp +++ b/modules/skottie/src/Skottie.cpp @@ -971,7 +971,8 @@ sk_sp<sksg::RenderNode> AttachMask(const skjson::ArrayValue* jmask, SkSTArray<4, MaskRecord, true> mask_stack; - bool opaque_mask = true; + const SkScalar full_opacity = 100; + bool has_opacity = false; for (const skjson::ObjectValue* m : *jmask) { if (!m) continue; @@ -997,11 +998,10 @@ sk_sp<sksg::RenderNode> AttachMask(const skjson::ArrayValue* jmask, mask_paint->setAntiAlias(true); mask_paint->setBlendMode(MaskBlendMode(mode.c_str()[0])); - const auto animator_count = ctx->fAnimators.size(); - BindProperty<ScalarValue>((*m)["o"], &ctx->fAnimators, - [mask_paint](const ScalarValue& o) { mask_paint->setOpacity(o * 0.01f); }); - - opaque_mask &= (animator_count == ctx->fAnimators.size() && mask_paint->getOpacity() >= 1); + has_opacity |= BindProperty<ScalarValue>((*m)["o"], &ctx->fAnimators, + [mask_paint](const ScalarValue& o) { + mask_paint->setOpacity(o * 0.01f); + }, &full_opacity); mask_stack.push_back({mask_path, mask_paint}); } @@ -1009,8 +1009,8 @@ sk_sp<sksg::RenderNode> AttachMask(const skjson::ArrayValue* jmask, if (mask_stack.empty()) return childNode; - if (mask_stack.count() == 1 && opaque_mask) { - // Single opaque mask => clip path. + if (mask_stack.count() == 1 && !has_opacity) { + // Single, fully-opaque mask => clip path. return sksg::ClipEffect::Make(std::move(childNode), std::move(mask_stack.front().mask_path), true); |