From: subhransu mohanty Date: Thu, 23 Aug 2018 04:10:06 +0000 (+0900) Subject: lottie/vector : added addPath() api to vpath. X-Git-Tag: submit/tizen/20180917.042405~71 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43d77af0d175f0fff8854ce1fd0a608c3504c372;p=platform%2Fcore%2Fuifw%2Flottie-player.git lottie/vector : added addPath() api to vpath. Change-Id: I3fd7ee9ba8add8f7109c23c0b6e62388b3fda5bf --- diff --git a/src/vector/vpath.cpp b/src/vector/vpath.cpp index 085094c..7089d2b 100644 --- a/src/vector/vpath.cpp +++ b/src/vector/vpath.cpp @@ -667,4 +667,21 @@ void VPath::VPathData::addPolygon(float points, float radius, float roundness, close(); } +void VPath::VPathData::addPath(const VPathData &path) +{ + int segment = path.segments(); + + // make sure enough memory available + if (m_points.capacity() < m_points.size() + path.m_points.size()) + m_points.reserve(m_points.size() + path.m_points.size()); + + if (m_elements.capacity() < m_elements.size() + path.m_elements.size()) + m_elements.reserve(m_elements.size() + path.m_elements.size()); + + std::copy(path.m_points.begin(), path.m_points.end(), back_inserter(m_points)); + std::copy(path.m_elements.begin(), path.m_elements.end(), back_inserter(m_elements)); + + m_segments += segment; +} + V_END_NAMESPACE diff --git a/src/vector/vpath.h b/src/vector/vpath.h index ff5583a..8845b41 100644 --- a/src/vector/vpath.h +++ b/src/vector/vpath.h @@ -41,6 +41,7 @@ public: void addPolygon(float points, float radius, float roundness, float startAngle, float cx, float cy, VPath::Direction dir = Direction::CW); + void addPath(const VPath &path); void transform(const VMatrix &m); float length() const; const std::vector &elements() const; @@ -74,6 +75,7 @@ private: void addPolygon(float points, float radius, float roundness, float startAngle, float cx, float cy, VPath::Direction dir = Direction::CW); + void addPath(const VPathData &path); const std::vector &elements() const { return m_elements; @@ -201,6 +203,17 @@ inline void VPath::addPolygon(float points, float radius, float roundness, d.write().addPolygon(points, radius, roundness, startAngle, cx, cy, dir); } +inline void VPath::addPath(const VPath &path) +{ + if (path.isEmpty()) return; + + if (isEmpty()) { + *this = path; + } else { + d.write().addPath(path.d.read()); + } +} + inline const std::vector &VPath::elements() const { return d->elements();