lottie/render : fixed dash regression 05/186205/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Mon, 6 Aug 2018 08:09:23 +0000 (17:09 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Wed, 8 Aug 2018 05:14:19 +0000 (14:14 +0900)
Change-Id: I7a79295348ba23d8328718014a49760c2e11e731

src/lottie/lottieitem.cpp
src/vector/vdrawable.cpp
src/vector/vdrawable.h

index f3283f6..9785b4a 100644 (file)
@@ -910,10 +910,12 @@ void LOTStrokeItem::updateRenderNode(LOTPathDataItem *pathNode,
 
     VBrush brush(color);
     drawable->setBrush(brush);
-
+    float scale = getScale(mParentMatrix);
     drawable->setStrokeInfo(mCap, mJoin, mMiterLimit,
-                            mWidth * getScale(mParentMatrix));
+                            mWidth * scale);
     if (mDashArraySize) {
+        for (int i = 0 ; i < mDashArraySize ; i++)
+            mDashArray[i] *= scale;
         drawable->setDashInfo(mDashArray, mDashArraySize);
     }
 }
@@ -940,10 +942,13 @@ void LOTGStrokeItem::updateContent(int frameNo)
 void LOTGStrokeItem::updateRenderNode(LOTPathDataItem *pathNode,
                                       VDrawable *drawable, bool sameParent)
 {
+    float scale = getScale(mParentMatrix);
     drawable->setBrush(VBrush(mGradient.get()));
     drawable->setStrokeInfo(mCap, mJoin, mMiterLimit,
-                            mWidth * getScale(mParentMatrix));
+                            mWidth * scale);
     if (mDashArraySize) {
+        for (int i = 0 ; i < mDashArraySize ; i++)
+            mDashArray[i] *= scale;
         drawable->setDashInfo(mDashArray, mDashArraySize);
     }
 }
@@ -1025,8 +1030,8 @@ void LOTDrawable::sync()
             break;
         }
 
-        mCNode.mStroke.dashArray = mStroke.dashArray;
-        mCNode.mStroke.dashArraySize = mStroke.dashArraySize;
+        mCNode.mStroke.dashArray = mStroke.mDash.data();
+        mCNode.mStroke.dashArraySize = mStroke.mDash.size();
 
     } else {
         mCNode.mStroke.enable = 0;
index 470f0e1..c8df216 100644 (file)
@@ -6,15 +6,16 @@ void VDrawable::preprocess()
 {
     if (mFlag & (DirtyState::Path)) {
         if (mStroke.enable) {
-            if (mStroke.dashArraySize) {
-                VDasher dasher(mStroke.dashArray, mStroke.dashArraySize);
+            if (mStroke.mDash.size()) {
+                VDasher dasher(mStroke.mDash.data(), mStroke.mDash.size());
                 mPath = dasher.dashed(mPath);
             }
             mRleTask = VRaster::instance().generateStrokeInfo(
-                std::move(mPath), std::move(mRle), mStroke.cap, mStroke.join, mStroke.width,
-                mStroke.meterLimit);
+                std::move(mPath), std::move(mRle), mStroke.cap, mStroke.join,
+                mStroke.width, mStroke.meterLimit);
         } else {
-            mRleTask = VRaster::instance().generateFillInfo(std::move(mPath), std::move(mRle), mFillRule);
+            mRleTask = VRaster::instance().generateFillInfo(
+                std::move(mPath), std::move(mRle), mFillRule);
         }
         mFlag &= ~DirtyFlag(DirtyState::Path);
     }
@@ -32,7 +33,8 @@ void VDrawable::setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
                               float strokeWidth)
 {
     if ((mStroke.cap == cap) && (mStroke.join == join) &&
-       vCompare(mStroke.meterLimit, meterLimit) && vCompare(mStroke.width, strokeWidth))
+        vCompare(mStroke.meterLimit, meterLimit) &&
+        vCompare(mStroke.width, strokeWidth))
         return;
 
     mStroke.enable = true;
@@ -43,13 +45,13 @@ void VDrawable::setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
     mFlag |= DirtyState::Path;
 }
 
-void VDrawable::setDashInfo(float *array, int size)
+void VDrawable::setDashInfo(float *array, uint size)
 {
     bool hasChanged = false;
 
-    if (mStroke.dashArraySize == size) {
-        for (int i = 0; i < size; i++) {
-            if (!vCompare(mStroke.dashArray[i], array[i])) {
+    if (mStroke.mDash.size() == size) {
+        for (uint i = 0; i < size; i++) {
+            if (!vCompare(mStroke.mDash[i], array[i])) {
                 hasChanged = true;
                 break;
             }
@@ -60,7 +62,10 @@ void VDrawable::setDashInfo(float *array, int size)
 
     if (!hasChanged) return;
 
-    mStroke.dashArray = array;
-    mStroke.dashArraySize = size;
+    mStroke.mDash.clear();
+
+    for (uint i = 0; i < size; i++) {
+        mStroke.mDash.push_back(array[i]);
+    }
     mFlag |= DirtyState::Path;
 }
index a518cd4..e43ed77 100644 (file)
@@ -25,11 +25,19 @@ public:
     void setBrush(const VBrush &brush) { mBrush = brush; }
     void setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
                        float strokeWidth);
-    void setDashInfo(float *array, int size);
+    void setDashInfo(float *array, uint size);
     void preprocess();
     VRle rle();
 
 public:
+    struct StrokeInfo {
+        bool               enable{false};
+        float              width{0.0};
+        CapStyle           cap{CapStyle::Flat};
+        JoinStyle          join{JoinStyle::Bevel};
+        float              meterLimit{10};
+        std::vector<float> mDash;
+    };
     DirtyFlag         mFlag{DirtyState::All};
     VDrawable::Type   mType{Type::Fill};
     VBrush            mBrush;
@@ -37,15 +45,7 @@ public:
     FillRule          mFillRule{FillRule::Winding};
     std::future<VRle> mRleTask;
     VRle              mRle;
-    struct {
-        bool      enable{false};
-        float     width{0.0};
-        CapStyle  cap{CapStyle::Flat};
-        JoinStyle join{JoinStyle::Bevel};
-        float     meterLimit{10};
-        float *   dashArray{nullptr};
-        int       dashArraySize{0};
-    } mStroke;
+    StrokeInfo        mStroke;
 };
 
 #endif  // VDRAWABLE_H