2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "lottieview.h"
27 * To check the frame rate with rendermode off run
28 * ECORE_EVAS_FPS_DEBUG=1 ./lottieviewTest --disable-render
30 * To check the frame rate with render backend
31 * ECORE_EVAS_FPS_DEBUG=1 ./lottieviewTest
38 LottieViewTest(EvasApp *app, bool renderMode) {
40 mRenderMode = renderMode;
41 ecore_animator_frametime_set(1.0/120.0);
44 void show(int numberOfImage) {
45 auto resource = EvasApp::jsonFiles(std::string(DEMO_DIR));
47 if (resource.empty()) return;
49 int count = numberOfImage;
50 int colums = (int) ceil(sqrt(count));
52 int vw = (mApp->width() - (offset * colums))/colums;
56 int resourceSize = resource.size();
57 for (int i = 0 ; i < numberOfImage; i++) {
58 int index = i % resourceSize;
59 std::unique_ptr<LottieView> view(new LottieView(mApp->evas(), mRenderMode));
60 view->setFilePath(resource[index].c_str());
61 view->setPos(posx, posy);
62 view->setSize(vw, vh);
66 //view->setRepeatMode(LottieView::RepeatMode::Reverse);
69 if ((mApp->width() - posx) < vw) {
71 posy = posy + vh + offset;
73 mViews.push_back(std::move(view));
78 //auto clock = std::chrono::high_resolution_clock::now();
79 for (auto &i : mViews) {
82 //double d = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now()-clock).count();
83 //printf("total time taken = %f\n", d);
88 bool mRenderMode = false;
89 std::vector<std::unique_ptr<LottieView>> mViews;
93 onExitCb(void *data, void *extra)
95 LottieViewTest *view = (LottieViewTest *)data;
100 onRenderPreCb(void *data, void *extra)
102 LottieViewTest *view = (LottieViewTest *)data;
107 main(int argc, char **argv)
109 EvasApp *app = new EvasApp(800, 800);
112 bool renderMode = true;
114 if (!strcmp(argv[1],"--disable-render"))
117 LottieViewTest *view = new LottieViewTest(app, renderMode);
120 app->addExitCb(onExitCb, view);
121 app->addRenderPreCb(onRenderPreCb, view);