diff --git a/inc/thorvg.h b/inc/thorvg.h index f51b2c81..ed0e13c3 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1853,6 +1853,9 @@ public: * @retval Result::InsufficientCondition if the given @p no is the same as the current frame value. * @retval Result::NonSupport The current Picture data does not support animations. * + * @note For efficiency, ThorVG ignores updates to the new frame value if the difference from the current frame value + * is less than 0.001. In such cases, it returns @c Result::InsufficientCondition. + * * @see totalFrame() * */ diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index 8dcc9927..c92b61fc 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -2253,6 +2253,8 @@ TVG_API Tvg_Animation* tvg_animation_new(); * \retval TVG_RESULT_INSUFFICIENT_CONDITION No animatable data loaded from the Picture. * \retval TVG_RESULT_NOT_SUPPORTED The picture data does not support animations. * +* \note For efficiency, ThorVG ignores updates to the new frame value if the difference from the current frame value +* is less than 0.001. In such cases, it returns @c Result::InsufficientCondition. * \see tvg_animation_get_total_frame() */ TVG_API Tvg_Result tvg_animation_set_frame(Tvg_Animation* animation, float no); diff --git a/src/loaders/lottie/tvgLottieLoader.cpp b/src/loaders/lottie/tvgLottieLoader.cpp index 25b548b2..8d327663 100644 --- a/src/loaders/lottie/tvgLottieLoader.cpp +++ b/src/loaders/lottie/tvgLottieLoader.cpp @@ -315,11 +315,16 @@ bool LottieLoader::override(const char* slot) bool LottieLoader::frame(float no) { - //no meaing to update if frame diff is less then 1ms - if (fabsf(this->frameNo - no) < 0.001f) return false; + //Skip update if frame diff is too small. + if (fabsf(this->frameNo - no) < 0.0009f) return false; this->done(); + //This ensures that the perfect last frame is reached. + no *= 1000.0f; + no = roundf(no); + no *= 0.001f; + this->frameNo = no; TaskScheduler::request(this);