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)
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());
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
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);