Swiftgram/example/lottieview.h
subhransu mohanty 812f816138 lottie/example: updated example to use async rendering .
Change-Id: I6929f00bb6a26f18f7276890c40993329d94ae03
2018-07-20 05:45:18 +00:00

73 lines
1.9 KiB
C++

#ifndef LOTTIEVIEW_H
#define LOTTIEVIEW_H
#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#ifndef EFL_EO_API_SUPPORT
#define EFL_EO_API_SUPPORT
#endif
#include <Eo.h>
#include <Efl.h>
#include <Evas.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
#include"lottieplayer.h"
#include<future>
class LOTPlayer;
class LottieView
{
public:
enum class RepeatMode {
Restart,
Reverse
};
LottieView(Evas *evas, bool renderMode = true, bool asyncRender = true);
~LottieView();
void setSize(int w, int h);
void setPos(int x, int y);
void setFilePath(const char *filePath);
void show();
void hide();
void loop(bool loop);
void setSpeed(float speed) { mSpeed = speed;}
void setRepeatCount(int count);
void setRepeatMode(LottieView::RepeatMode mode);
public:
void seek(float pos);
void finished();
void play();
void pause();
void stop();
void render();
private:
void createVgNode(LOTNode *node, Efl_VG *parent);
void update(const std::vector<LOTNode *> &);
void restart();
public:
int mw;
int mh;
Evas *mEvas;
Efl_VG *mRoot;
Evas_Object *mVg;
int mRepeatCount;
LottieView::RepeatMode mRepeatMode;
LOTPlayer *mPlayer;
Ecore_Animator *mAnimator;
bool mLoop;
int mCurCount;
bool mReverse;
bool mPalying;
Evas_Object *mImage;
float mSpeed;
bool mRenderMode;
bool mAsyncRender;
bool mDirty;
float mPendingPos;
std::future<bool> mRenderTask;
LOTBuffer mBuffer;
};
#endif //LOTTIEVIEW_H