2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the LGPL License, Version 2.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * https://www.gnu.org/licenses/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "lottieview.h"
25 * To check the frame rate with rendermode off run
26 * ECORE_EVAS_FPS_DEBUG=1 ./lottieviewTest --disable-render
28 * To check the frame rate with render backend
29 * ECORE_EVAS_FPS_DEBUG=1 ./lottieviewTest
36 LottieViewTest(EvasApp *app, bool renderMode) {
38 mRenderMode = renderMode;
39 ecore_animator_frametime_set(1.0/120.0);
42 void show(int numberOfImage) {
43 auto resource = EvasApp::jsonFiles(std::string(DEMO_DIR));
45 if (resource.empty()) return;
47 int count = numberOfImage;
48 int colums = (int) ceil(sqrt(count));
50 int vw = (mApp->width() - (offset * colums))/colums;
54 int resourceSize = resource.size();
55 for (int i = 0 ; i < numberOfImage; i++) {
56 int index = i % resourceSize;
57 std::unique_ptr<LottieView> view(new LottieView(mApp->evas(), mRenderMode));
58 view->setFilePath(resource[index].c_str());
59 view->setPos(posx, posy);
60 view->setSize(vw, vh);
64 //view->setRepeatMode(LottieView::RepeatMode::Reverse);
67 if ((mApp->width() - posx) < vw) {
69 posy = posy + vh + offset;
71 mViews.push_back(std::move(view));
76 //auto clock = std::chrono::high_resolution_clock::now();
77 for (auto &i : mViews) {
80 //double d = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now()-clock).count();
81 //printf("total time taken = %f\n", d);
86 bool mRenderMode = false;
87 std::vector<std::unique_ptr<LottieView>> mViews;
91 onExitCb(void *data, void *extra)
93 LottieViewTest *view = (LottieViewTest *)data;
98 onRenderPreCb(void *data, void *extra)
100 LottieViewTest *view = (LottieViewTest *)data;
105 main(int argc, char **argv)
107 EvasApp *app = new EvasApp(800, 800);
110 bool renderMode = true;
112 if (!strcmp(argv[1],"--disable-render"))
115 LottieViewTest *view = new LottieViewTest(app, renderMode);
118 app->addExitCb(onExitCb, view);
119 app->addRenderPreCb(onRenderPreCb, view);