Update Factory::makeRenderPath to only accept a RawPath

Deletes the version that takes spans of points and verbs. We are
planning to inject the implicit moveTos into RawPath, at which point we
won't be able to just copy in arrays of points and verbs anymore.

Also changes the "RawPath" version of the factory method to take a
non-const "RawPath&" ref. This enables zero-copy construction via
stealing the arrays out from under the RawPath's points and verbs.

Diffs=
1bd616612 Update Factory::makeRenderPath to only accept a RawPath (#4211)
This commit is contained in:
csmartdalton
2022-09-02 16:07:36 +00:00
parent ce0af130b3
commit e4e765b084
19 changed files with 52 additions and 103 deletions

View File

@@ -34,9 +34,7 @@ public:
size_t count) override;
// Returns a full-formed RenderPath -- can be treated as immutable
std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
Span<const PathVerb> verbs,
FillRule) override;
std::unique_ptr<RenderPath> makeRenderPath(RawPath&, FillRule) override;
std::unique_ptr<RenderPath> makeEmptyRenderPath() override;

View File

@@ -39,7 +39,7 @@ protected:
public:
TessRenderPath();
TessRenderPath(Span<const Vec2D> points, Span<const PathVerb> verbs, FillRule fillRule);
TessRenderPath(RawPath&, FillRule);
~TessRenderPath();
void reset() override;
void fillRule(FillRule value) override;
@@ -65,4 +65,4 @@ public:
const RawPath& rawPath() const;
};
} // namespace rive
#endif
#endif

View File

@@ -17,8 +17,7 @@ static void fillColorBuffer(float* buffer, ColorInt value) {
class SokolRenderPath : public TessRenderPath {
public:
SokolRenderPath() {}
SokolRenderPath(Span<const Vec2D> points, Span<const PathVerb> verbs, FillRule fillRule) :
TessRenderPath(points, verbs, fillRule) {}
SokolRenderPath(RawPath& rawPath, FillRule fillRule) : TessRenderPath(rawPath, fillRule) {}
~SokolRenderPath() {
sg_destroy_buffer(m_vertexBuffer);
@@ -125,10 +124,8 @@ public:
};
// Returns a full-formed RenderPath -- can be treated as immutable
std::unique_ptr<RenderPath> SokolFactory::makeRenderPath(Span<const Vec2D> points,
Span<const PathVerb> verbs,
FillRule rule) {
return std::make_unique<SokolRenderPath>(points, verbs, rule);
std::unique_ptr<RenderPath> SokolFactory::makeRenderPath(RawPath& rawPath, FillRule rule) {
return std::make_unique<SokolRenderPath>(rawPath, rule);
}
std::unique_ptr<RenderPath> SokolFactory::makeEmptyRenderPath() {
@@ -989,4 +986,4 @@ SokolRenderImage::SokolRenderImage(rcp<SokolRenderImageResource> image,
SokolRenderImage::~SokolRenderImage() {
sg_destroy_buffer(m_vertexBuffer);
sg_destroy_buffer(m_uvBuffer);
}
}

View File

@@ -6,10 +6,10 @@ static const float contourThreshold = 1.0f;
using namespace rive;
TessRenderPath::TessRenderPath() : m_segmentedContour(contourThreshold) {}
TessRenderPath::TessRenderPath(Span<const Vec2D> points,
Span<const PathVerb> verbs,
FillRule fillRule) :
m_rawPath(points, verbs), m_fillRule(fillRule), m_segmentedContour(contourThreshold) {}
TessRenderPath::TessRenderPath(RawPath& rawPath, FillRule fillRule) :
m_fillRule(fillRule), m_segmentedContour(contourThreshold) {
m_rawPath.swap(rawPath);
}
TessRenderPath::~TessRenderPath() {}