lottie/optimization: keep drawablelist in layer to avoid memory allocation in every... 54/186854/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 16 Aug 2018 04:37:21 +0000 (13:37 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Thu, 16 Aug 2018 04:37:21 +0000 (13:37 +0900)
Change-Id: I80eebb9e1ab16a424a26a17ce67274c7518efca9

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

index 25056cf..5896543 100644 (file)
@@ -160,14 +160,14 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerIt
 {
     VRle matteRle;
     if (matteSource) {
-        std::vector<VDrawable *> matteList;
-        matteSource->renderList(matteList);
-        for (auto &i : matteList) {
+        mDrawableList.clear();
+        matteSource->renderList(mDrawableList);
+        for (auto &i : mDrawableList) {
             matteRle = matteRle + i->rle();
         }
     }
-    std::vector<VDrawable *> list;
-    renderList(list);
+    mDrawableList.clear();
+    renderList(mDrawableList);
     VRle mask = inheritMask;
     if (hasMask()) {
         if (mask.isEmpty())
@@ -176,7 +176,7 @@ void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerIt
             mask = mask & inheritMask;
     }
 
-    for (auto &i : list) {
+    for (auto &i : mDrawableList) {
         painter->setBrush(i->mBrush);
         VRle rle = i->rle();
         if (!mask.isEmpty()) rle = i->rle() & mask;
@@ -343,9 +343,9 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLay
 {
     VRle matteRle;
     if (matteSource) {
-        std::vector<VDrawable *> matteList;
-        matteSource->renderList(matteList);
-        for (auto &i : matteList) {
+        mDrawableList.clear();
+        matteSource->renderList(mDrawableList);
+        for (auto &i : mDrawableList) {
             matteRle = matteRle + i->rle();
         }
     }
index 6c769e0..c3d5066 100644 (file)
@@ -79,6 +79,7 @@ protected:
    VRle maskRle(const VRect &clipRect);
    bool hasMask() const {return !mMasks.empty();}
 protected:
+   std::vector<VDrawable *>                    mDrawableList;
    std::vector<std::unique_ptr<LOTMaskItem>>   mMasks;
    LOTLayerData                               *mLayerData;
    LOTLayerItem                               *mParentLayer;