Commit Graph

31 Commits

Author SHA1 Message Date
Florin Malita
3a76975a7c [skottie] VectorValue specialization
Currently we're handling VectorValues via a generic animator => we use
vector<vector<float>> for storage.  That's kinda clunky, especially for
small-size vectors (3d values, colors).

Introduce a more efficient VectorKeyframeAnimator:

  - stores vector values in a contiguous/consolidated float array
  - keyframes reference value offsets in storage
  - fast/sk4f lerp impl

Change-Id: Ia9538068f2c722c2d2209f87e26564f0fe28ac31
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277578
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-03-18 17:57:41 +00:00
Florin Malita
141ac68fa0 [skottie] Cleanup: split animators into separate CUs
No functional changes, just code reshuffle.

TBR=

Change-Id: Ia04add9d51d6e84903d010534434c9a60464a72a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277457
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-03-17 15:48:17 +00:00
Florin Malita
af99f3ee60 [skottie] Cleanup: finalize adapter conversion
Convert remaining bindProperty clients to adapters, and remove the
legacy API.

TBR=
Change-Id: I06eda513a75b55a1ba7eae328b0916e738c9ddd7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268309
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-02-03 18:56:01 +00:00
Florin Malita
f7d399a6ca [skottie] Cleanup: convert shape stroke/fill to new adapter pattern
TBR=
Change-Id: If4b9e591fdd4349b6a06ce86ba5284ab43634a03
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267447
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-01-29 19:02:07 +00:00
Florin Malita
d960cc31b6 [skottie] Cleanup: remove unused header
SkottieAdapter.h is no longer used.

TBR=
Change-Id: I5a6f503c52168a4418540d344e47cdde101a9f90
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267396
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2020-01-29 15:13:36 +00:00
Florin Malita
cbf31d0a0e [skottie] Cleanup: convert shape layer adapters to new pattern
Split off most shape layer components into own CUs (naming convention
following AE), and convert to new DiscardableAdapter pattern.

TBR=
Change-Id: Iba7800cff1998d3d7cf81dfd89b4193d02b59559
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265147
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-01-22 20:16:36 +00:00
Florin Malita
d5c42c8c03 [skottie] Refactor property animators
Currently, property animators use lambda captures (std::function<>) to push
values to adapters and then to the scene graph.  Some downsides:

  * complex lambda captures are expensive in terms of object code size
  * adapters with multiple animated properties don't synchronize/quiesce: each individual property tick triggers a SG
    synchronization, possibly with inconsistent state (as animator running
    order is unspecified)
  * there is no enforced scoping, resulting in fragile constructs when SG
    fragments are discarded

This CL introduces a simplified and more robust animator pattern:

  * property animators are scoped to explicit containers
  * instead of capturing arbitrary value functors, animators only capture
    a pointer to the target value

Some implementation details:

  * keyframe/interpolation logic is pretty much unchanged (just relocated)
  * introduced AnimatablePropertyContainer - a base class for animatable
    adapters
  * legacy binding functions are refactored based on the new mechanism
    (they now/transitionally inject adapter objects)
  * converted a handful of effects, to exercise trivial refactoring patterns
  * converted the text animator goo, to exercise non-trivial refactoring:
    - detecting value changes is now trickier (no more lambda magic)
    - value adjustments must be hoisted into adapter logic (no more lambda magic)
    - all dependent animated values (selectors, etc) must be scoped to the
      text adapter to avoid lifetime issues

TBR=
Change-Id: Ia5821982f251de0de58fd3f87812219ff7fcc726
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263938
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
2020-01-16 22:43:12 +00:00
Florin Malita
a3936c8d29 [skottie] cleanup: move transform & camera adapters to own CUs
Shuffling code around, no functional changes.

TBR=
Change-Id: I9a045fa643fbcf52c58e1378d4d4c1566c0d35d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262225
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-01-06 18:16:14 +00:00
Florin Malita
e1fa70000a [skottie] Invert effect support
https://helpx.adobe.com/after-effects/using/channel-effects.html#invert_effect

Change-Id: Iac8e291ab9cb57714c50f1e40cecb66b3dc64ee1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259276
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
2019-12-11 23:07:04 +00:00
Florin Malita
c6fbedc507 [skottie] 3D layer parenting refinements
Observed AE layer parenting semantics:

  * layers are flagged as either 2D or 3D
  * camera applies to 3D layers, but not to 2D layers
  * parented 3D layers treat their ancestor transform chain as 3D (SkMatrix44)
  * parented 2D layers treat their ancestor transform chain as 2D (SkMatrix, ignoring 3D components)

This means that for a given layer, we may need to build two distinct transform chains - depending
on the type of descendant layer being considered.

Furthermore, transforms are animatable and their animators are scoped to a layer controller.  Since
we're potentially building two version of the transform node, we need to ensure all animators for
both of them are transferred to controller object (we still want to only instantiate a single layer
controller and render tree to avoid duplication).  IOW, all dependent layer transforms need to be
considered before "sealing off" a given layer controller.

In order to avoid a layer dependency/topological sort, we can split off the transform tree
construction into a separate pass.  High-level changes:

  -- replace existing LayerAttachContext with CompositionBuilder
     (holds LayerBuilders and other Composition-wide state)

  -- replace LayerRec with LayerBuilder
     (holds Layer-wide state and also caches transform nodes)

  -- pass 1: for each LayerBuilder, transitively build and cache a transform chain
     of a type (2d/3d) determined by the leaf (entry point) layer

  -- pass 2: for each LayerBuilder, build the actual layer content render tree
     and instantiate the layer controller objects

Bug: skia:8914
Change-Id: I9f7efcf4819424282fd3dda98f5621ba12fd001b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251001
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-10-28 20:29:54 +00:00
Florin Malita
c1b501c352 [skottie] Shift Channels effect support
(https://helpx.adobe.com/after-effects/using/channel-effects.html#shift_channels_effect)

Limitations: no HSL sources for now.

Change-Id: Iffd63f2bbfc8c5f1de00846412be26847e822420
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/250036
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2019-10-22 20:36:01 +00:00
Florin Malita
17b9d1d1de [skottie] Initial Hue/Saturate effect support
Due to limitations in BodyMovin/AE JSX, full effect data is not
available (specifically the "channel range" property).

We only support static master hue, static master saturation and
static master lightness at this point.

This CL also introduces a new animation builder pattern:
DiscardableAdapterBase and attachDiscardableAdapter().

The former is a base class for adapters with full animator ownership.
This enables a) capturing raw adapter pointers in animator lambdas and
b) syncing to SG only once, after all local animators are updated).

The latter is a helper for managing adapter creation and optional
destruction (when all adapter properties are static we can discard it).

Change-Id: Iecc4b78830e5464e7958cb12cdfd75a61010aa25
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/231956
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-08-02 18:04:14 +00:00
Florin Malita
5f1108ce46 [skottie] Motion blur support
Unlike all other Skottie effects, motion blur requires sampling at multiple
points on the timeline.

To support this:

  1) Introduce MotionBlurEffect - a custom SG render node which can drive
     the timeline of its subtree using an sksg::Animator.

  2) Introduce MotionBlurController to swap for a regular LayerController
     when needed.  MotionBlurController dispatches time ticks to
     MotionBlurEffect instead of directly to the layer animators.

The actual motion blur impl is based on
https://skia-review.googlesource.com/c/skia/+/221416.

Motion blur requires Lottie files exported with this BodyMovin patch:
https://github.com/bodymovin/bodymovin-extension/pull/15

Change-Id: I075e101ea91ec9aa300bac35ee810fd539f1aced
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225416
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-07-09 13:02:17 +00:00
Florin Malita
45dc1f0001 [skottie] Cleanup: split off layers into own CUs
TBR=
Change-Id: Ia6c27cca33f9dc8f242a50e624341dd0b465b380
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/224738
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-07-01 18:29:22 +00:00
Florin Malita
b0944553df [skottie] Venetian Blinds effect
Change-Id: I50e133dea448e044fef45379490cb85b39eea3bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223856
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-06-26 13:13:10 +00:00
Florin Malita
d7b321afa2 [skottie] Radial swipe effect
Implement radial wipe with a sweep gradient shader mask filter.

The implementation is slightly convoluted because edge feathering requires a real blur, which in turn requires content layer isolation.

So there are two distinct operation modes:

  - no feather -> draw the content directly into the dest buffer, with the mask filter
    deferred in SG context

  - feather -> draw the content into a separate layer, then blend (dstOut) the composed
    blur+shader mask on top

Change-Id: I253701aff42db8010ce463762252c262e2c5d92b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/222596
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-06-21 14:03:45 +00:00
Florin Malita
9c47e15e23 [skottie] Linear Wipe effect
Add SkMaskFilter scene graph nodes and implement AE's linear wipe effect
as a gradient shader mask filter.

Change-Id: I3b2d8677c894d27249cfae7e3ea6b1248b53546b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221776
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-06-19 13:22:53 +00:00
Florin Malita
b97824d4d1 [skottie] Motion tile effect
Implement support for AE's Motion Tile effect [1].

This is the first effect which needs layer size information, so the CL includes
related plumbing.

Limitations: no phase support at this point.

[1] https://helpx.adobe.com/after-effects/using/stylize-effects.html#motion_tile_effect

Change-Id: I023bf8a9d3e3d2a48458fa94218f143e6aac4c9f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221244
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-06-17 18:20:15 +00:00
Florin Malita
941b9ff09b [skottie] Effects cleanup pass
Split-off effects into separate CUs.

TBR=
Change-Id: Ic214027d27e1c341085d9a8c74f605caba260630
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221118
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-06-14 20:31:45 +00:00
Florin Malita
e47d8afabd [skottie] Add support for Transform distort effect
Yet another way to transform a layer, disguised as a distort effect.

TBR=
Change-Id: Ic2d5479fa6ae27b460de60875924f73f77fc7f71
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221001
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-06-14 16:58:31 +00:00
Florin Malita
1c44db15d1 [skottie] Initial text range selector support
Each animator can have multiple range selectors, whose combined "coverage"
modulates how the animator props compose with other/initial props.

Since there can be multiple animators with different/arbitrary selectors,
we compute independent property values for each fragment.

Supported features:

 - start, end, offset, amount
 - units: percentage, index
 - based-on: characters-only for now
 - mode: add-only for now
 - shape: square-only for now

Change-Id: If7fee46ffb29e1f92542822481ed699fd0b0b521
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218076
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-06-04 20:50:32 +00:00
Florin Malita
96b95f911c [skottie] Initial animated text properties support
Limitations:

  - no range selectors (applies to the whole text)
  - only position, fill color and stroke color for now

Change-Id: I91e88a6107c5f66687c1c27f27a71be3914bde25
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217386
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-05-31 18:41:13 +00:00
Florin Malita
ca449d5899 [skottie] Cleanup: relocate text sources
Move text-related sources to a dedicated 'text' subdirii, and drop
"Skottie" src prefix.

TBR=
Change-Id: I4f8d1633d649d371f76840405b6e567bd93f0c00
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212724
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-05-08 14:36:07 +00:00
Florin Malita
f4e8733947 [skottie] Relocate text shaping utils to separate compilation unit
Introduce AE-specific text shaping abstractions, and move the existing
implementation to a separate CU.

Change-Id: I8533ed8d9c59af6d82b3f1ca66a6e1d50a3c33c5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203706
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-03-26 20:34:02 +00:00
Florin Malita
a85f3a138c Reland: [skottie] Initial property setters
Introduce a PropertyObserver to receive property notifications for layer
and shape nodes.

Properties are communicated using strongly-typed "handles", which act
as impedance adapters between the AE/BM model and the internal Skottie
model.

Reviewed-by: Mike Reed <reed@google.com>
Change-Id: Id155076faa8595f6b4d81672559f01c2e0c7455a
TBR=
Reviewed-on: https://skia-review.googlesource.com/156626
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-09-24 21:46:07 +00:00
Brian Salomon
39e1d13d35 Revert "[skottie] Initial property setters"
This reverts commit 7903957247.

Reason for revert: breaking SAN bots

Original change's description:
> [skottie] Initial property setters
> 
> Introduce a PropertyObserver to receive property notifications for layer
> and shape nodes.
> 
> Properties are communicated using strongly-typed "handles", which act
> as impedance adapters between the AE/BM model and the internal Skottie
> model.
> 
> Bug: skia:
> Change-Id: Ieb9be1ff843673f1f4fe900d3774c36956b7c941
> Reviewed-on: https://skia-review.googlesource.com/156186
> Commit-Queue: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Mike Reed <reed@google.com>

TBR=fmalita@chromium.org,reed@google.com

Change-Id: Ic737766e305bb8dff10a817fa37f16fdfa051c93
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/156620
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2018-09-24 20:46:34 +00:00
Florin Malita
7903957247 [skottie] Initial property setters
Introduce a PropertyObserver to receive property notifications for layer
and shape nodes.

Properties are communicated using strongly-typed "handles", which act
as impedance adapters between the AE/BM model and the internal Skottie
model.

Bug: skia:
Change-Id: Ieb9be1ff843673f1f4fe900d3774c36956b7c941
Reviewed-on: https://skia-review.googlesource.com/156186
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
2018-09-24 19:03:06 +00:00
Florin Malita
471a946cf1 [skottie] Make AnimationBuilder available for value parsing
Plumb AnimationBuilder throught a bazillion layers to make it reachable
when parsing animatable values.

This is in preparation of keyframed text, which will require access to
the font set when parsing.

Refactor only, no functional changes.

TBR=
Change-Id: Ide2ef2ba66fbcc75fdcc785f987b364d45dff5b6
Reviewed-on: https://skia-review.googlesource.com/149264
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2018-08-26 00:39:48 +00:00
Florin Malita
1b1dead00d [skottie] Split-up Skottie.cpp
Introduce more granular compilation units for major Skottie layer types.

TBR=
Change-Id: Iee2ef05cbcdda06467674824eb295ae6d7dc5bb9
Reviewed-on: https://skia-review.googlesource.com/148394
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2018-08-21 19:06:15 +00:00
Florin Malita
f9c5063fc4 [skottie] Initial text layer plumbing
Still loads to do. For now just draws trivial text nodes using a default fontmgr.

Change-Id: I7343b648726d2c4f376f43437f6ae1377ad8ba86
Reviewed-on: https://skia-review.googlesource.com/147465
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-17 16:59:54 +00:00
Florin Malita
8949c8a2f8 [skottie/sksg] Move source files list to .gni
To facilitate Chromium integration.

Change-Id: Ie6a08e90feda4c6deace9754f0baef7176882334
Reviewed-on: https://skia-review.googlesource.com/145146
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-02 16:29:13 +00:00