mStatic = mPrecompLayer ? (mStatic & mPrecompLayer->isStatic()) : mStatic;
}
-void LOTLayerItem::update(int frameNo, const VMatrix &parentMatrix,
+void LOTLayerItem::update(int frameNumber, const VMatrix &parentMatrix,
float parentAlpha)
{
- mFrameNo = frameNo;
+ mFrameNo = mLayerData->timeRemap(frameNumber);
// 1. check if the layer is part of the current frame
if (!visible()) return;
// 2. calculate the parent matrix and alpha
- VMatrix m = matrix(frameNo);
+ VMatrix m = matrix(frameNo());
m *= parentMatrix;
- float alpha = parentAlpha * opacity(frameNo);
+ float alpha = parentAlpha * opacity(frameNo());
// 6. update the mask
if (hasMask()) {
- for (auto &i : mMasks) i->update(frameNo, m, alpha, mDirtyFlag);
+ for (auto &i : mMasks) i->update(frameNo(), m, alpha, mDirtyFlag);
}
// 3. update the dirty flag based on the change
int solidWidth() const noexcept{return mSolidLayer.mWidth;}
int solidHeight() const noexcept{return mSolidLayer.mHeight;}
LottieColor solidColor() const noexcept{return mSolidLayer.mColor;}
+ int timeRemap(int frameNo) const;
public:
struct SolidLayer {
int mWidth{0};
bool mHasGradient{false};
bool mRoot{false};
std::vector<std::shared_ptr<LOTMaskData>> mMasks;
+ LOTCompositionData *mCompRef;
};
class LOTCompositionData : public LOTData
return isStatic() ? startFrame() :
startFrame() + pos * frameDuration();
}
+ long frameAtTime(double timeInSec) const {
+ return isStatic() ? startFrame() : frameAtPos(timeInSec / duration());
+ }
long frameDuration() const {return mEndFrame - mStartFrame -1;}
float frameRate() const {return mFrameRate;}
long startFrame() const {return mStartFrame;}
};
+/**
+ * TimeRemap has the value in time domain(in sec)
+ * To get the proper mapping first we get the mapped time at the current frame Number
+ * then we need to convert mapped time to frame number using the composition time line
+ * Ex: at frame 10 the mappend time is 0.5(500 ms) which will be convert to frame number
+ * 30 if the frame rate is 60. or will result to frame number 15 if the frame rate is 30.
+ */
+inline int LOTLayerData::timeRemap(int frameNo) const
+{
+ return mTimeRemap.isStatic() ? frameNo :
+ mCompRef->frameAtTime(mTimeRemap.value(frameNo));
+}
+
class LOTTransformData : public LOTData
{
public: