From 1d638b192417fc3afac05edb4d46305d9e9ad9b3 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 3 Oct 2022 17:34:52 +0200 Subject: [PATCH] Squashed 'external/rlottie/' changes from 875626965..056c0a1bc 056c0a1bc example: lottieviewer - fixed frame no (#528) 12facb817 Fix one frame missing (#529) 30f300ddc Delete accidentally committed Vim swap file git-subtree-dir: external/rlottie git-subtree-split: 056c0a1bc14bcee6f6b1a821013872a1228b0fa9 --- example/lottieview.cpp | 1 - example/lottieviewer.cpp | 23 +++++++++++------------ src/binding/.lottieplayer.cpp.swp | Bin 12288 -> 0 bytes src/lottie/lottieitem.cpp | 2 +- src/lottie/lottiemodel.h | 4 ++-- src/lottie/lottieparser.cpp | 4 ++-- 6 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 src/binding/.lottieplayer.cpp.swp diff --git a/example/lottieview.cpp b/example/lottieview.cpp index d1fc9f26e..7fdf903bd 100644 --- a/example/lottieview.cpp +++ b/example/lottieview.cpp @@ -109,7 +109,6 @@ void LottieView::seek(float pos) { if (!mRenderDelegate) return; - mPos = mapProgress(pos); // check if the pos maps to the current frame diff --git a/example/lottieviewer.cpp b/example/lottieviewer.cpp index 8a09ea76f..d3d86f35b 100644 --- a/example/lottieviewer.cpp +++ b/example/lottieviewer.cpp @@ -62,12 +62,13 @@ _layout_del_cb(void *data, Evas *, Evas_Object *, void *) } static void -_update_frame_info(AppInfo *info, double pos) +_update_frame_info(AppInfo *info) { - int frameNo = pos * info->view->getTotalFrame(); - char buf[64]; + long currFrameNo = info->view->mCurFrame; + long totalFrameNo = info->view->getTotalFrame(); - sprintf(buf, "%d / %ld", frameNo, info->view->getTotalFrame()); + char buf[64]; + sprintf(buf, "%ld (total: %ld)", currFrameNo, totalFrameNo); elm_object_part_text_set(info->layout, "text", buf); } @@ -96,7 +97,7 @@ _animator_cb(void *data) if (info && info->autoPlaying && info->view) { float pos = info->view->getPos(); - _update_frame_info(info, pos); + _update_frame_info(info); elm_slider_value_set(info->slider, (double)pos); evas_object_image_pixels_dirty_set(info->view->getImage(), EINA_TRUE); if (pos >= 1.0) @@ -111,20 +112,20 @@ _slider_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) double val = elm_slider_value_get(obj); AppInfo *info = (AppInfo *)data; - _update_frame_info(info, val); - if (!info->autoPlaying) { info->view->seek(val); evas_object_image_pixels_dirty_set(info->view->getImage(), EINA_TRUE); } + + _update_frame_info(info); } static void _button_clicked_cb(void *data, Evas_Object */*obj*/, void */*event_info*/) { AppInfo *info = (AppInfo *)data; - + if (info->view->getPos() >= 1.0f) info->view->mPos = 0.0f; _toggle_start_button(info); } @@ -133,7 +134,6 @@ create_layout(Evas_Object *parent, const char *file) { Evas_Object *layout, *slider, *image, *button; Ecore_Animator *animator; - char buf[64]; AppInfo *info = (AppInfo *)calloc(sizeof(AppInfo), 1); //LAYOUT @@ -176,10 +176,9 @@ create_layout(Evas_Object *parent, const char *file) info->animator = animator; evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _layout_del_cb, (void *)info); - sprintf(buf, "%d / %ld", 0, view->getTotalFrame()); - elm_object_part_text_set(layout, "text", buf); - view->seek(0.0); + _update_frame_info(info); + return layout; } diff --git a/src/binding/.lottieplayer.cpp.swp b/src/binding/.lottieplayer.cpp.swp deleted file mode 100644 index e312a378e09c380c9279c04beb74d1bbdba214e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2OKcNI7{|ZR6VUJor(UW7gs_cYX;q2VG^c`u6i6gOgv7&gcE|BX&hB=1OrTN9 z<4kzoK_G5C!~p>p4jkcxs!AL|w5mWow8!?)s{ff;ZyYx^^w{=W>E~U0XTJHq-_BTx zJX7V#z5B$@VwrGkAbRoS_~Ds#XFoW%o~R+CS*i4m{)aCE-z$Vp|5ilb+JL3;D43Cs zic8A-M*8-(`dP7DY6ePqvJf_FCuLNMBd0Xw`L5?rCwJ_Pq7#Pi8jA0;0XEQSprz`C zorCo0C&Ol`Z{4z4Y#KV)*@Cax02^QfY=8~00XDz}*Z>>&j~h_o0G&dOtCBh=lk-5= zIeE(`Hoykh02^QfY=8~00XDz}*Z><~18m@5XrSg2eYBcraSf8k@Bi)p|KH;G|2NOW-0n1SUZR41tZ{ z_d%lHz|Y_<~18m@bX<(uAAR$B~RV(s^-RoHxiKOq!Xw-{UCJf^2Vb48rw1U64gjmoo zIFb(g4~~vj2=BeR$e@)N`Lb7#VvLQanQT_fn?Sn5W;Ks_M@&=|>`GZ{P3w zZaSdJLHAd>f10VyqMc2TVY{>@M*5_n$4`n`o`9B6b%K_!dZo}Iq(?ST)vx}-a6bX) z`+l{TZF$yDVZ=;=++1Gd8hzXshIQqhZzh55YP_4?J;u!ow9g5IHs?lH)!lhWbwJNY zH2dX4*x$Ys3USgHco+*Nsilwbcq@c@T2AMDjFC?g$gj=HIIKBR Zhs0)js|=C0dcM= mLayerData->inFrame() && - frameNo() < mLayerData->outFrame()); + frameNo() <= mLayerData->outFrame()); } void renderer::Layer::preprocess(const VRect &clip) diff --git a/src/lottie/lottiemodel.h b/src/lottie/lottiemodel.h index 3e0430853..745571e2c 100644 --- a/src/lottie/lottiemodel.h +++ b/src/lottie/lottiemodel.h @@ -539,8 +539,8 @@ public: { return long(frameAtPos(timeInSec / duration())); } - size_t totalFrame() const { return mEndFrame - mStartFrame; } - long frameDuration() const { return mEndFrame - mStartFrame - 1; } + size_t totalFrame() const { return mEndFrame - mStartFrame + 1; } + long frameDuration() const { return mEndFrame - mStartFrame; } float frameRate() const { return mFrameRate; } size_t startFrame() const { return mStartFrame; } size_t endFrame() const { return mEndFrame; } diff --git a/src/lottie/lottieparser.cpp b/src/lottie/lottieparser.cpp index 83be17e39..e14fd5c1c 100644 --- a/src/lottie/lottieparser.cpp +++ b/src/lottie/lottieparser.cpp @@ -665,9 +665,9 @@ void LottieParserImpl::parseComposition() } else if (0 == strcmp(key, "h")) { comp->mSize.setHeight(GetInt()); } else if (0 == strcmp(key, "ip")) { - comp->mStartFrame = GetDouble(); + comp->mStartFrame = std::lround(GetDouble()); } else if (0 == strcmp(key, "op")) { - comp->mEndFrame = GetDouble(); + comp->mEndFrame = std::lround(GetDouble()); } else if (0 == strcmp(key, "fr")) { comp->mFrameRate = GetDouble(); } else if (0 == strcmp(key, "assets")) {