Skip to content

Commit

Permalink
Add a "lite_rtti" utility and use it with Render objects
Browse files Browse the repository at this point in the history
We need to be more robust if a user tries to use mismatched factories and renderers. This PR creates a simple "lite_rtti" utility and applies it to every Render object. The renderers now abort early instead of crashing if they are given a Render object for the wrong renderer.

Diffs=
c357e7aa7 Add a "lite_rtti" utility and use it with Render objects (#6311)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
  • Loading branch information
csmartdalton and csmartdalton committed Dec 8, 2023
1 parent b831f39 commit a94902e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f0ca1b0ef3052ecb92f5bf6ca8411e85d4368e86
c357e7aa757f23486271df284a5c3aa5643f2ff5
7 changes: 3 additions & 4 deletions wasm/src/bindings_c2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ class RendererWrapper : public wrapper<rive::Renderer>
rive::BlendMode value,
float opacity) override
{

auto vtx = rive::DataRenderBuffer::Cast(vertices_f32.get());
auto uv = rive::DataRenderBuffer::Cast(uvCoords_f32.get());
auto indices = rive::DataRenderBuffer::Cast(indices_u16.get());
LITE_RTTI_CAST_OR_RETURN(vtx, rive::DataRenderBuffer*, vertices_f32.get());
LITE_RTTI_CAST_OR_RETURN(uv, rive::DataRenderBuffer*, uvCoords_f32.get());
LITE_RTTI_CAST_OR_RETURN(indices, rive::DataRenderBuffer*, indices_u16.get());

uint32_t f32Count = vertexCount * 2;
assert(vtx->sizeInBytes() == f32Count * sizeof(float));
Expand Down
2 changes: 1 addition & 1 deletion wasm/submodules/rive-cpp

0 comments on commit a94902e

Please sign in to comment.