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, Strategy st) {
43 void show(int numberOfImage) {
44 auto resource = EvasApp::jsonFiles(std::string(DEMO_DIR));
46 if (resource.empty()) return;
48 int count = numberOfImage;
49 int colums = (int) ceil(sqrt(count));
51 int vw = (mApp->width() - (offset * colums))/colums;
55 int resourceSize = resource.size();
56 for (int i = 0 ; i < numberOfImage; i++) {
57 int index = i % resourceSize;
58 std::unique_ptr<LottieView> view(new LottieView(mApp->evas(), mStrategy));
59 view->setFilePath(resource[index].c_str());
60 view->setPos(posx, posy);
61 view->setSize(vw, vh);
65 //view->setRepeatMode(LottieView::RepeatMode::Reverse);
68 if ((mApp->width() - posx) < vw) {
70 posy = posy + vh + offset;
72 mViews.push_back(std::move(view));
77 //auto clock = std::chrono::high_resolution_clock::now();
78 for (auto &i : mViews) {
81 //double d = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now()-clock).count();
82 //printf("total time taken = %f\n", d);
88 std::vector<std::unique_ptr<LottieView>> mViews;
92 onExitCb(void *data, void *extra)
94 LottieViewTest *view = (LottieViewTest *)data;
99 onRenderPreCb(void *data, void *extra)
101 LottieViewTest *view = (LottieViewTest *)data;
106 main(int argc, char **argv)
109 if (!strcmp(argv[1],"--help") || !strcmp(argv[1],"-h")) {
110 printf("Usage ./lottieviewTest 1 \n");
111 printf("\t 0 - Test Lottie SYNC Renderer with CPP API\n");
112 printf("\t 1 - Test Lottie ASYNC Renderer with CPP API\n");
113 printf("\t 2 - Test Lottie SYNC Renderer with C API\n");
114 printf("\t 3 - Test Lottie ASYNC Renderer with C API\n");
115 printf("\t 4 - Test Lottie Tree Api using Efl VG Render\n");
116 printf("\t Default is ./lottieviewTest 1 \n");
120 printf("Run ./lottieviewTest -h for more option\n");
123 EvasApp *app = new EvasApp(800, 800);
126 Strategy st = Strategy::renderCppAsync;
128 int option = atoi(argv[1]);
129 st = static_cast<Strategy>(option);
131 LottieViewTest *view = new LottieViewTest(app, st);
134 app->addExitCb(onExitCb, view);
135 app->addRenderPreCb(onRenderPreCb, view);