lottie/parser: treat root layer as a special precomp layer. 94/187094/4
authorsubhransu mohanty <sub.mohanty@samsung.com>
Mon, 20 Aug 2018 02:22:31 +0000 (11:22 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Mon, 20 Aug 2018 04:42:50 +0000 (04:42 +0000)
Change-Id: Ic9a2b171ee349f132e52db5395a92587c9e44c08

src/lottie/lottieitem.cpp
src/lottie/lottiemodel.h
src/lottie/lottieparser.cpp

index fd044fd..c835e02 100644 (file)
@@ -322,7 +322,8 @@ LOTCompLayerItem::LOTCompLayerItem(LOTLayerData *layerModel)
                             [id](const auto& val){ return val->id() == id;});
             if (search != mLayers.end()) i->setParentLayer(*search);
         }
-        i->setPrecompLayer(this);
+        // update the precomp layer if its not the root layer.
+        if (!layerModel->root()) i->setPrecompLayer(this);
     }
 }
 
index 1321d92..3f16213 100644 (file)
@@ -312,6 +312,7 @@ public:
     bool hasGradient() const noexcept {return mHasGradient;}
     bool hasMask() const noexcept {return mHasMask;}
     bool hasRepeater() const noexcept {return mHasRepeater;}
+    bool root() const noexcept {return mRoot;}
     int id() const noexcept{ return mId;}
     int parentId() const noexcept{ return mParentId;}
     int inFrame() const noexcept{return mInFrame;}
@@ -346,6 +347,7 @@ public:
     bool                 mHasMask{false};
     bool                 mHasRepeater{false};
     bool                 mHasGradient{false};
+    bool                 mRoot{false};
     std::vector<std::shared_ptr<LOTMaskData>>  mMasks;
 };
 
index d4e6db3..05b8bb8 100644 (file)
@@ -636,6 +636,7 @@ std::shared_ptr<LOTAsset> LottieParserImpl::parseAsset()
 void LottieParserImpl::parseLayers(LOTCompositionData *comp)
 {
     comp->mRootLayer = std::make_shared<LOTLayerData>();
+    comp->mRootLayer->mRoot = true;
     comp->mRootLayer->mLayerType = LayerType::Precomp;
     comp->mRootLayer->mTransform = std::make_shared<LOTTransformData>();
     bool staticFlag = true;