lottie: Add Mask information to the layer node. 18/194418/2 tizen_5.0 accepted/tizen/unified/20181213.142320 submit/tizen/20181211.054046 submit/tizen/20181211.054151 submit/tizen_5.0/20181211.054718
authorsubhransu mohanty <sub.mohanty@samsung.com>
Tue, 4 Dec 2018 07:34:03 +0000 (16:34 +0900)
committerHermet Park <chuneon.park@samsung.com>
Mon, 10 Dec 2018 08:06:57 +0000 (08:06 +0000)
Change-Id: I312e178d10747f29b6a6cbde9862edf5541a6c53

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

index 31ddb30..2494d36 100644 (file)
@@ -151,10 +151,13 @@ void LOTMaskItem::update(int frameNo, const VMatrix &parentMatrix,
     opacity = opacity * parentAlpha;
     mCombinedAlpha = opacity;
 
-    VPath path = mLocalPath;
-    path.transform(parentMatrix);
+    mFinalPath.reset();
+    mFinalPath.addPath(mLocalPath);
+    mFinalPath.transform(parentMatrix);
 
-    mRleTask = VRaster::generateFillInfo(std::move(path), std::move(mRle));
+    VPath tmp = mFinalPath;
+
+    mRleTask = VRaster::generateFillInfo(std::move(tmp), std::move(mRle));
     mRle = VRle();
 }
 
@@ -204,7 +207,38 @@ void LOTLayerItem::buildLayerNode()
         }
     }
     if (hasMask()) {
-        //TODO populate mask property
+        mMasksCNode.clear();
+        for (const auto &mask : mMasks) {
+            LOTMask cNode;
+            const std::vector<VPath::Element> &elm = mask->mFinalPath.elements();
+            const std::vector<VPointF> &       pts = mask->mFinalPath.points();
+            const float *ptPtr = reinterpret_cast<const float *>(pts.data());
+            const char * elmPtr = reinterpret_cast<const char *>(elm.data());
+            cNode.mPath.ptPtr = ptPtr;
+            cNode.mPath.ptCount = pts.size();
+            cNode.mPath.elmPtr = elmPtr;
+            cNode.mPath.elmCount = elm.size();
+            switch (mask->maskMode()) {
+            case LOTMaskData::Mode::Add:
+                cNode.mMode = MaskModeAdd;
+                break;
+            case LOTMaskData::Mode::Substarct:
+                cNode.mMode = MaskModeSubstract;
+                break;
+            case LOTMaskData::Mode::Intersect:
+                cNode.mMode = MaskModeIntersect;
+                break;
+            case LOTMaskData::Mode::Difference:
+                cNode.mMode = MaskModeDifference;
+                break;
+            default:
+                cNode.mMode = MaskModeAdd;
+                break;
+            }
+            mMasksCNode.push_back(std::move(cNode));
+        }
+        mLayerCNode->mMaskList.ptr = mMasksCNode.data();
+        mLayerCNode->mMaskList.size = mMasksCNode.size();
     }
 }
 
index 0251460..695ac45 100644 (file)
@@ -84,6 +84,7 @@ protected:
    VRle maskRle(const VRect &clipRect);
    bool hasMask() const {return !mMasks.empty();}
 protected:
+   std::vector<LOTMask>                        mMasksCNode;
    std::unique_ptr<LOTLayerNode>               mLayerCNode;
    std::vector<VDrawable *>                    mDrawableList;
    std::vector<std::unique_ptr<LOTMaskItem>>   mMasks;
@@ -161,6 +162,7 @@ public:
     float                    mCombinedAlpha;
     VMatrix                  mCombinedMatrix;
     VPath                    mLocalPath;
+    VPath                    mFinalPath;
     std::future<VRle>        mRleTask;
     VRle                     mRle;
 };