lottieplayer: merge setPos() with renderList() 83/186683/3
authorHermet Park <hermetpark@gmail.com>
Mon, 13 Aug 2018 10:29:38 +0000 (19:29 +0900)
committerSubhransu Mohanty <sub.mohanty@samsung.com>
Tue, 14 Aug 2018 03:27:35 +0000 (03:27 +0000)
renderList() build render tree based on current Position.
merge both api helps user to avoid mistake.

Change-Id: Ia158f28b5ab66ec6e20665726a21d7f1c4e4cc13

example/lottieview.cpp
inc/lottieplayer.h
src/lottie/lottieplayer.cpp

index a59468d..6970191 100644 (file)
@@ -162,8 +162,7 @@ void LottieView::seek(float pos)
             }
         }
     } else {
-        mPlayer->setPos(pos);
-        const std::vector<LOTNode *> &renderList = mPlayer->renderList();
+        const std::vector<LOTNode *> &renderList = mPlayer->renderList(pos);
         update(renderList);
     }
 }
@@ -186,8 +185,7 @@ void LottieView::render()
         }
         mBuffer.buffer = nullptr;
     } else {
-        mPlayer->setPos(mPendingPos);
-        const std::vector<LOTNode *> &renderList = mPlayer->renderList();
+        const std::vector<LOTNode *> &renderList = mPlayer->renderList(mPendingPos);
         update(renderList);
     }
 }
index 1fcdb77..9115977 100644 (file)
@@ -46,10 +46,9 @@ public:
 
     float playTime() const;
 
-    void  setPos(float pos);
     float pos();
 
-    const std::vector<LOTNode *> &renderList() const;
+    const std::vector<LOTNode *> &renderList(float pos) const;
 
     // TODO: Consider correct position...
     void              setSize(int width, int height);
index 7c97398..95368af 100644 (file)
@@ -7,15 +7,18 @@
 #include <fstream>
 
 class LOTPlayerPrivate {
+
+private:
+    bool                          setPos(float pos);
+
 public:
     LOTPlayerPrivate();
     bool                          setFilePath(std::string path);
     void                          setSize(const VSize &sz);
     VSize                         size() const;
     float                         playTime() const;
-    bool                          setPos(float pos);
     float                         pos();
-    const std::vector<LOTNode *> &renderList() const;
+    const std::vector<LOTNode *> &renderList(float pos);
     bool                          render(float pos, const LOTBuffer &buffer);
 
 public:
@@ -48,13 +51,13 @@ VSize LOTPlayerPrivate::size() const
     }
 }
 
-const std::vector<LOTNode *> &LOTPlayerPrivate::renderList() const
+const std::vector<LOTNode *> &LOTPlayerPrivate::renderList(float pos)
 {
     if (!mCompItem) {
         static std::vector<LOTNode *> empty;
         return empty;
     }
-
+    this->setPos(pos);
     return mCompItem->renderList();
 }
 
@@ -66,7 +69,10 @@ float LOTPlayerPrivate::playTime() const
 
 bool LOTPlayerPrivate::setPos(float pos)
 {
-    if (!mModel || !mCompItem) return false;
+    if (!mModel || !mCompItem) {
+         vWarning << "Invalid data, mModel(?), mCompItem(?)";
+         return false;
+    }
 
     if (pos > 1.0) pos = 1.0;
     if (pos < 0) pos = 0;
@@ -244,19 +250,14 @@ float LOTPlayer::playTime() const
     return d->playTime();
 }
 
-void LOTPlayer::setPos(float pos)
-{
-    d->setPos(pos);
-}
-
 float LOTPlayer::pos()
 {
     return d->pos();
 }
 
-const std::vector<LOTNode *> &LOTPlayer::renderList() const
+const std::vector<LOTNode *> &LOTPlayer::renderList(float pos) const
 {
-    return d->renderList();
+    return d->renderList(pos);
 }
 
 std::future<bool> LOTPlayer::render(float pos, LOTBuffer buffer)