LottieView::~LottieView()
{
+ if (mRenderTask.valid())
+ mRenderTask.get();
+
ecore_animator_del(mAnimator);
if (mVg) evas_object_del(mVg);
if (mImage) evas_object_del(mImage);
LOTBuffer buf;
evas_object_image_size_get(mImage, &buf.width, &buf.height);
if (mAsyncRender) {
+ if (mRenderTask.valid()) return;
mDirty = true;
mPendingPos = pos;
+ buf.buffer = (uint32_t *)evas_object_image_data_get(mImage, EINA_TRUE);
+ buf.bytesPerLine = evas_object_image_stride_get(mImage);
+ mRenderTask = mPlayer->render(mPendingPos, buf);
+ mBuffer = buf;
// to force a redraw
evas_object_image_data_update_add(mImage, 0 , 0, buf.width, buf.height);
} else {
mDirty = false;
if (mRenderMode) {
- LOTBuffer buf;
- buf.buffer = (uint32_t *)evas_object_image_data_get(mImage, EINA_TRUE);
- buf.bytesPerLine = evas_object_image_stride_get(mImage);
- evas_object_image_size_get(mImage, &buf.width, &buf.height);
- bool changed = mPlayer->renderSync(mPendingPos, buf);
- evas_object_image_data_set(mImage, buf.buffer);
+ if (!mBuffer.buffer) return;
+ bool changed = false;
+ if (mRenderTask.valid()) {
+ changed = mRenderTask.get();
+ }
+ evas_object_image_data_set(mImage, mBuffer.buffer);
// if the buffer is updated notify the image object
if (changed) {
- evas_object_image_data_update_add(mImage, 0 , 0, buf.width, buf.height);
+ evas_object_image_data_update_add(mImage, 0 , 0, mBuffer.width, mBuffer.height);
}
+ mBuffer.buffer = nullptr;
} else {
mPlayer->setPos(mPendingPos);
const std::vector<LOTNode *> &renderList = mPlayer->renderList();
}
void render() {
+ //auto clock = std::chrono::high_resolution_clock::now();
for (auto &i : mViews) {
i->render();
}
+ //double d = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now()-clock).count();
+ //printf("total time taken = %f\n", d);
}
public:
renderMode = false;
}
LottieViewTest *view = new LottieViewTest(app, renderMode);
- view->show(50);
+ view->show(400);
app->addExitCb(onExitCb, view);
app->addRenderPreCb(onRenderPreCb, view);