1438 Commits

Author SHA1 Message Date
csmartdalton
6ab1ea9e8e Remove the 'EMIT_OFFSCREEN_VERTEX' macro in PLS
D3D and metal both have an opposite sense of Y when rendering to an
offscreen texture. This knowledge used to be baked into the shaders, but
that makes it difficult to correctly get triangle windings when we're
using face culling. This PR instead moves this knowledge of the Y
direction into variables by negating the Y viewport uniforms when
necessary.

This change also exposed an issue in minify.py where HLSL semantic names
were getting collisions because they are NOT case sensitive. So this
change also updates minify.py to not use lower case letters in
"@exported" names.

Diffs=
623766365 Remove the 'EMIT_OFFSCREEN_VERTEX' macro in PLS (#5615)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-07-20 01:20:14 +00:00
luigi-rosso
fc27a560cb Fixing modifier ranges not updating on the right frame.
This animation wasn't ending up on the right frame when quickly moving the cursor left->right. This was an error with update cycle order of the text modifier group vs the text object itself. The modifier group needs to always update before the text object!

@JcToon showed this issue to me in the office today...

https://github.com/rive-app/rive/assets/454182/76692e1d-e670-4324-a8ac-8c8ce0748e52

Diffs=
b17671130 Fixing modifier ranges not updating on the right frame. (#5623)
2023-07-19 23:33:05 +00:00
philter
28b2ab431a Fix dependency order issues for Follow Path
Since we removed our use of PathComposer and are recomputing our metrics path in FollowPathConstraint, a dependency order bug was resulting in the constrained component being updated BEFORE its follow path constraint. Since we generate our path in FollowPathConstraint.update, this meant the constrained component wasn't getting an up to date path. This resulted in unexpected behavior in the editor, such as https://github.com/rive-app/rive/issues/5569.

Diffs=
d1f8710f5 Fix dependency order issues for Follow Path (#5595)
2023-07-18 20:55:32 +00:00
luigi-rosso
8a34925c5c Baseline Origin
Allows setting the origin at the baseline:

<img width="1086" alt="CleanShot 2023-07-13 at 15 25 54@2x" src="https://github.com/rive-app/rive/assets/454182/eab10c64-75f0-4272-a5d5-3eedb92dbf7e">

It also changes how the text moves when line spacing is changing, keeping the text aligned to the origin (no swimming origin).

Drafting to allow tests to run, want to add the runtime (c++) component to this.

Diffs=
8e82475b8 Baseline Origin (#5577)
2023-07-17 23:36:45 +00:00
luigi-rosso
f85cb28382 Add option to quantize time to whole frames of framerate.
This ensures that only whole frames are displayed. Good for ensuring the frames you see in the editor are what is shown at runtime and for creating more stop-motion like effects efficiently.

![CleanShot 2023-07-13 at 15 36 21@2x](https://github.com/rive-app/rive/assets/454182/c796c493-c359-469e-b5f4-8dd37686e7b7)

Diffs=
8b49fcbc5 Add option to quantize time to whole frames of framerate. (#5578)
2023-07-17 22:11:54 +00:00
philter
416e9aac85 Follow path should respect constrained component rotation if orient is off
Verified with Alex that the correct behavior if follow path orient is off is to respect the constrained component's rotation value. I missed this in my test cases.

https://github.com/rive-app/rive/assets/186340/69fab499-016d-458a-9159-50b93e373b3c

Diffs=
b8e5473b9 Follow path should respect constrained component rotation if orient is off (#5601)
2023-07-17 21:56:57 +00:00
mjtalbot
f43011775e Code generator fixes alternative
three commits

1 - updated the generator
2 - ran generator against core
3 - ran generator against core runtime

i tried to remove all the changes that are not the comment change

Diffs=
1292ebe56 Code generator fixes alternative (#5584)
2023-07-14 11:05:56 +00:00
csmartdalton
7be546cd4b Use v_edgeDistance.y to differentiate between PLS strokes and fills
Now that we have two coverage components per pixel, it's cleaner to use the second, which is otherwise unused for fills.

Diffs=
4587a3d1d Use v_edgeDistance.y to differentiate between PLS strokes and fills (#5582)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-07-14 04:15:32 +00:00
csmartdalton
d59e6856a8 PLS cleanups
The PLS code has started to devolve into chaos. This PR is a start at attempting to de-spaghettify some of it.

It also fixes a bug that got introduced in bae069339. That PR assumed that interior triangulation did not write contour records to the GPU, but that's false. "outerCurve" patches still need a contour record in order to get the pathID.

Diffs=
60296f34f PLS cleanups (#5580)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-07-14 04:13:56 +00:00
luigi-rosso
beda60a037 Adding target origin to transform constraint.
Allows transforming to an origin within the bounds of the target.
Details: https://2dimensions.slack.com/archives/CHMAP278R/p1689203310676079

Diffs=
094afae0b Adding target origin to transform constraint. (#5559)
2023-07-13 17:33:53 +00:00
csmartdalton
1a09c28b2f Stop automatically pruning empty segments in RawPath
RawPath used to discard empty segments from lineTo/quadTo/cubicTo. However, it was still possible produce empty segments when transforming a path, and RawPath didn't catch those.

This change adds a simple utility, RawPath::pruneEmptySegments(), and passes the responsibility on to the client for using this method when necessary (including after a transform).

Diffs=
bae069339 Stop automatically pruning empty segments in RawPath (#5557)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-07-12 23:42:13 +00:00
luigi-rosso
904e3d70de Line Height & Paragraph Spacing
Need to fix the caret with small line heights and check something odd re: bounding boxes in Flutter Web but want to start running tests.

Diffs=
2d2d8c413 Line Height & Paragraph Spacing (#5552)
2023-07-12 23:16:35 +00:00
luigi-rosso
b207a8b785 Runtime modifiers
Finally ready! Some highlights:
- Text objects own TextModifierGroups
- A TextModifierGroup defines a set of operations (Modifiers) to perform on ranges of the whole Text object.
- The ranges are defined by TextModifierRanges which are owned by TextModiferGroups. Each TextModifierGroup can have multiple TextModifierRanges, meaning that the set of Modifiers will perform on the final selection defined by TextModifierRanges.
- TextModifierRanges select portions of the text in a Text object based on rules that define the strength of the selection. The strength of multiple TextModifierRanges can be blended together meaning selection strength can be above 1 and below 0 (optionally clamped).
- There are three fundamental modifications:
  1. Transform where glyphs are individually transformed by a matrix
  2. Paint where glyphs are drawn with different paint (currently only opacity is supported, but later Fill and Stroke will be too).
  3. Shape where a selection can have shaping properties (currently variable axes later also font size) changed. This is the most complex one as it requires [two pass shaping](ef2d0d3ca3/packages/runtime/src/text/text.cpp (L578-L598)).

Diffs=
8086bdbf9 Runtime modifiers (#5512)
2023-07-12 18:19:57 +00:00
csmartdalton
593cc0d0c1 Get more compiling on MSVC
Diffs=
1a271c437 Get more compiling on MSVC (#5547)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-07-11 20:47:39 +00:00
csmartdalton
a60a7e3b83 Rename "breadcrumb" triangles to "grout" triangles
Diffs=
cd6a563e1 Rename "breadcrumb" triangles to "grout" triangles (#5542)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-07-11 17:46:33 +00:00
philter
0fe6ad0b16 Swap propertyKeys between follow path and text core defs
Restoring the propertyKeys for follow path constraint since they were already being used by animators.

Diffs=
5a18c89bd Swap propertyKeys between follow path and text core defs (#5543)
2023-07-10 23:05:32 +00:00
philter
ee22a5a8ba Fix conflicting core key ids and set follow path offset to default false
Not sure how the previous PR didn't fail with the core def conflicts. Maybe something else got merged in the meantime?

Also changed offset to default to false to be consistent with other constraints.

Diffs=
942bb8c94 Fix conflicting core key ids and set follow path offset to default false (#5541)
2023-07-10 21:15:45 +00:00
csmartdalton
4e59808fdd Initial D3D11 backend for PLS
Diffs=
9c1d1e4ff Initial D3D11 backend for PLS (#5534)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-07-10 19:59:55 +00:00
philter
8b4728eb5e Follow Path Constraint (Editor & CPP Runtime)
This PR includes a bunch of unrelated core defs that were missing from the CPP runtime to bring us up to date. Requirements and test cases here: https://www.notion.so/rive-app/FollowPathConstraint-8a1de3aa7494461c8ba79b8915acfd9d?pvs=4

Diffs=
dcf320c64 Follow Path Constraint (Editor & CPP Runtime) (#5510)
2023-07-10 17:26:45 +00:00
luigi-rosso
2ebbafcd9d Adding origin to text.
Adds origin to text object that works just like the origin of a parametric path. It can be moved in freeze mode too. Adds support in the editor, Flutter runtime, and C++ runtime.

Diffs=
9b8dacbac Adding origin to text. (#5533)
2023-07-07 22:11:33 +00:00
umberto-sonnino
6524c7847b Add CMake support for building Android and Catch2 Tests
Diffs=
797fb4cbd Add CMake support for building Android and Catch2 Tests (#5468)
2023-07-07 13:30:53 +00:00
csmartdalton
0b1562d6e5 Implement interior triangulation for PLS
Adds a drawing mode for large paths that:

1. Subdivides the curves into sections spanning no more than 16 segments.
2. Draws the outer curves using the existing PLS algorithm.
3. Triangulates the path interior into non-overlapping triangles and draws them separately.

In addition to simply eliminating overdraw, these interior triangles:

1. Can be drawn without raster ordered synchronization (since they don't overlap).
2. Don't have to update the coverage buffer (since we know each fragment is the final one for the path at that pixel).

Both of these properties lead to savings in a PC environment that uses read/write textures for pixel local storage (45 fps -> 78 fps on the Rope.riv at 3840x2241).

Apple Silicon also benefits from these changes, even though we can't turn off raster ordering there and the coverage updates should have been much cheaper in a tiled rendering architecture (375 fps -> 525 fps on the Rope.riv at 3200x2102).

Diffs=
16c4503b8 Implement interior triangulation for PLS (#5515)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-07-01 03:56:46 +00:00
csmartdalton
801f47de30 Consolidate uniforms into a single buffer
We were set up to have different uniform buffers for every draw, but it makes more sense to just put all the info into a single shared buffer.

Diffs=
0796b5c1c Consolidate uniforms into a single buffer (#5447)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-30 19:58:16 +00:00
luigi-rosso
9d61fc7994 Increases the margin for the approx call to some of the wangs formula…
… checks.

Diffs=
7ee5f7d5a Increases the margin for the approx call to some of the wangs formula… (#5506)
2023-06-28 21:17:34 +00:00
luigi-rosso
f93d2756dc Runtime ellipsis
Runtime support for different overflow types:
- ellipsis
- clip
- hide
- show

Diffs=
2f224da7f Runtime ellipsis (#5482)
2023-06-27 19:24:00 +00:00
luigi-rosso
e6fc017e05 fix viewer build
Fixes an issue I introduced when adding the features functionality. I imported harfbuzz from our text header which causes all downstream users to need to know where the harfbuzz includes are. This isn't necessary and slows down the compiler too.

Diffs=
500d878a2 fix viewer build (#5493)
2023-06-26 22:41:53 +00:00
luigi-rosso
dd98bfc2df Feature options on Fonts
Adds runtime and editor support for setting feature flags on a Font.

The biggest change to the font engine is that the feature options are now stored on the Font object itself instead of hard-coded during shaping. This is nice as it requires no extra data to be piped through for individual run styling. It also means that we generalized the concept of creating a variable font as configuring a version of the font (see withOptions replacing makeVariation) so that variable axis and feature settings are treated as options to a Font configuration.

This also allows us to track existing variations and options on the configured Font such that any further call to "withOptions" on that already configured Font will propagate previous changes if not overridden. This fortuitously also fixes an issue the modifiers were exhibiting where a variation set on the TextStyle that wasn't part of the modifier set would be lost.

Diffs=
31d9a5424 Feature options on Fonts (#5479)
2023-06-26 17:36:35 +00:00
umberto-sonnino
beb92c6995 Runtime/interpolate states cpp
Quite a lot of churn here, I created this off of https://github.com/rive-app/rive/pull/5429 which already generated a lot of code.
On top of it, I also generated the C++ classes, which in turn added a bunch of other missing things related to text.
There's *not that much non-generated* code here, but I'll keep this draft for now..?

Diffs=
8b7587241 Runtime/interpolate states cpp (#5437)
2023-06-23 21:36:53 +00:00
csmartdalton
fa42295ceb Introduce a DrawList to PLS
It's been great being able to draw everything in a single call, but we
are now at a point where we need separate draws for coarse
inner-path-fan tessellations and non-raster-ordered rendering. We will
probably also find separate draws superior to an uber shader for nested
clipping and raster images.

This change (finally) introduces a DrawList, which is capable of
recording all the types of draws we may need. Implementing the DrawList
also required incorporating EXT_base_instance into the GL backend, which
in turn necessitated a nice cleanup of our GL extension wrangling.

Diffs=
28c49dbbd Introduce a DrawList to PLS (#5432)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-21 00:51:51 +00:00
csmartdalton
f825a604c1 Delete the DrawParameters buffer
Wrong direction. We can do better by packing the wedge size in the vertex data and using the built-in "base instance".

Diffs=
80117d7b1 Delete the DrawParameters buffer (#5441)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-16 18:56:18 +00:00
csmartdalton
4e5899e3b7 Cleanup the fibonacci growth function in TrivialBlockAllocator
I accidentally overwrote this code when I pushed new changes to the original PR on github.

Diffs=
e00611f6c Cleanup the fibonacci growth function in TrivialBlockAllocator (#5430)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-15 18:22:15 +00:00
csmartdalton
4fd22f865e Import GrTriangulator from Skia with tests
We intentionally chose Skia's triangulator, as opposed to libtess et. al., because it gives us the "breadcrumb triangle" list, which we need in order to do coarse tessellations of just the inner fan.

Diffs=
c153c393a Import GrTriangulator from Skia with tests (#5417)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-15 17:22:12 +00:00
csmartdalton
b96abc8b6a Refactor PLS uniform buffers to support multiple draws
Currently, PLS renders every path in a single draw call. In order to support some indispensable optmizations, in addition to non-raster-ordered rendering, we need to be able to support a draw list with multiple draws. This change adds a uniform buffer that can support per-draw parameters.

Diffs=
beab8bab0 Refactor PLS uniform buffers to support multiple draws (#5416)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-13 19:15:59 +00:00
csmartdalton
076f75ef9b Non-clang build fixes
* <mm_malloc.h> is clang only.
* __builtin_clz is clang only.
* Generate preprocessor defines for shader feature sets as a bitfield instead of strings.
* Use float literals with simd expressions, which are more compatible with the non-clang simd workaround class.
* Remove C++20 designated initializer lists.

Diffs=
ffa49c5b9 Non-clang build fixes (#5397)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
Co-authored-by: Scott Redig <scott@pocketwatchgames.com>
2023-06-09 20:55:52 +00:00
csmartdalton
6add861539 Reorder PLS RW texture definitions
Reorder "@PLS_IMPL_RW_TEXTURE" macro definitions in a way that feels more intuitive.

Diffs=
6bb88136d Reorder PLS RW texture definitions (#5388)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-08 16:31:03 +00:00
csmartdalton
984697f2a9 Add a PLSImpl that uses read/write textures
This gets us working on PCs without the need for ANGLE.

Diffs=
298dd2da6 Add a PLSImpl that uses read/write textures (#5384)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-08 15:26:04 +00:00
csmartdalton
9566436c2e Fix downstream pls pushes
Refer to the correct folder name (pls, not rive_pls).

Diffs=
0781fdac2 Fix downstream pls pushes (#5375)
9dca5ab50 Reorganize pixel local storage implementations (#5353)

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
2023-06-06 19:07:54 +00:00
Chris Dalton
9d643220cf Create a downstream repo for the Rive renderer 2023-06-02 10:22:09 -06:00