lottie: keep the content in back-tofron order in lottie scenegraph. 53/188553/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 6 Sep 2018 03:16:59 +0000 (12:16 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Thu, 6 Sep 2018 03:16:59 +0000 (12:16 +0900)
Change-Id: I15090782105c5e30d38e4d2df896d430d6f8cc19

src/lottie/lottieitem.cpp

index 6c1b1f500609b2bce542f153cee8c9c143217a31..56a4532cc7b94f8f901d6e96ab34d182b3de3d47 100644 (file)
@@ -556,6 +556,9 @@ void LOTContentGroupItem::addChildren(LOTGroupData *data)
             mContents.push_back(std::move(content));
         }
     }
+
+    // keep the content in back-to-front order.
+    std::reverse(mContents.begin(), mContents.end());
 }
 
 void LOTContentGroupItem::update(int frameNo, const VMatrix &parentMatrix,
@@ -582,17 +585,18 @@ void LOTContentGroupItem::update(int frameNo, const VMatrix &parentMatrix,
 
     mMatrix = m;
 
-    for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
-        (*i)->update(frameNo, m, alpha, newFlag);
+    for (const auto &content : mContents) {
+        content->update(frameNo, m, alpha, newFlag);
     }
 }
 
 void LOTContentGroupItem::applyTrim()
 {
-    for (auto &i : mContents) {
-        if (auto trim = dynamic_cast<LOTTrimItem *>(i.get())) {
+    for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
+        auto content = (*i).get();
+        if (auto trim = dynamic_cast<LOTTrimItem *>(content)) {
             trim->update();
-        } else if (auto group = dynamic_cast<LOTContentGroupItem *>(i.get())) {
+        } else if (auto group = dynamic_cast<LOTContentGroupItem *>(content)) {
             group->applyTrim();
         }
     }
@@ -600,8 +604,8 @@ void LOTContentGroupItem::applyTrim()
 
 void LOTContentGroupItem::renderList(std::vector<VDrawable *> &list)
 {
-    for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
-        (*i)->renderList(list);
+    for (const auto &content : mContents) {
+        content->renderList(list);
     }
 }
 
@@ -609,15 +613,16 @@ void LOTContentGroupItem::processPaintItems(
     std::vector<LOTPathDataItem *> &list)
 {
     int curOpCount = list.size();
-    for (auto &i : mContents) {
-        if (auto pathNode = dynamic_cast<LOTPathDataItem *>(i.get())) {
+    for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
+        auto content = (*i).get();
+        if (auto pathNode = dynamic_cast<LOTPathDataItem *>(content)) {
             // add it to the list
             list.push_back(pathNode);
-        } else if (auto paintNode = dynamic_cast<LOTPaintDataItem *>(i.get())) {
+        } else if (auto paintNode = dynamic_cast<LOTPaintDataItem *>(content)) {
             // the node is a paint data node update the path list of the paint item.
             paintNode->addPathItems(list, curOpCount);
         } else if (auto groupNode =
-                       dynamic_cast<LOTContentGroupItem *>(i.get())) {
+                       dynamic_cast<LOTContentGroupItem *>(content)) {
             // update the groups node with current list
             groupNode->processPaintItems(list);
         }
@@ -628,15 +633,16 @@ void LOTContentGroupItem::processTrimItems(
     std::vector<LOTPathDataItem *> &list)
 {
     int curOpCount = list.size();
-    for (auto &i : mContents) {
-        if (auto pathNode = dynamic_cast<LOTPathDataItem *>(i.get())) {
+    for (auto i = mContents.rbegin(); i != mContents.rend(); ++i) {
+        auto content = (*i).get();
+        if (auto pathNode = dynamic_cast<LOTPathDataItem *>(content)) {
             // add it to the list
             list.push_back(pathNode);
-        } else if (auto trimNode = dynamic_cast<LOTTrimItem *>(i.get())) {
+        } else if (auto trimNode = dynamic_cast<LOTTrimItem *>(content)) {
             // the node is a paint data node update the path list of the paint item.
             trimNode->addPathItems(list, curOpCount);
         } else if (auto groupNode =
-                       dynamic_cast<LOTContentGroupItem *>(i.get())) {
+                       dynamic_cast<LOTContentGroupItem *>(content)) {
             // update the groups node with current list
             groupNode->processTrimItems(list);
         }