Change factory to use span ... and add a test (doh). Diffs= 194a38e78 Change factory to use span
diff --git a/.rive_head b/.rive_head index c523dbb..a43f55d 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -93229eacd7a946ea27f7f3697ee5e07ddd1fe093 +194a38e7846180ce77a1575dca27208d099d7209
diff --git a/include/rive/math/raw_path.hpp b/include/rive/math/raw_path.hpp index de32874..fea2032 100644 --- a/include/rive/math/raw_path.hpp +++ b/include/rive/math/raw_path.hpp
@@ -26,12 +26,8 @@ std::vector<PathVerb> m_Verbs; // Construct a RawPath from count points and verbs. - RawPath(const Vec2D* points, - std::size_t pointCount, - const PathVerb* verbs, - std::size_t verbCount); + RawPath(Span<const Vec2D> points, Span<const PathVerb> verbs); RawPath() {} - ~RawPath() {} bool operator==(const RawPath& o) const; bool operator!=(const RawPath& o) const { return !(*this == o); }
diff --git a/src/math/raw_path.cpp b/src/math/raw_path.cpp index fd4419a..6cfef04 100644 --- a/src/math/raw_path.cpp +++ b/src/math/raw_path.cpp
@@ -9,11 +9,8 @@ using namespace rive; -RawPath::RawPath(const Vec2D* points, - std::size_t pointCount, - const PathVerb* verbs, - std::size_t verbCount) : - m_Points(points, points + pointCount), m_Verbs(verbs, verbs + verbCount) {} +RawPath::RawPath(Span<const Vec2D> points, Span<const PathVerb> verbs) : + m_Points(points.begin(), points.end()), m_Verbs(verbs.begin(), verbs.end()) {} bool RawPath::operator==(const RawPath& o) const { return m_Points == o.m_Points && m_Verbs == o.m_Verbs;
diff --git a/test/raw_path_test.cpp b/test/raw_path_test.cpp index e24bf9e..bdc8a38 100644 --- a/test/raw_path_test.cpp +++ b/test/raw_path_test.cpp
@@ -297,3 +297,26 @@ } } } + +TEST_CASE("factory", "[rawpath]") { + // clang-format off + const Vec2D pts[] = { + {1, 2}, + {2, 3}, + {4, 5}, {6, 7}, {8, 9}, + }; + const PathVerb vbs[] = { + PathVerb::move, PathVerb::line, PathVerb::cubic, PathVerb::close + }; + // clang-format on + + RawPath path0(pts, vbs); + + RawPath path1; + path1.move(pts[0]); + path1.line(pts[1]); + path1.cubic(pts[2], pts[3], pts[4]); + path1.close(); + + REQUIRE(path0 == path1); +} \ No newline at end of file