Commit Graph

629 Commits

Author SHA1 Message Date
Luigi Rosso
fda8d1cee7 Fix 2022-11-16 13:03:12 -08:00
Luigi Rosso
0f5f35c112 Fix test scripts. 2022-11-16 13:01:39 -08:00
luigi-rosso
527560ff11 Text
Uses it in the artboard title but also updates the flutter runtime massively to support FFI & WASM C++ Rive Text. PRing to let the tests run.

Diffs=
3be5ff0d8 Text (#4372)
2022-11-16 09:52:15 +00:00
umberto-sonnino
ae6265131f Fix the Android debug build
Pick up the Skia path also when building for debug. In debug, we were linking against two different Skias between the Android app and the renderer library.

Diffs=
90245a5e1 Fix the Android debug build
2022-11-15 12:01:50 +00:00
luigi-rosso
1ad72ba925 Fix for missing animation in a blend state.
Fix for issue discussed here:
https://2dimensions.slack.com/archives/CLLCU09T6/p1667317349310539

Boils down to a missing animation in a blend state:
![CleanShot 2022-11-14 at 12 26 00@2x](https://user-images.githubusercontent.com/454182/201758919-d0a37458-c0e3-41b2-aaff-56c33fe2a532.png)

We make some assumptions about our Animation Instances always having a backing animation. I've mode those assumptions more robust by including an assert and by having a Blend State always provide an animation, so if one is missing an empty one (with no keyframes) will be used. This maintains edit time and runtime fidelity.

Diffs=
0a0f3c267 Fix for missing animation in a blend state. (#4415)
2022-11-14 21:45:23 +00:00
luigi-rosso
711cda4c92 Add simd::if_then_else
Elementwise ternary ?: operations on vectors aren't supported until clang 13. This change adds a "simd::if_then_else" method that we will have to use instead, which has a fallback implementation for compilers that don't support the vector ternary.

Diffs=
440512dca Add simd::if_then_else (#4403)
2022-11-10 04:02:35 +00:00
csmartdalton
4f70c93cc1 Revert "Update SIMD booleans to use bitwise logic operators"
Reverts rive-app/rive#4385

I was wrong; boolean operators are officially supported:

https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors

Diffs=
ec9fb5bfc Revert "Update SIMD booleans to use bitwise logic operators"
2022-11-09 14:31:18 +00:00
csmartdalton
65cdabbcb4 Update SIMD booleans to use bitwise logic operators
Vectors should use (a | b) as opposed to (a || b).

Diffs=
701d8dee2 Update SIMD booleans to use bitwise logic operators
2022-11-08 21:20:37 +00:00
csmartdalton
8a70f0615c Add SIMD fallbacks for missing builtins
We can't expect every platform that uses Rive to have access to a recent clang. Add fallbacks with a performance warning when builtins aren't supported.

It's worth considering adding a gcc or older clang runner in order to test these fallbacks.

Diffs=
e98b93a61 Add SIMD fallbacks for missing builtins
2022-11-08 20:42:26 +00:00
csmartdalton
3b7931df22 Add some more core math and SIMD functions
Diffs=
466f68e3a Add some more core math and SIMD functions
2022-11-08 17:24:36 +00:00
duncandoit
ffedc47d7d chore: release v3.1.1 3.1.1 2022-11-02 20:48:09 +00:00
duncandoit
f15581bcf9 Updating version files 2022-11-02 20:48:04 +00:00
duncandoit
ad517b5fd5 chore: release v3.1.0 3.1.0 2022-10-31 16:53:19 +00:00
duncandoit
90295d735e Updating version files 2022-10-31 16:53:14 +00:00
duncandoit
e9ad1474a1 Fit bug fix
Fixed a bug that prevented fits and alignments that were set in the RiveViewModel's init from propagating to the RiveView

Diffs=
26aa419fd Fixed a bug that prevented fits and alignments that were set in the RiveViewModel's init from propagating to the RiveView.
2022-10-28 16:09:25 +00:00
luigi-rosso
edfe5ae631 Fix for incorrectly interpreting a RenderMetricsPath as a RenderPath
Fixes this issue: https://2dimensions.slack.com/archives/CLLCU09T6/p1666370141425879

Diffs=
3bfd9917f Fix for incorrectly interpreting a RenderMetricsPath as a RenderPath (#4323)
2022-10-21 19:31:03 +00:00
mjtalbot
6f2ca664be chore: release v3.0.5 3.0.5 2022-10-21 12:04:41 +00:00
mjtalbot
d5c13a0c6f Updating version files 2022-10-21 12:04:36 +00:00
mjtalbot
8a75b92c88 apply speed to both time and total time
fixes #3927

https://github.com/rive-app/rive/issues/3927

i did it once by changing how to determine the work end area, but then compared to flutter, which was doing this by changing how advance works. which is probably better.

Diffs=
bd567e2ba apply speed to both time and total time
2022-10-21 09:40:03 +00:00
luigi-rosso
792c9cc34c Bidi Text Support
Adding support for bidirectional text using SheenBidi to break styled runs into directional runs. This also needs to introduce the "baseDirection" of a paragraph (and the concept of a paragraph) in order to properly flow the runs after shaping.

Diffs=
291a3a02b Bidi Text Support (#4282)
2022-10-11 21:07:14 +00:00
luigi-rosso
c41d325c1c Adding artboard clip test.
Adds a test for the issue fixed in #4281 (the duolingo artboard clipping issue).

Diffs=
0ffa502c4 Adding artboard clip test. (#4283)
2022-10-04 19:30:41 +00:00
zplata
2ae76fb08a chore: release v3.0.4 3.0.4 2022-10-04 17:40:39 +00:00
zplata
ff5bd4f5f6 Updating version files 2022-10-04 17:40:32 +00:00
luigi-rosso
e473ae7c82 Fix non-framed artboard origin rendering.
Fixes issue caught by Duolingo with nested artboards and non-zero origins. Adds AABB::fromLTWH to keep AABB to Rect tidy.

Diffs=
99c5590bc Fix non-framed artboard origin rendering. (#4281)
2022-10-03 21:39:35 +00:00
csmartdalton
d53d5ae44d clang-format updates
- Put braces on their own line
- Turn off single-line case labels

Diffs=
32e79999a clang-format updates
2022-10-03 20:24:54 +00:00
zplata
3d8cbf3623 docs: fix links and some verbiage in the iOS runtime README
Fixing some verbiage and links from copy/pasta from the README docs updates

Diffs=
b9f2a3491 docs: fix links and some verbiage in the iOS runtime README
2022-10-02 21:25:11 +00:00
umberto-sonnino
84b6fff52a Optional width and height parameters for thumbnailer
This is to generate custom sized images from SVGs, defaults will still work the same as before.

Diffs=
434223338 Optional width and height parameters for thumbnailer
2022-09-28 13:30:03 +00:00
zplata
4bd77a597c chore: release v3.0.3 3.0.3 2022-09-27 13:49:58 +00:00
zplata
8aeb507bf9 Updating version files 2022-09-27 13:49:53 +00:00
mjtalbot
00bf012205 fix: remove pr merged check on publish cocoapods step in gh workflow
no longer a line that's needed:
https://2dimensions.slack.com/archives/CLLCU09T6/p1663602758997489

Diffs=
37cedffa4 fix: remove pr merged check on publish cocoapods step in gh workflow
2022-09-27 12:24:03 +00:00
luigi-rosso
3b54bfa468 Line breaker
Updating the line breaker to support:
- forced line breaks (return characters)
- store break points in context of runs (no searching when breaking)
- perform alignment (center/left/right)

In order to implement tests for this in Rive, I moved the Harfbuzz shaper into Rive (conditionally compiled out) but now we can test line-breaking logic in Rive core.

Since I had to update some of the build scripts, I ran the same new premake formatter we've been using.

<img width="910" alt="CleanShot 2022-09-19 at 21 03 53@2x" src="https://user-images.githubusercontent.com/454182/191164998-6b7b131b-b624-41c7-81d2-c2e01a050680.png">

Diffs=
a1d921c85 Line breaker (#4249)
2022-09-23 23:11:01 +00:00
luigi-rosso
a7f2caee0a Implement a dynamic array (simple vector for marshaling).
While working on marshaling the RenderFont abstraction to Dart FFI and WASM, it became clear that dealing with vectors inside of vectors gets tricky.

We can wrap one single vector into a return struct like:
```
struct EasyToMarshal {
  std::vector<float>* ptrToVector;
  float* dataInVector;
  size_t size;
};
```
This is what we currently do and FFI/WASM is expected to then call in to C++ to delete ptrToVector when it's done with the data.

This gets problematic to do when ptrToVector contains types that internally contain more vectors. The size and memory layout of vector isn't guaranteed across platforms with different STL implementations.

The result from the shaper was a vector of RenderGlyphRuns:
```
struct RenderGlyphRun {
    rcp<RenderFont> font;
    float size;

    std::vector<GlyphID> glyphs;       // [#glyphs]
    std::vector<uint32_t> textOffsets; // [#glyphs]
    std::vector<float> xpos;           // [#glyphs + 1]
};

std::vector<RenderGlyphRun> shapeText(...){}
```

This PR introduces a DynamicArray (totally up for renaming this to something less lame) which makes it really easy to marshal DynamicArrays inside of other DynamicArrays as we know the memory layout is just like rive::Span (a pointer and a size).

Separately, this does make me wonder if we should use uint64_t for size in DynamicArrays so we can guarantee those are always 64 bit (the FFI and WASM tooling doesn't make it easy to marhsal runtime determined sizes).

Diffs=
e62737cf9 include cstring for memcpy
468dd3a2b Add growToFit, assert we didn’t overflow size_t, and in place constructor calls
f0947d32f Add realloc down to actual used size from capacity.
516d0fc12 Move resize to builder and rename to simple array.
091904d22 malloc/realloc version
e574043f7 More windows fixes
c1f5b96ec Fix windows compiler warning.
164911445 Implement a dynamic array (simple vector for marshaling).
2022-09-19 23:53:57 +00:00
csmartdalton
270d2ac61e Add a make_rcp<>() helper method
Saves us from having to type the class name twice:

  make_rcp<MyClass>()

vs.

  rcp<MyClass>(new MyClass())

Diffs=
51eb2ee20 Add a make_rcp<>() helper method
2022-09-13 18:33:39 +00:00
csmartdalton
0bb7753894 Make RefCnt templated
Saves a virtual destructor when otherwise not needed.

Diffs=
2ad434e80 Make RefCnt templated
2022-09-13 18:31:35 +00:00
luigi-rosso
36e644df4d Spam cleanup from previous PR
Diffs=
fffc91e00 Cleanup
2022-09-08 21:37:48 +00:00
luigi-rosso
40f754d36a Fixing skia viewer and renderer builds.
A couple of fixes:
- skia renderer uses new harfbuzz dependency paths
- skia builds of viewer don't try to include tess specific logic for example atlas

Diffs=
45293a868 oops
f8a8f4c0c override skia cache folder
d86875260 Try
10b22bfe3 Attempt using correct skia dir
85feea448 more fixes
0b0371b24 switching to bash
ad07fbd18 Tweak for linux build
dab0642a0 Adding config dirs for linux
7e5a2aa47 Build harfbuzz from the recorder builder
a77709a68 Fixing skia viewer and renderer builds.
2022-09-08 20:56:47 +00:00
csmartdalton
ffdf92d2d8 Simpify RawPath::Iter
Implement Iter as an STL-style iterator that can be traversed very
efficiently using range-for:

  for (auto [verb, pts] : rawPath) { ... }

Manually inject the implicit moveTos in RawPath (namely, the implicit
moveTo(0) at the beginning of a path, if the client didn't add one, and
a similar moveTo after close).

The implicit moveTos fix a bug in RawPath::bounds where we were not
accounting for the implicit moveTo(0), as well as a bug in
ContourMeasureIter::tryNext where we expected the first contour in a
path to begin with PathVerb::move.

With the implicit moveTos guaranteed to be in the raw path, the iterator
can be simplified to just peek back one point and give a contiguous array
beginning with p0 for each verb. In addition to generally simplifying
things, one more perk of having all the points contiguous is that it
also enables fast SIMD loads.

IterateRawPath bench result:

  MacOS NEON: 8.71ms -> 5.02 (58%)
  Windows SSE: 5.63ms -> 4.20 (75%)

BuildRawPath bench result:

  MacOS NEON: 2.09ms -> 2.19 (105%)
  Windows SSE: 2.18ms -> 2.27 (104%)

Diffs=
fdeff54d1 Simpify RawPath::Iter (#4157)
2022-09-06 20:09:02 +00:00
luigi-rosso
c396ab522a building harfbuzz with our premake setup
- builds and gets harfbuzz the same way we do our other dependencies
- slight tweak to building libpng so it also builds from the dependencies folder

Diffs=
0e69f1166 building harfbuzz with our premake setup and removing third_party (for now)
2022-09-02 23:49:15 +00:00
csmartdalton
2c04f0e84f 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)
2022-09-02 16:08:35 +00:00
luigi-rosso
57b703b73a Example for how to pack an atlas with tools
Implements an example Atlas packer (ideally run offline/in a pre-runtime step using the runtime API). Imagine a game engine like Defold using this at edit time/from within engine tooling to pack all the images necessary for all the Rive files in one level into a single Atlas/set of Atlases to minimize state changes when drawing the whole scene.

Example implementation is mostly here: packages/runtime/viewer/src/sample_tools

The example does both atlas packing and runtime image resolving from the Atlas from the same set of utility classes and their corresponding objects in order to keep the example simple (no serialization of the atlas metadata or pixels). It also uses a very naive packing technique, but it illustrates these main features:

1. find all the image assets in a file
2. packing them sequentially into an atlas
3. ...while building up metadata of where they are in the atlas
4. strips the images from the file
5. shows how to then re-load the file (with no in-band images) and use the generated atlas
6. implements a FileAssetResolver to resolve the images in the Atlas and provide UV transforms

Steps 1-4 are what an engine would do at edit/export time. Steps 5-6 show what a runtime would do to then use the files generated in steps 1-4.

All of this is implemented in the viewer, minor changes were necessary to the runtime to transform UVs with a transform provided by the RenderImage and fix some bugs. See how the viewer wires this all up here: 86dbad80c6/packages/runtime/viewer/src/viewer_content/scene_content.cpp (L185-L233)

Diffs=
38b70a98d Cleanup
ac44c1ad7 Fix broken test.
40d2fa966 Fixing UV modification at load time.
736bcf133 Adding an example atlas packer.
e42e484eb Starting to add example atlas packer.
438f98716 Adding imgui menu bar
2022-08-30 23:15:46 +00:00
csmartdalton
6af3685548 Add a simd library for SSE / NEON / WASM_SIMD
Adds a "simd" namespace with vector utilities (SSE, NEON, WASM_SIMD),
and implements RawPath::bounds in SIMD. This namespace relies
exclusively on the latest clang vector extensions, so from here on, Rive
needs to be built with a recent clang. On our own bots, we had to bump
the Android builder to NDK r25b, the Ubuntu builder to 22.04, and the
MacOS builder to macos-12.

RawPathBounds bench result:

  MacOS:   2.37ms -> .579 (4.1x)
  Windows: 3.53ms -> 1.68 (2.1x)

Windows SSE can be optimized down to .927ms (3.8x) by forcing the SSE
min/max instructions, but they have different behavior with NaN, which
is why clang doesn't use them directly, so it seems like an
over-optimization at this point.

Diffs=
986b49674 Add a simd library for SSE / NEON / WASM_SIMD (#4199)
2022-08-30 22:55:04 +00:00
luigi-rosso
46e19c331d "fix" broken tess test
When using the earcut triangulatation we pass through the vertex buffer straight from raw path and just use an index buffer generating by the triangulation.

Diffs=
ba0406a89 Fix tess test.
2022-08-30 18:14:27 +00:00
mikerreed
437701c38f Update call site for RawPath constructor
oops - forgot to build the tess renderer on the prev PR (should update the bots to build viewer in a few configs)

Diffs=
a7615ab7c Update call site for RawPath constructor
2022-08-29 20:01:54 +00:00
mikerreed
410d31c47e Change factory to use span
... and add a test (doh).

Diffs=
194a38e78 Change factory to use span
2022-08-29 19:56:19 +00:00
csmartdalton
e46fe4ffa5 Clean up some windows warnings on rive runtime tests
Diffs=
93229eacd Clean up some windows warnings on rive runtime tests (#4198)
2022-08-29 16:48:10 +00:00
mikerreed
832a59ea98 use contour_measure
Diffs=
ad4ff71df use contour_measure
2022-08-27 17:45:56 +00:00
mikerreed
ec4848ae51 Utilities for rawpath
- addPath()
- operator==

Diffs=
f9a5698be Add != operator
2022-08-27 00:29:33 +00:00
luigi-rosso
255a4f1a67 Adds a utility to strip out FileAssetContents for given FileAsset types.
Adds a ```File::stripAssets``` utility method that is optionally compiled in. This allows removing in-band asset bytes from the file. It only does this for the provided asset types. Right now we only put image assets in-band, but in the future we may have fonts, scripts, sounds, other .riv files, etc so allowing the utility to only strip specific concrete file types is nice to have.

The next step will be to use this utility to show how you'd create an atlas out of the in-band images, strip out the images, and save a smaller .riv that uses images from that generated atlas.

I envision adding more utility methods like this for tools that want to manipulate Rive content at build/pre-package time. These should be able to be compiled out as they are rarely necessary at mass-consumption runtime (I doubt anyone wants these in WASM unless they're building their game engine, not just the player, in JS).

Diffs=
698af558e Fix linux build.
cb742eb08 Adds a utility to strip out FileAssetContents for given FileAsset types.
2022-08-26 23:41:10 +00:00
csmartdalton
85c926cc09 Build RiveSharp with clang
We may want to try and standardize on clang SIMD vector extensions,
which means everything has to build with clang.

Diffs=
07186fc98 Build RiveSharp with clang (#4194)
2022-08-26 16:37:39 +00:00
mikerreed
fb1d3ccec3 add != to Mat2D
fissioned from https://github.com/rive-app/rive/pull/4186

Diffs=
59ecc6712 Add != operator
2022-08-26 11:28:14 +00:00