From b853ddc2906c17867ceeb10271f7d2c172c6b0a6 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Mon, 7 Jan 2019 14:07:02 +0900 Subject: [PATCH] lottie/vector: don't use startFrame() of a layer when it has time remap. Change-Id: I62230a2f5d9447bf7fa7ff3c9ebeed7aaa90dfa3 --- src/lottie/lottieitem.cpp | 5 ++--- src/lottie/lottiemodel.h | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lottie/lottieitem.cpp b/src/lottie/lottieitem.cpp index 11a6489..667142c 100644 --- a/src/lottie/lottieitem.cpp +++ b/src/lottie/lottieitem.cpp @@ -591,10 +591,9 @@ void LOTCompLayerItem::updateContent() if (mClipper && flag().testFlag(DirtyFlagBit::Matrix)) { mClipper->update(combinedMatrix()); } - + int mappedFrame = mLayerData->timeRemap(frameNo()); for (const auto &layer : mLayers) { - layer->update( mLayerData->timeRemap(frameNo()) - mLayerData->startFrame(), - combinedMatrix(), combinedAlpha()); + layer->update( mappedFrame, combinedMatrix(), combinedAlpha()); } } diff --git a/src/lottie/lottiemodel.h b/src/lottie/lottiemodel.h index 47faccf..16a75d5 100644 --- a/src/lottie/lottiemodel.h +++ b/src/lottie/lottiemodel.h @@ -441,7 +441,12 @@ public: */ inline int LOTLayerData::timeRemap(int frameNo) const { - frameNo = mTimeRemap.isStatic() ? frameNo : + /* + * only consider startFrame() when there is no timeRemap. + * when a layer has timeremap bodymovin updates the startFrame() + * of all child layer so we don't have to take care of it. + */ + frameNo = mTimeRemap.isStatic() ? frameNo - startFrame(): mCompRef->frameAtTime(mTimeRemap.value(frameNo)); /* Apply time streatch if it has any. * Time streatch is just a factor by which the animation will speedup or slow -- 2.7.4