lottie/example: updated example to use async rendering .
[platform/core/uifw/lottie-player.git] / example / lottieview.h
1 #ifndef LOTTIEVIEW_H
2 #define LOTTIEVIEW_H
3
4 #ifndef EFL_BETA_API_SUPPORT
5 #define EFL_BETA_API_SUPPORT
6 #endif
7
8 #ifndef EFL_EO_API_SUPPORT
9 #define EFL_EO_API_SUPPORT
10 #endif
11
12 #include <Eo.h>
13 #include <Efl.h>
14 #include <Evas.h>
15 #include <Ecore.h>
16 #include <Ecore_Evas.h>
17 #include"lottieplayer.h"
18 #include<future>
19 class LOTPlayer;
20 class LottieView
21 {
22 public:
23     enum class RepeatMode {
24         Restart,
25         Reverse
26     };
27     LottieView(Evas *evas, bool renderMode = true, bool asyncRender = true);
28     ~LottieView();
29     void setSize(int w, int h);
30     void setPos(int x, int y);
31     void setFilePath(const char *filePath);
32     void show();
33     void hide();
34     void loop(bool loop);
35     void setSpeed(float speed) { mSpeed = speed;}
36     void setRepeatCount(int count);
37     void setRepeatMode(LottieView::RepeatMode mode);
38 public:
39     void seek(float pos);
40     void finished();
41     void play();
42     void pause();
43     void stop();
44     void render();
45 private:
46     void createVgNode(LOTNode *node, Efl_VG *parent);
47     void update(const std::vector<LOTNode *> &);
48     void restart();
49 public:
50     int                      mw;
51     int                      mh;
52     Evas                    *mEvas;
53     Efl_VG                  *mRoot;
54     Evas_Object             *mVg;
55     int                      mRepeatCount;
56     LottieView::RepeatMode   mRepeatMode;
57     LOTPlayer               *mPlayer;
58     Ecore_Animator          *mAnimator;
59     bool                     mLoop;
60     int                      mCurCount;
61     bool                     mReverse;
62     bool                     mPalying;
63     Evas_Object             *mImage;
64     float                    mSpeed;
65     bool                     mRenderMode;
66     bool                     mAsyncRender;
67     bool                     mDirty;
68     float                    mPendingPos;
69     std::future<bool>        mRenderTask;
70     LOTBuffer                mBuffer;
71 };
72 #endif //LOTTIEVIEW_H