Commit Graph

22 Commits

Author SHA1 Message Date
mjtalbot
9122e58a54 Libraries
Bunch of changes, i think its at the point where it will be helpful to get a review, there is a *lot* of outstanding work to do here, but i'm hoping that much of it can be done while this is in master but not enabled for uat yet. so @susan101566 and I can work through that set together, with smaller more targeted fixes and changes.

There are a couple of things i want to figure out to make sure we can merge this:
- is the Resolver approach going to work (library components resolve to real components)
- writing library assets into the parent needs a bit more love, it should not cause problems unless you're using libraries
- I want to do a small refactor on the exporter before merge to keep asset writing and asset index updates together as suggested by @susan101566. there's a larger refactor here but i think that can be done in due course.
- re-check editor-only deliniation

After refactoring those i also need to re-check that all these things still work, because chances are i've broken something in the meantime.

for
    using a library in as a nested artboard &
    using a library as part of using a nested artboard that contains a library
check
    using a library animation
    using a library stateMachine
    using a library stateMachineInputs
        we can key state machine input changes
        we can trigger nested state machine input changes from teh state machine editor
    using a library with assets

exporting all the above and view in cpp viewer
exporting all the above and view in dart viewer

There is a large list of items that need to be worked on beyond this. but hopefully we can do that more incrementally. this includes but is not limited to:
- object validations make sense
- the asset panel is interacting as we want
- right click menus make sense
- out of band loading works
- library api failures are handled
- refactor how we add library assets
- refactor asset exporting
- tracking
- smi paths'

Diffs=
9d8a7e81fa Libraries (#9255)

Co-authored-by: Arthur Vivian <arthur@rive.app>
Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
Co-authored-by: Susan Wang <susan@rive.app>
2025-04-03 17:27:06 +00:00
rivessamr
306a744a0c Fix viewer tess builds
The following now builds and runs as per README in viewer:

./build_viewer.sh gl tess run

Diffs=
7d00d35d3 Fix viewer tess builds (#7935)

Co-authored-by: rivessamr <suki@rive.app>
2024-08-24 00:01:52 +00:00
rivessamr
6acee5a096 Add webp decoder.
We've been needing this for a while for the game engines but we also need it to support decoding webp images for use in the editor with the Rive Renderer.

I haven't instrumented the build properly to use SIMD extensions, but I left some notes for how to do so. This PR unblocks the use of WebP, let's do some perf improvements in a follow up that perhaps the runtime team can own?

Diffs=
160d9eefb Add webp decoder. (#7883)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
Co-authored-by: rivessamr <suki@rive.app>
2024-08-22 04:33:03 +00:00
luigi-rosso
c134293d05 Yoga layout runtimes
Starting to implement layout component with Yoga in CPP. Layouts works on iOS, macOS, Android and web runtimes.

https://github.com/rive-app/rive/assets/186340/e09e639a-d38e-46b8-951d-a5ecc392b53a

Diffs=
6c76b425f Yoga layout runtimes (#6787)

Co-authored-by: Luigi Rosso <luigi.rosso@gmail.com>
Co-authored-by: Philip Chung <philterdesign@gmail.com>
2024-06-11 16:03:05 +00:00
luigi-rosso
6ecd588295 Simple libjpeg
Original libjpeg (turbo was forked from an older version of this). Note C api is still the same.

Diffs=
45b998e68 Simple libjpeg (#7277)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
2024-05-16 23:46:24 +00:00
csmartdalton
2080d11ac8 Clean up emscripten build
* Don't use an external premake extension for emscripten; just set up the environment ourselves to build with emscripten.

* Delete the spots that turned on the '-pthread' flag for emscripten.

* Get the WebGL and WebGPU builds compiling again and add a github workflow for them.

* Delete the bubbles example. It didn't compile on android or wasm and caused confusion. It's in the git history if we want it back.

Diffs=
ac0d97c12 Clean up emscripten build (#6531)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2024-02-01 03:54:32 +00:00
luigi-rosso
bf1e8f8eff fix viewer build
Diffs=
a8c86e949 fix viewer build (#6527)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2024-01-27 22:20:31 +00:00
luigi-rosso
3255a2aeb2 Lua formatter
Format all our lua scripts with Stylua

https://www.notion.so/rive-app/Formatters-be8845abbca34e39b5d4c212b2437b3f?pvs=4

Diffs=
858215cc4 Lua formatter (#6525)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
2024-01-26 23:51:01 +00:00
luigi-rosso
80c037c2d7 Audio engine
Adds an audio engine abstraction (implemented with miniaudio) in Rive. We can selectively replace it with other abstractions later if we find miniaudio isn't well suited everywhere but I'm confident it will be based on flexibility with getting it working in the recorder.

Adds audio support in:

- packages/rive_common
  - WASM: rive_audio_wasm.dart
  - FFI: rive_audio_ffi.dart
- packages/runtime
- packages/recorder

Subsequent PR will add support in:

- packages/rive_unity
  - This is getting meaty enough...
- packages/rive_flutter
  - This requires publishing rive_common so I want to make sure this is reviewed and accepted before publishing
  - I'd also prefer to merge layout constraints into rive_common before this lands.

Editor features:
- Updated preview window:
<img width="248" alt="CleanShot 2024-01-15 at 14 44 31@2x" src="https://github.com/rive-app/rive/assets/454182/a9588be6-8370-4e22-ab32-af1e9ed71183">

- Preview waveforms in the timeline:
<img width="651" alt="CleanShot 2024-01-15 at 14 44 53@2x" src="https://github.com/rive-app/rive/assets/454182/2710667f-838f-483d-9647-e2bcb9e0237a">

- Subsequent PR will also use threads in web editor build (currently uses a time/frame based decoder to offload ui). I can't do that until I can verify the Shared Memory access is granted once rive_common lands in pub.dev and then we can push to UAT.

Diffs=
73bf11db3 Audio engine (#6454)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
2024-01-23 04:11:42 +00:00
mjtalbot
d276194d24 add ability to attach callbacks when resolving file asset listeners
Bascially add tracking of fileAssetReferencers from file assets, so that when file assets update, they can tell things that reference them to update also.

its worth looking at the rive-flutter & runtime implementations

in cpp it looks like we can hook into the delete hooks nicely to clean up after ourselves (so that when artboards get collected we are not holding references to them from file assets)

in dart this is more of a problem, however using weakReferences we do end up seeing artboards go out of scope
but weakReferences requires us to bump to a min dart of 2.17 (we are 2.14 in flutter & 2.12 in our editor atm)

the update here also uses the referencers to mark fonts dirty when fonts are set, which causes them to be updated on the next draw cycle

(video showing font updates working properly now in dart)

https://github.com/rive-app/rive/assets/1216025/d65ea2cf-95d6-4412-b8f5-368cda609d0b

(video showing how referencers get collected and trashed in dart, it looks like we hold onto about 10 of them at a time.. but they do drop off over time. also we start with 2 references, the main artboard and the artboard instance)

https://github.com/rive-app/rive/assets/1216025/b11b7b46-aa9d-4dcc-bc11-f745d8449575

Diffs=
7bc216b03 add ability to attach callbacks when resolving file asset listeners (#6068)

Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
2023-10-17 16:04:05 +00:00
csmartdalton
142d059a87 Lift tess decoders into a static lib
Add a packages/runtime/decoders project that can be reused by more projects than just the tess renderer.

Diffs=
b69ae1312 Lift tess decoders into a static lib (#5709)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-08-01 13:29:49 +00:00
luigi-rosso
7e2e70df67 Runtime Text!
Not ready for review! But feel free to peek :)

Starting to add support for runtime text. This is the bulk of the implementation marrying the Core objects to the text engine we've been working on at the runtime level. PRing in draft early to let tests run.

Also refactors some class and file names to disambiguate more clearly with the Core objects.

Diffs=
051769242 Runtime Text! (#4741)
2023-02-01 00:31:43 +00:00
luigi-rosso
d248296923 Cleaning up libpng premake to be isolated/stand-alone.
libpng_premake is now standlone!

You should just need to dofile the premake5_libpng.lua file. This will expose a variable called "libpng" which you can then use to point to include dirs, see how the viewer premake does this:
3a8b2203e2/packages/runtime/viewer/build/premake5_viewer.lua (L117)

You link to it by name:
3a8b2203e2/packages/runtime/viewer/build/premake5_viewer.lua (L124)

This should automatically setup the dependency tree for building in correct order, but I found that on some versions of I premake I need to force the order by telling the project it depends on a dependency like so:
3a8b2203e2/packages/runtime/viewer/build/premake5_viewer.lua (L26)

This just ensures that libpng always builds before rive_viewer.

Diffs=
404a04d35 Cleaning up libpng premake to be isolated/stand-alone. (#4713)
2023-01-23 19:25:54 +00:00
luigi-rosso
ad04f39753 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:06:03 +00:00
luigi-rosso
8f690ee101 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:10:03 +00:00
luigi-rosso
c4c90718a7 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:48:16 +00:00
luigi-rosso
ce0af130b3 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:14:30 +00:00
luigi-rosso
578a73bab3 Force re-link viewer builds.
Our viewer has a few static lib dependencies like rive, rive_tess_renderer, etc. If you work in isolation on one of those dependencies, the viewer binary won't re-link. This was causing us to have to clean the build every time. The right solution is to make the build depend on any changes to those files. I couldn't find a good way to do that without merging all the premake files (we used to do this with dofile).

For now an easy solution is to just delete the viewer binary which forces a re-link any time you call build, which I think is ok.

Diffs=
c07c43a80 viewer premake depends on premake file for rive_tess
08c607bfe Force re-link viewer builds.
2022-08-24 02:33:15 +00:00
mikerreed
828746d96c Always build harfbuzz in viewer
this allows us to always have text content available for testing (since it is independent of renderer backend)

This also abstracts a factory for building RenderFonts (in ViewerContent) -- again, since that decision is independent of renderer.

Diffs=
4802c650a Always build harfbuzz in viewer
2022-07-29 18:54:15 +00:00
mikerreed
69489eab6c Work on font-fallback
This is a way to handle missing characters from a given Font -- we detect this, and then try using other font(s).

The current test just adds some Chinese characters and tries to draw them (which are not present in most of our sample fonts).

CoreGraphics backend handles this for us, we just needed to notice when they introduce a new/different font in the GlyphRun, and wrap-it.

Diffs=
4f4b79858 Work on font-fallback
2022-07-28 13:19:05 +00:00
luigi-rosso
5d5f859d61 Adding rive_tess
This is the part that was split out from the other larger PR (#4020).

Diffs=
17c822472 Tabs to spaces and add comments to mat4
aa9448468 Adding rive_tess
2022-07-18 23:00:48 +00:00
luigi-rosso
f17eb06604 Multi backend viewer
Re-works viewer to use GL, Metal, and optionally in the future D3D. Also introduces a new renderer and allows the viewer to be compiled with either Skia or the new example Tess renderer (with either GL or Metal).

I want to re-work the dependency building to be more similar to what Mike did with the third_party directory in a separate PR. It's pretty similar to what's been done here, but generalized at the top level which I think is nice and more re-usable. Also removes the need for some of my path building shell scripts...

There's a new README.md in the viewer directory with some details.

```
cd packages/runtime/viewer/build/macosx
```

Build and run with a Metal backed Skia Renderer:
```
./build_viewer.sh metal skia run
```

Build and run with a GL backed Skia Renderer:
```
./build_viewer.sh gl skia run
```

Build and run with a Metal backed Tess Renderer:
```
./build_viewer.sh metal tess run
```

... and so on

You can also clean directly from the same command:
```
./build_viewer.sh metal tess run clean
```

Diffs=
86d5b0924 Cleanup skia build
83506229a Fix skia dir.
7d4a3bdcf Remove tess to simplify PR.
14346ad9e Nuke old viewer
fba2696cf See clang-format after update
15b8fd753 Remove mat4 test from main rive project
69a2ce9ad Render font cleanup
abd8fa89b Missed files.
e690870a4 Move shader.h and remove formatting for generated files.
afc437b17 Tweaks for failed tests.
2f9a936fc Moving mat4 to tess renderer.
27a3606d6 Cleanup
a4034ff0f Adding viewer readme
bebcd8abe Adding text viewers.
5a1da4ed2 Getting image rendering working in with tess
2c81fee81 Silence deprecation warning.
52f410dfc Getting mesh rendering working.
8de842c7f Starting to use sokol to render meshes. Adding Mat4 class.
dbd5c79b5 Updating clang format for objc
ca0ea9d84 Getting image content working too and fixing contention with sokol
79405a77d Starting to add handle draw support.
8b9f14a16 Adding gl renderer for skia.
af23274ae Adding support for rendering Skia with Metal.
92139ce08 Adding tess renderer.
dc3e1b49b Adding dependencies at top level
22fa8e6ce Updating build scripts
b5cb990aa Merging with latest master.
d08ac18e2 Reorg
a828e92da Updating project json
086890736 Cleanup unused glfw and gl3w for new viewer
55161f36c Using sokol.
72b62b563 Separating GL and TessRenderer.
611b991b6 Adding limits import to fix compilation on all platforms.
820ab8e2f Missed build files.
0964b4416 Stubbing out a generalized viewer and alternate renderer.
2022-07-16 04:21:44 +00:00