From: subhransu mohanty Date: Tue, 30 Jul 2019 00:44:35 +0000 (+0900) Subject: Dasher: Fixed crash when dash array contains ZERO length segments or ZERO gap segments X-Git-Tag: submit/tizen/20190812.090759~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9836271b9426b8e25ed6128dbc766d386f76bfe7;p=platform%2Fcore%2Fuifw%2Flottie-player.git Dasher: Fixed crash when dash array contains ZERO length segments or ZERO gap segments --- diff --git a/src/vector/vdasher.cpp b/src/vector/vdasher.cpp index a6ca9ab..121a250 100644 --- a/src/vector/vdasher.cpp +++ b/src/vector/vdasher.cpp @@ -33,6 +33,15 @@ VDasher::VDasher(const float *dashArray, size_t size) mIndex = 0; mCurrentLength = 0; mDiscard = false; + //if the dash array contains ZERO length + // segments or ZERO lengths gaps we could + // optimize those usecase. + for (size_t i = 0; i < mArraySize; i++) { + if (!vCompare(mDashArray->length, 0.0f)) + mNoLength = false; + if (!vCompare(mDashArray->gap, 0.0f)) + mNoGap = false; + } } void VDasher::moveTo(const VPointF &p) @@ -178,7 +187,8 @@ void VDasher::cubicTo(const VPointF &cp1, const VPointF &cp2, const VPointF &e) VPath VDasher::dashed(const VPath &path) { - if (path.empty()) return VPath(); + if (path.empty() || mNoLength) return VPath(); + if (mNoGap) return path; mResult = {}; mResult.reserve(path.points().size(), path.elements().size()); diff --git a/src/vector/vdasher.h b/src/vector/vdasher.h index 224a2a8..81ce197 100644 --- a/src/vector/vdasher.h +++ b/src/vector/vdasher.h @@ -46,10 +46,12 @@ private: VPointF mCurPt; size_t mIndex{0}; /* index to the dash Array */ float mCurrentLength; - bool mDiscard; float mDashOffset{0}; VPath mResult; - bool mStartNewSegment=true; + bool mDiscard{false}; + bool mStartNewSegment{true}; + bool mNoLength{true}; + bool mNoGap{true}; }; V_END_NAMESPACE diff --git a/src/vector/vdrawable.cpp b/src/vector/vdrawable.cpp index 946054f..af44032 100644 --- a/src/vector/vdrawable.cpp +++ b/src/vector/vdrawable.cpp @@ -26,7 +26,7 @@ void VDrawable::preprocess(const VRect &clip) if (mStroke.enable) { if (mStroke.mDash.size()) { VDasher dasher(mStroke.mDash.data(), mStroke.mDash.size()); - mPath = dasher.dashed(mPath); + mPath.clone(dasher.dashed(mPath)); } mRasterizer.rasterize(std::move(mPath), mStroke.cap, mStroke.join, mStroke.width, mStroke.meterLimit, clip);