lottie/render: start all preprocess task at once before rendering the frame. 96/184596/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 19 Jul 2018 06:04:57 +0000 (15:04 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Thu, 19 Jul 2018 06:04:57 +0000 (15:04 +0900)
Change-Id: I6c625a3ed069c40d4f42fbb3579120ffbcc30d54

src/lottie/lottieitem.cpp
src/lottie/lottieitem.h

index 5bae4e9..a48777b 100644 (file)
@@ -271,14 +271,14 @@ bool LOTCompItem::update(int frameNo)
 
 void LOTCompItem::buildRenderList()
 {
-    mRenderList.clear();
-    std::vector<VDrawable *> list;
+    mDrawableList.clear();
     for (auto i = mLayers.rbegin(); i != mLayers.rend(); ++i) {
        LOTLayerItem *layer = *i;
-       layer->renderList(list);
+       layer->renderList(mDrawableList);
     }
 
-    for(auto i : list) {
+    mRenderList.clear();
+    for(auto i : mDrawableList) {
         i->sync();
         mRenderList.push_back(&i->mCNode);
     }
@@ -294,6 +294,12 @@ bool LOTCompItem::render(const LOTBuffer &buffer)
     VBitmap bitmap((uchar *)buffer.buffer, buffer.width, buffer.height,
                    buffer.bytesPerLine, VBitmap::Format::ARGB32_Premultiplied, nullptr, nullptr);
 
+    /* schedule all preprocess task for this frame at once.
+     */
+    for (auto &e : mDrawableList) {
+        e->preprocess();
+    }
+
     VPainter painter(&bitmap);
     VRle mask;
     for (auto i = mLayers.rbegin(); i != mLayers.rend(); ++i) {
@@ -349,11 +355,6 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask)
             mask = mask & inheritMask;
     }
 
-    // do preprocessing first to take advantage of thread pool.
-    for(auto i : list) {
-        i->preprocess();
-    }
-
     for(auto i : list) {
         painter->setBrush(i->mBrush);
         if (!mask.isEmpty()) {
index 5054b6a..259aeeb 100644 (file)
@@ -48,6 +48,7 @@ private:
    bool                                        mUpdateViewBox;
    int                                         mCurFrameNo;
    std::vector<LOTNode *>                      mRenderList;
+   std::vector<VDrawable *>                    mDrawableList;
 };
 
 typedef vFlag<DirtyFlagBit> DirtyFlag;