+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "evasapp.h"
#include "lottieview.h"
#include<iostream>
LottieViewTest(EvasApp *app, bool renderMode) {
mApp = app;
mRenderMode = renderMode;
+ ecore_animator_frametime_set(1.0/120.0);
}
- void show() {
+ void show(int numberOfImage) {
auto resource = EvasApp::jsonFiles(std::string(DEMO_DIR));
if (resource.empty()) return;
- int count = resource.size();
+ int count = numberOfImage;
int colums = (int) ceil(sqrt(count));
int offset = 3;
- int vw = (mApp->width() - (2 * offset * colums))/colums;
+ int vw = (mApp->width() - (offset * colums))/colums;
int vh = vw;
int posx = offset;
int posy = offset;
- for(auto filePath : resource) {
-
+ int resourceSize = resource.size();
+ for (int i = 0 ; i < numberOfImage; i++) {
+ int index = i % resourceSize;
std::unique_ptr<LottieView> view(new LottieView(mApp->evas(), mRenderMode));
- view->setFilePath(filePath.c_str());
- view->setPos(posx, posy);
- view->setSize(vw, vh);
- view->show();
- view->play();
- view->loop(true);
- //view->setRepeatMode(LottieView::RepeatMode::Reverse);
-
- posx += vw+offset;
- if ((mApp->width() - posx) < vw) {
+ view->setFilePath(resource[index].c_str());
+ view->setPos(posx, posy);
+ view->setSize(vw, vh);
+ view->show();
+ view->play();
+ view->loop(true);
+ //view->setRepeatMode(LottieView::RepeatMode::Reverse);
+
+ posx += vw+offset;
+ if ((mApp->width() - posx) < vw) {
posx = offset;
posy = posy + vh + offset;
- }
- mViews.push_back(std::move(view));
+ }
+ mViews.push_back(std::move(view));
}
+ }
+ 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:
delete view;
}
+static void
+onRenderPreCb(void *data, void *extra)
+{
+ LottieViewTest *view = (LottieViewTest *)data;
+ view->render();
+}
+
int
main(int argc, char **argv)
{
renderMode = false;
}
LottieViewTest *view = new LottieViewTest(app, renderMode);
- view->show();
+ view->show(250);
app->addExitCb(onExitCb, view);
+ app->addRenderPreCb(onRenderPreCb, view);
app->run();
delete app;