rlottie: Fix issue with handling hidden Layer
authorsubhransu mohanty <sub.mohanty@samsung.com>
Tue, 18 Jun 2019 04:53:53 +0000 (13:53 +0900)
committerHermet Park <hermetpark@gmail.com>
Wed, 19 Jun 2019 04:36:15 +0000 (13:36 +0900)
src/lottie/lottieparser.cpp

index 74899c7..ae84ba9 100644 (file)
@@ -895,6 +895,8 @@ std::shared_ptr<LOTData> LottieParserImpl::parseLayer(bool record)
             parseMaskProperty(layer);
         } else if (0 == strcmp(key, "ao")) {
             layer->mAutoOrient = GetInt();
+        } else if (0 == strcmp(key, "hd")) {
+            layer->mHidden = GetBool();
         } else {
 #ifdef DEBUG_PARSER
             vWarning << "Layer Attribute Skipped : " << key;
@@ -903,6 +905,18 @@ std::shared_ptr<LOTData> LottieParserImpl::parseLayer(bool record)
         }
     }
 
+    layer->mCompRef = compRef;
+
+    if (layer->hidden()) {
+        // if layer is hidden, only data that is usefull is its
+        // transform matrix(when it is a parent of some other layer)
+        // so force it to be a Null Layer and release all resource.
+        layer->setStatic(layer->mTransform->isStatic());
+        layer->mLayerType = LayerType::Null;
+        layer->mChildren = {};
+        return sharedLayer;
+    }
+
     // update the static property of layer
     bool staticFlag = true;
     for (const auto& child : layer->mChildren) {
@@ -914,7 +928,6 @@ std::shared_ptr<LOTData> LottieParserImpl::parseLayer(bool record)
     }
 
     layer->setStatic(staticFlag && layer->mTransform->isStatic());
-    layer->mCompRef = compRef;
 
     if (record) {
         mLayerInfoList.push_back(LayerInfo(layer->mName, layer->mInFrame, layer->mOutFrame));