Skip to content

Commit

Permalink
Convert RenderPath/CommandPath and RenderPaint to refcounted objects
Browse files Browse the repository at this point in the history
Diffs=
8666bde87 Convert RenderPath/CommandPath and RenderPaint to refcounted objects (#6395)

Co-authored-by: Chris Dalton <[email protected]>
  • Loading branch information
csmartdalton and csmartdalton committed Dec 27, 2023
1 parent efc3bd5 commit 1dffe23
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9c3da38e31678c3eaccc88857f6b54255e889cee
8666bde87b8ef973ff99d7a285a4b768bdf76aa9
12 changes: 6 additions & 6 deletions wasm/src/bindings_c2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class C2DFactory : public Factory
return rcp<RenderShader>(new RadialGradientShader(colors, stops, count, cx, cy, radius));
}

std::unique_ptr<RenderPath> makeRenderPath(RawPath& path, FillRule fr) override
rcp<RenderPath> makeRenderPath(RawPath& path, FillRule fr) override
{
val renderPath = val::module_property("renderFactory").call<val>("makeRenderPath");
auto ptr = renderPath.as<RenderPath*>(allow_raw_pointers());
Expand Down Expand Up @@ -363,21 +363,21 @@ class C2DFactory : public Factory
}
assert(pts - path.points().data() == path.points().size());

return std::unique_ptr<RenderPath>(ptr);
return rcp(ptr); // Adopt this ref without increasing the refcount.
}

std::unique_ptr<RenderPath> makeEmptyRenderPath() override
rcp<RenderPath> makeEmptyRenderPath() override
{
val renderPath = val::module_property("renderFactory").call<val>("makeRenderPath");
auto ptr = renderPath.as<RenderPath*>(allow_raw_pointers());
return std::unique_ptr<RenderPath>(ptr);
return rcp(ptr); // Adopt this ref without increasing the refcount.
}

std::unique_ptr<RenderPaint> makeRenderPaint() override
rcp<RenderPaint> makeRenderPaint() override
{
val renderPaint = val::module_property("renderFactory").call<val>("makeRenderPaint");
auto ptr = renderPaint.as<RenderPaint*>(allow_raw_pointers());
return std::unique_ptr<RenderPaint>(ptr);
return rcp(ptr); // Adopt this ref without increasing the refcount.
}

rcp<RenderImage> decodeImage(Span<const uint8_t> bytes) override
Expand Down
2 changes: 1 addition & 1 deletion wasm/src/bindings_skia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class WebGLSkiaRenderer : public rive::SkiaRenderer
void saveClipRect(float l, float t, float r, float b)
{
save();
std::unique_ptr<rive::RenderPath> rect(jsFactory()->makeEmptyRenderPath());
rive::rcp<rive::RenderPath> rect(jsFactory()->makeEmptyRenderPath());
rect->moveTo(l, t);
rect->lineTo(r, t);
rect->lineTo(r, b);
Expand Down
2 changes: 1 addition & 1 deletion wasm/submodules/rive-cpp

0 comments on commit 1dffe23

Please sign in to comment.