Plumb lighting props and implement a Phong lighting model.
This is ~40% slower with the SW backend - to mitigate, construct two
runtime effects and only apply fancy lighting when needed.
Change-Id: If6f71253e7adc148f6d5cf5fbde2c1dff977f669
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368246
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Implement CC Sphere.
No lighting support for now (matches AE's Light Intensity: 0,
Ambient: 100).
Change-Id: I7eb4d8f9c5dd4b4cb312321cefee0231a9901873
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362457
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Expand existing SkottieColorizeGM to also handle text properties and
add text-focused instance.
Update layer names in one of the json assets to match expected demo
prefix ($).
TBR=
Change-Id: I076229067523fe597be66c611a8653897f995bc8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/342916
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Auto-resizing and vertical alignment require a non-empty text box. But
currently, the presence of the text box is used to discriminate between
point text [1] and paragraph text [2].
In order to support auto-scaling and v-alignment for point text, we must
decouple the text mode encoding from the text box:
* introduce and explicit LinebreakPolicy property for skottie::Shaper,
and use it to control line breaking instead of the text box presence
* by default, the line breaking policy is initialized per existing
AE/BM semantics: non-empty text box -> paragraph mode,
empty box -> point mode
* the policy can be overridden via the PropertyObserver APIs to enable
point mode auto-resizing and vertical alignment
[1] https://helpx.adobe.com/after-effects/using/creating-editing-text-layers.html#enter_point_text
[2] https://helpx.adobe.com/after-effects/using/creating-editing-text-layers.html#enter_paragraph_text
Change-Id: I007144283a31a2faa579d7eec82af72af3d540cb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321788
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Plumb layer size information and add machinery for retrieving layer
content as an SkPicture.
Implement the effect in SkSL.
Current limitations:
* displacement source layer must be above (on top in stacking order)
of the target layer
* if animated, the displacement layer timeline (in/out points) must
fully cover the target layer timeline
* Hue/Sat/Lightness selectors are not supported at the moment
These will be addressed in follow-up CLs.
Note: Bodymovin does not export hidden layers by default; if the
displacement source layer is hidden, one should select the "Hidden"
export option.
Change-Id: I11a5c760a9df1e75835a51371f60d5b798e7e38a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314798
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Refactor the shape repeater using a custom render node (instead of
duplicating per-instance SG nodes).
In the process, fix several issues:
* scale was not being composed correctly
* start/end opacity were being ignored
* non-atomic fragments were being drawn in wrong stacking order
Change-Id: I06cd3606806d1a46852a8557b27c09eb44abdadd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313209
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
BM can now export inline fonts, encoded as data-uris.
Extend our DataURIResourceProviderProxy helper to also intercept and
decode inline typefaces.
Change-Id: Iaf1be9db2fd32383af78bc351b1228fe6b3b64bf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305685
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Florin Malita <fmalita@chromium.org>
Reviewed-by: Ben Wagner <bungeman@google.com>
Spread/choke operates as a compression of the alpha channel towards the
low bits.
Change-Id: I82aec1321b60f7f75a79e8280e761d4629f6c923
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305183
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Assorted bugfixes for the non-analytical mask code path.
1) SkSG modulatePaint() should only override the blend mode when
one is specified (!= kSrcOver).
2) Some modes (notably intersect) require touching pixels outside the
mask draw geometry. These modes must be applied as a layer.
Introduce an explicit layer node in SkSG, and inject for masks which
require it.
Also refactor Subtract to use more natural blend and pathops modes,
instead of always inverting geometry.
TBR=
Change-Id: I412168d1ff61eb8e59907babe8f0e091f6fffacf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303997
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Sksg::Merge needs to preserve the fill type of the first path appended
in the stack.
Theoretically, one could append multiple paths with different fill types
using sksg::Merge, but in practice Skottie should never do that (append
mode with invertible shape only used for the very first mask in a stack).
TBR=
Change-Id: Ie9ac9187cc1c8baaae2bef439313a7700407f04a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303582
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Observed semantics:
-- operates on cubic Bezier path representation
-- moves vertices towards the shape center, and control points in the
opposite direction, based on the specified amount
-- the center is determined as the vertex average
-- the amount is specified as a fraction of the transition to center
(0 -> noop, 1 -> fully collapesed to center)
-- negative and extranormal amount values are allowed
(invert direction/extrapolate)
TBR=
Change-Id: I7da81a5fe5cffd0e50bd94e6b448565b0b04ed86
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301582
Reviewed-by: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
AE allows selecting the paint order when both fill & stroke are present.
The CL also fixes some text stroke issues: stroke width not parsed
correctly and not actually used on the paint.
Change-Id: Iec27bb65d09f689365e43b801d3844106780572b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301857
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Two issues:
1) For static keyframes (start_value == end_value) AE yields horizontal
orientation (0 tangent). We technically have the same logic in
Skottie, but our value deduplication logic interferes: the two
consecutive equal values are consolidated, and the result ends up
holding the spatial lerp info for the next frame => our hold frames
auto-orient for the beginning of the next keyframe.
Fix: skip value deduplication when spatial lerp is present.
2) The very last keyframe is always static and holds no spatial info.
AE retains the orientation of the previous frame, but Skottie yields
0 tangent.
Fix: the easiest way to accomplish AE semantics is to detect when
we're dealing with the last keyframe, and swap with the previous
keyframe with an adjust weight of 1 (to select the end value). This
produces the same lerp result (because keyframed values are always
contiguous) and also respects the orientation of the prev frame.
TBR=
Change-Id: Id661f7804533e95b747722457489a7ef759572a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301176
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Unlike other shape path effects, merge paths disables the rendering of
any preceding paints - it only extracts the merged geometry from the
stack.
Update the shape layer attacher logic to suppress paints under merge
paths.
TBR=
Change-Id: I414134839de9eaa4b0f828d8dc6d4721620242bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300897
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Based on SkPathOps for now.
Change-Id: Id27c8a235cbd4ab5083735b67cf5d2635ee16cfc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300497
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Mike Reed <reed@google.com>
AE allows animating the line spacing text property [1].
Observed semantics:
- spacing is applied as an offset to all fragments in a line
- for selector/partial coverage, the spacing for a given line
is the average of the computed spacing for each fragment
- spacing is cumulative (applies to all lines following)
Plumb the new animator prop ("ls") and expand the existing line
tracking logic to also apply computed spacing offsets.
(also requires a Bodymovin update to export the line spacing property)
[1] https://helpx.adobe.com/after-effects/using/animating-text.html#text_animator_properties
Change-Id: I5517acea8dbc1b2fbae09cb0874f1e53cd2acb90
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300377
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
AE layers can be tagged for auto-orient - i.e. they observe an
additional rotation component dependent on the position property
animation (position derivative/tangent).
Augment Vec2KeyframeAnimator to optionally track orientation, for both
temporal/linear and spatial (motion-path) keyframes. Update
TransformAdapter2D to use this orientation when attached to layer
transforms.
Change-Id: I616e45a07b088e9e566b4f88450e95f9315b727c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291716
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
Add support for external precomp Skottie layers. This allows embedders
to seamlessly mix custom/Lottie content.
General flow:
* embedders register a PrecompInterceptor callback with
the animation builder
* at build time, Skottie invokes the callback for each pre-composed
layer
- the returned ExternalLayer implementation is used instead of the
Lottie layer payload
- (a nullptr value signals Skottie to use the usual Lottie payload)
* at render time, ExternalLayer::render() is called to defer content
rendering to the embedder
Also implement a sample PrecompInterceptor which attempts to substitute
precmp layers matching a given pattern with external Lottie animations:
precomp_name: "__foo.json" -> Animation("foo.json")
This new mechanism is a generalization of (and supersedes) the old
NestedAnimation hack - so we can remove that.
Change-Id: Id80fe11881c62b8717c2476117c7c03ad5300eef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288130
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
Implement non-linear contrast using a cubic polynomial approximation,
as a SkRuntimeEffect.
The effect range is significantly more constrained than the legacy
version: https://www.desmos.com/calculator/ehem0vy3ft
Change-Id: I86bdbb9cc0d30065780f87705d2d4d39385609cb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285840
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Implement drop and inner shadow styles using explicit image filters.
Remove existing style support from DropShadowEffect.cpp, as it now
has a new cozy place with its inner sibling.
Supported properties:
- color
- opacity
- angle
- distance
- size (sigma)
Change-Id: I5b7e3c75678e036a20c1908b84c74a670a5aa196
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283918
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
In inverted mode (Mode::kInverted), the trim result represents the
logical segment [stop..start] (wrapping around at the path's end).
We currently emit two segments [0..start] and [stop..1], in that
exact order. This behavior breaks continuity for single closed
contour paths.
Update SkTrimPath to
1) emit the segments in the correct order ([stop..1],[0..start])
2) skip the connecting moveTo for closed paths
Bug: skia:10107
Change-Id: Icd280554ba7291c985f504793feff104df2a4a99
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281882
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Note: works for well-formed poly-to-poly (perspective) transforms, but
doesn't support AE's degenerate corners semantics (concave/inverted
polys) at this point.
Bug: skia:10100
Change-Id: I5b3492b008302495b616867c139c6e5ad6dc57df
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281595
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Plumb layer style parsing, and extend existing DropShadowAdapter to
support both drop shadow style and drop shadow effect.
Change-Id: Id99a419dacd06dc38dc4cf84ff4ecb92218c45f7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279020
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Implement all AE grouping modes: character/word/line/all.
-- character grouping was already supported (default mode)
-- for word and line grouping, expand the existing domain mapping logic
to also track cumulative advance and max(ascent) per span, then use
this info to compute anchor point boxes
-- for "all" grouping, the anchor point box coincides with the text box
(https://helpx.adobe.com/after-effects/using/animating-text.html#text_anchor_point_properties)
TBR=
Change-Id: I8564f1349d167d82c31862d8f7e57615cdae0dcf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274201
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
In adition to transforms/opacity/etc, text animators can target
per-glyph opacity.
Change-Id: I6ab63a6e49a64beaf63fc955f0b672a5b8ba84ba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272886
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
When per-character 3D is enabled, text properties can be animated in
3 dimensions.
- position and scale become 3-value vectors
- in addition to existing "r" (really rz), rotation gains "rx" and "ry"
- instead of specializing for 3D, expand the existing structures to
handle both 3D and 2D modes
- also ensure that sksg::Transform does not flatten to SkMatrix
Change-Id: I426a7ee1ff38c1702deb85e9f1db80f6069f36d6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272648
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
AE discards lines with baselines outside the paragraph box.
This aligns Skottie's behavior with AE for default/top-alignment
(but not for any of the custom vertical alignment modes).
Bug: skia:9933
Change-Id: Id0318f0744bf89580774e89494faf19bfb6f6d14
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272376
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Similar to existing ADBE Easy Levels2, but provides separate mapping
controls per channel.
Change-Id: Ibc58c58e1e8cb8793d6eb819998c1804ccbbf859
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268936
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Also fix a couple of custom props issues:
- solid layer colors were not dispatched
- text values were not sync'ed
TBR=
Change-Id: I827f8c1d8c8bb73b03f05de15e1c7c96753a631e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264936
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Currently, we treat track matte source layers (tagged with td:1) as single-shot mask triggers:
we apply once to the following layer, then move on.
But track mattes can cascade: a layer with a matte can itself be applied as a track matte for the
following layer.
Also, for matte/masking purposes, only the layer content is being considered (ignoring blend mode
and any masks applied to the matte itself).
To support this, refactor the layer attachment code:
- instead of tracking the presence of a single-shot matte source, always track
previous layer content trees
- instead of triggering matte attachment in the presence of a matte source, trigger based on
the matte *target* property (tt: X)
- log errors on unknown matte modes
Change-Id: I6c71d4007e1e27d3f3a139344bbf367d7bc6e29d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259820
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Precomp layers can have a different size vs. main composition.
Instead of relying on the global animation (main comp) size, use the
current (pre)comp size when setting up cameras.
Change-Id: I54106375fb39dde2bfd11e14a38e5ec3e7190764
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258156
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
So far Skottie has been assuming all cameras are two-node (have a point
of interest).
AE also supports one-node cameras, where the camera does not auto-orient
towards a POI but starts off perpendicular to the z == 0 plane.
(https://helpx.adobe.com/after-effects/how-to/camera-animation.html)
Change-Id: Id565de7d8feb9a762940ac372c1bbbcce2e2dfc6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254559
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Refactor as a single interpolating loop, based on careful selection
of lerp coefficients.
Change-Id: I58786cddb2f042b53dcbac80c2346736429be102
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252858
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>