From 911ae4066eb79f9a95a2d81e02d12c005b2db066 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Thu, 31 May 2018 16:45:29 -0400 Subject: [skottie] Remove inPoint/outPoint/frameRate from public API TBR= Change-Id: Ice4de3abe350c4570c22e859a36dbd445527fa41 Reviewed-on: https://skia-review.googlesource.com/131300 Reviewed-by: Florin Malita Commit-Queue: Florin Malita --- modules/skottie/src/Skottie.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'modules/skottie/src') diff --git a/modules/skottie/src/Skottie.cpp b/modules/skottie/src/Skottie.cpp index 250aa2e8d3..d2c2cceb5a 100644 --- a/modules/skottie/src/Skottie.cpp +++ b/modules/skottie/src/Skottie.cpp @@ -62,7 +62,7 @@ using AssetMap = SkTHashMap; struct AttachContext { const ResourceProvider& fResources; const AssetMap& fAssets; - const float fFrameRate; + const float fDuration; sksg::AnimatorList& fAnimators; }; @@ -724,21 +724,21 @@ sk_sp AttachNestedAnimation(const char* path, AttachContext* c class SkottieAnimatorAdapter final : public sksg::Animator { public: - SkottieAnimatorAdapter(sk_sp animation, float frameRate) + SkottieAnimatorAdapter(sk_sp animation, float time_scale) : fAnimation(std::move(animation)) - , fFrameRate(frameRate) { + , fTimeScale(time_scale) { SkASSERT(fAnimation); - SkASSERT(fFrameRate > 0); } protected: void onTick(float t) { - fAnimation->seek(t * fFrameRate / fAnimation->frameRate()); + // TODO: we prolly need more sophisticated timeline mapping for nested animations. + fAnimation->seek(t * fTimeScale); } private: const sk_sp fAnimation; - const float fFrameRate; + const float fTimeScale; }; const auto resStream = ctx->fResources.openStream(path); @@ -753,8 +753,10 @@ sk_sp AttachNestedAnimation(const char* path, AttachContext* c return nullptr; } - ctx->fAnimators.push_back(skstd::make_unique(animation, - ctx->fFrameRate)); + + ctx->fAnimators.push_back( + skstd::make_unique(animation, + animation->duration() / ctx->fDuration)); return sk_make_sp(std::move(animation)); } @@ -1051,7 +1053,7 @@ sk_sp AttachLayer(const json::ValueRef& jlayer, AttachLayerCon sksg::AnimatorList layer_animators; AttachContext local_ctx = { layerCtx->fCtx->fResources, layerCtx->fCtx->fAssets, - layerCtx->fCtx->fFrameRate, + layerCtx->fCtx->fDuration, layer_animators}; // Layer attachers may adjust these. @@ -1283,7 +1285,7 @@ Animation::Animation(const ResourceProvider& resources, } sksg::AnimatorList animators; - AttachContext ctx = { resources, assets, fFrameRate, animators }; + AttachContext ctx = { resources, assets, this->duration(), animators }; auto root = AttachComposition(json, &ctx); stats->fAnimatorCount = animators.size(); -- cgit v1.2.3