Commit Graph

378 Commits

Author SHA1 Message Date
Brian Osman
ea485e5285 Enforce ES2 limits on indexing expressions (in runtime effects)
This enforces an even stricter version of the rules from GLSL ES 1.0
Appendix A, Section 5. Essentially, indices (to arrays, vectors,
matrices) must be made of literals, loop indices, and expressions made
of those two.

Bug: skia:10837
Bug: skia:11096
Change-Id: I437a5ed64da58e24d5991ddbde68859f5214e98b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/354665
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-01-15 22:49:27 +00:00
Brian Osman
bf061a32ef Fix an (int + float) error in "cube" particle demo
Also fix a crash if you try to play an effect that has never compiled
correctly. (After the first compile, the arrays were always large enough
to set "dt" -- this code is all going to be reworked soon for SkVM, but
I hit this while diagnosing the type coercion error).

Change-Id: I5bfab539c7304bde2da36b0b0604991d5b5b303a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/354660
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-01-15 19:15:16 +00:00
Brian Osman
fb79f9faa4 Remove all particle examples that use SkEffectBinding
I'm going to remove this feature to simplify migration to skvm.
fireworks was updated to work without it. raincloud is fairly complex,
and not that attractive, so it's just being deleted.

Change-Id: Id2d5cd490baa7bae627002f41edf7522c8bdfcd8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/353076
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-01-12 19:09:18 +00:00
Brian Osman
2ae02492a7 Remove use of do-while loops from particle examples
This was unnecessary (closed-form unit-disc picking is simpler), and
these loops don't meet the strict ES2 standards that we'll be applying
to the interpreter soon.

Bug: skia:11095
Change-Id: Ic2617c2807fe49d57ff8e4d57d70b9ed1f015916
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348895
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-30 21:30:40 +00:00
Brian Osman
e11c43804b Remove use of uint from particle random system
uint (and bitwise operations) aren't supported by our minimum spec, and
they're going to be removed from public SkSL. For now, convert the
random generator to a good-enough chaotic sequence of high-frequency
sine waves.

If/when the interpreter (and particles) are converted to the newer skvm
backend, it will be straightforward to support custom intrinsics that
emit skvm instructions directly into the builder, and re-introduce a
better integer-based PRNG, without requiring SkSL language support.

Bug: skia:11093
Change-Id: I885b15a51a9e5c12b4274b5938d8deb77219d41b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347036
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-23 16:21:17 +00:00
Brian Osman
ba2c246259 Simplify raincloud particle effect
The 'flags' field is going away soon (per public SkSL minimum spec), and
the only use of that feature was for this one example. The alternative
is simpler to understand, too.

Bug: skia:11093
Change-Id: I18a85bd48316301edc44c691fbe20f93da243e2f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346776
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-22 20:39:38 +00:00
Mike Klein
0047afffb0 remove very oldest SkVM testing
None of these earliest testing tools are useful anymore
now that we can do useful work with SkVM and SkVMBlitter.

Change-Id: I8b25ef6ddd101c4ff8617c6742343dedb4764922
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345456
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-17 21:17:46 +00:00
Brian Salomon
72068174f2 Fix images used in orientation GMs
Previous approach using magick's -orient tool didn't actually change the
stored JPEG's orientation (they were all tagged Undefined and the data
was top-left).

Regenerate the images using new method where the PNGs are generated with
transformations that the EXIF tag will undo. The script converts to JPEG
using magick and then modifies the TAG using exiftool.

Change-Id: Ic2276711c0f4faa26620c93b24f4f0e58d658ae3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345127
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2020-12-17 15:48:25 +00:00
Florin Malita
8655eab56c [skottie] Add text colorization GM
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>
2020-12-10 17:10:48 +00:00
Brian Osman
e7f68f3644 Tweak ParticlesSlide's resource provider to show how to use PathBinding
Adds an example effect that spawns particles along an SkPath.

Change-Id: I53f3c02fefec814bd9e16f3ac593eac4cf6a297c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341418
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-12-07 17:26:39 +00:00
Leon Scroggins III
469d67e7d9 Expose more info in SkCodec::FrameInfo
Bug: b/160984428

Add more fields to SkCodec::FrameInfo, which describes the properties of
an individual frame in an animated image. This allows a client that
wishes to seek to determine frame dependencies so that they can decode
an arbitrary frame, which in turn will allow SkCodec to remove
SkCodec::FrameInfo::fRequiredFrame. Currently, SkCodec seeks through the
stream to determine frame dependencies, but this is unnecessary work
(and storage) for a client that does not want to seek.

These fields also support the proposed APIs in go/animated-ndk.

Move SkCodecAnimation::Blend from SkCodecAnimationPriv (and delete that
file) into SkCodecAnimation.h. Rename its values to be more clear.

Merge common code for populating SkCodec::FrameInfo.

Add a test for a GIF with offsets outside the range of the image. Note
that libwebp rejects such an image.

Update libgifcodec.

Change-Id: Ie27e0531e7d62eaae153eccb3105bf2121b5aac4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339857
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Nigel Tao <nigeltao@google.com>
2020-12-02 22:37:20 +00:00
Ben Wagner
416fe32ce1 Ensure variable font from data created at default.
If font data is used to create an SkTypeface and the font data describes
a variable font and no variation parameters are specified, the
SkTypeface created should have the default values for all axes. This is
particularaly interesting with DirectWrite since it makes this not
straight forward.

Bug: skia:10929
Cq-Include-Trybots: luci.skia.skia.primary:Test-Win10-Clang-NUC5i7RYH-CPU-AVX2-x86_64-Debug-All-NativeFonts
Change-Id: I4620deebf52142bbdffa1a283343b503cd1e6981
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338604
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2020-12-01 00:30:22 +00:00
Mike Klein
ee40ec6dd6 remove Op::pack
pack(x,y,bits) as an alias for x|(y<<bits) only existed originally to
implement it with the SLI arm64 instruction, but I've since realized
that was misguided.

I had thought the assumption on pack ("(x & (y << bits)) == 0"), i.e.
"no overlap between x and the shifted y", was enough to make using SLI
legal, but it's actually not strong enough a requirement.

The SLI docs say "...inserts the result into the corresponding vector
element in the destination SIMD&FP register such that the new zero bits
created by the shift are not inserted but retain their existing value."
The key thing not mentioned there happens with zero bits _not_ created
by the shift, the ones already present at the top of y.  They're of
course inserted, overwriting any previous values.

This means SLI (and so pack()) become strictly order dependent in a way
I had never intended.  This will work as you'd think,

    skvm::I32 px = splat(0);
    px = pack(px, r,  0);
    px = pack(px, a, 24);

but this version swapping the two calls to pack() will overwrite alpha,

    skvm::I32 px = splat(0);
    px = pack(px, a, 24);
    px = pack(px, r,  0);

I find that error-prone, so I've removed Op::pack and replaced it
with a simple expansion to x|(y<<bits).  That of course works in either
order.

This new test can't JIT at head, but if we implement the other missing
instructions (soon, dependent CL) it would start failing when JIT'd.
The interpreter and x86 were both fine, since they're both doing what's
now the only approach to pack(), the simple x|(y<<bits).

I've left assembler support for SLI in case we want to try it again.

Change-Id: Iaf879309d3e1d0a458a688f3a62556e55ab05e23
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337197
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-11-21 12:38:19 +00:00
Leon Scroggins
bc098ef6d4 Handle EXIF orientation in SkAnimCodecPlayer
Bug: skia:10914

SkAnimCodecPlayer:
- Properly handle orientation, whether the image is still or not
- Mark const methods as const
- Fix seek() so that if you seek to the duration of frame 0, it will
  show frame 1
- Fix the SkImageInfo so if the first frame is opaque, but following
  frames are not, those frames can still be decoded

resources:
- Rename "webp-animated.webp" to "stoplight.webp", which better
  describes the animation
  - Update test files accordingly
- Add "stoplight_h.webp", which is the same animation with an EXIF
  that converts it to a horizontal stoplight

AnimCodecPlayer test:
- Test the new image files
- Verify SkAnimCodecPlayer::dimensions behaves as expected
- Remove extra debugging line
- Provide better error messages

AnimCodecPlayerExifGM:
- Add a new GM that shows all frames of the new animation with an EXIF
  orientation
- Add a new GM that shows all frames of an animation with an opaque
  first frame followed by frames with alpha

Change-Id: I43cf91c16d52aa1901eef8e13e1e644eea6058b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332753
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-11-12 14:43:47 +00:00
Florin Malita
9176c51b5c [skottie] Black & White effect
Add support for Adobe's Black&White effect [1].

Also plumb 'abs' for SkSL.

[1] https://helpx.adobe.com/after-effects/user-guide.html/after-effects/using/color-correction-effects.ug.html#main-pars_heading_2

Change-Id: Ia7dc24d6df9492867a1b1806ce7645586498161a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329536
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-10-27 17:03:40 +00:00
Matthew Leibowitz
07055b5e25 Parse out the orientation in the SubIFD of EXIF
Orientation information is sometimes stored in
the SubIFD section of EXIF, so read that. This is
just a matter of searching for the SubIFD offset
value in the EXIF tags and then parsing the
values from there onwards. The data format is
the same as the EXIF data.

The images are not under any copyright as I made
them up locally specifically for these tests.

Bug: skia:10799

Change-Id: I5384ffc1c4a9a0c7d3fc8510ef4da2f278cb8b97
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323217
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-10-12 13:50:27 +00:00
Nigel Tao
bf4605ffc3 Have SkWuffsCodec use PIXEL_BLEND__SRC_OVER
This takes the "one pass" code path more often, using less memory, as it
does not have to allocate an intermediate width*height pixel buffer.

Wuffs v0.2 did not support SRC_OVER, only SRC, but Wuffs v0.3 does.

The gif-transparent-index.gif test file comes from the
test/data/artificial directory of the github.com/google/wuffs
repository. It was programmatically generated.

The new GifTest.cpp test passes with skia_use_wuffs true or false, with
or without the SkWuffsCodec.cpp change.

Change-Id: I46fb4c849319fbefc39f331416a8b7d3836093ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320116
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2020-10-05 18:24:48 +00:00
Florin Malita
71bcfef9f7 [skottie] Auto-resize and VAlign support for point text
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>
2020-10-02 19:33:35 +00:00
Florin Malita
66b45a7f40 [skottie] Add support for invert/YIQ
The Invert layer effect [1] also supports YIQ selectors [2]:

  -- YIQ
  -- Luminance (Y)
  -- In Phase Chrominance (I)
  -- Quadrature Chrominance (Q)

[1] https://helpx.adobe.com/after-effects/using/channel-effects.html#invert_effect
[2] https://en.wikipedia.org/wiki/YIQ

Change-Id: I54b1c81a786ff6f2bdea6456b45b435b2c0fea07
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316446
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-09-11 14:55:44 +00:00
Florin Malita
4748c17557 [skottie] Initial Displacement Map effect
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>
2020-09-11 14:15:44 +00:00
Mike Reed
81606b5d97 remove unused (and bit-rotting) Lua support
Change-Id: I1ee2d21b79e929e5976825ae75aa4db960b034c9
Docs-Preview: https://skia.org/?cl=315856
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/315856
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-09-09 14:33:32 +00:00
Florin Malita
cdb0f8e523 [skottie] Assorted shape repeater fixes
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>
2020-08-26 13:24:53 +00:00
Brian Salomon
87d42e5d12 A new way to specify YUVA planar data from SkCodec to SkImage_Lazy
Tunnels through SkImageGenerator as well.

The new SkCodec interface doesn't assume three 8 bit planes.

New SkYUVASpec more clearly defines chroma subsampling and siting of
the planes.

The intent is to use this for other YUVA APIs as well, in particular
SkImage factories in the future.

In this change we convert to the SkYUVASpec to SkYUVASizeInfo
and SkYUVAIndex[4] representation. But the intent is to use
the SkYUVASpec representation throughout the pipeline once
legacy APIs are removed.

orientation GM is replicated to test a variety of chroma
subsampling configs.

Bug: skia:10632

Change-Id: I3fad35752b87cac16c51b24824331f2ae7d458d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309658
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2020-08-24 14:25:32 +00:00
Florin Malita
13c4dbe2ef [skottie] Add support for baseline shift
AE allows specifying a baseline shift [1] for text content.

This is essentially a vertical offset.

[1] https://helpx.adobe.com/after-effects/using/formatting-characters-character-panel.html#text_scale_and_baseline_shift

Change-Id: I6abfc47912735376f044769d6be6c25115dc62b6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/312483
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2020-08-21 20:05:10 +00:00
Leon Scroggins III
f21d6b9b71 Reland "Add an SkImageGenerator that uses NDK APIs"
This reverts commit 07438b0cda.

Bug: skia:10369
Bug: skia:10371

This will allow Skia clients developing for Android 11+ to rely on
Android's NDK APIs for decoding, which will allow them to decode
without including their own decoding libraries (e.g. libjpeg-turbo).
Using these APIs also provides support for static HEIF images.

Run ImageGenSrc in kPlatform_Mode on Android to verify decoding
visually.

Add tests and a grayscale png.

Update some test bots running Android R to specify ndk_api so they will
run the new code.

Change-Id: I4ca07d832dbd6a9d8cff0faea975fd70da00718f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308185
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-08-05 18:55:30 +00:00
Leon Scroggins
07438b0cda Revert "Add an SkImageGenerator that uses NDK APIs"
This reverts commit cfef980939.

Reason for revert: Breaking Google3 roll

Original change's description:
> Add an SkImageGenerator that uses NDK APIs
> 
> Bug: skia:10369
> Bug: skia:10371
> 
> This will allow Skia clients developing for Android 11+ to rely on
> Android's NDK APIs for decoding, which will allow them to decode
> without including their own decoding libraries (e.g. libjpeg-turbo).
> Using these APIs also provides support for static HEIF images.
> 
> Run ImageGenSrc in kPlatform_Mode on Android to verify decoding
> visually.
> 
> Add tests and a grayscale png.
> 
> Update some test bots running Android R to specify ndk_api so they will
> run the new code.
> 
> Change-Id: Ica782339b2414d472ede0b61729a127ce41892a5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305689
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Leon Scroggins <scroggo@google.com>

TBR=djsollen@google.com,mtklein@google.com,scroggo@google.com,brianosman@google.com,reed@google.com

Change-Id: Ifed506a76a0ff5903d101c1bf7330d319b8376a6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10369
Bug: skia:10371
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308180
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-08-05 14:42:51 +00:00
Leon Scroggins III
cfef980939 Add an SkImageGenerator that uses NDK APIs
Bug: skia:10369
Bug: skia:10371

This will allow Skia clients developing for Android 11+ to rely on
Android's NDK APIs for decoding, which will allow them to decode
without including their own decoding libraries (e.g. libjpeg-turbo).
Using these APIs also provides support for static HEIF images.

Run ImageGenSrc in kPlatform_Mode on Android to verify decoding
visually.

Add tests and a grayscale png.

Update some test bots running Android R to specify ndk_api so they will
run the new code.

Change-Id: Ica782339b2414d472ede0b61729a127ce41892a5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305689
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-08-05 13:44:39 +00:00
Leon Scroggins III
07b0099820 Remove "master" from lua files
Bug: chromium:1101491
Bug: b/161896447

Change-Id: I68f7f0ed65ac94550b167328e70d7bdb25a60189
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305964
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2020-07-28 13:35:37 +00:00
Florin Malita
d1ae99438e [skottie] Add support for inline/data-uri fonts
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>
2020-07-25 13:46:52 +00:00
Florin Malita
72db717348 [skottie] Add spread/choke support for glow styles
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>
2020-07-22 23:20:02 +00:00
Florin Malita
a524ea266d [skottie] More masking fixes
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>
2020-07-21 13:58:45 +00:00
Florin Malita
f2d90659ff [skottie] Fix analytical mask fill type
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>
2020-07-17 18:35:23 +00:00
Florin Malita
71dc916852 [skottie] Pucker & Bloat shape layer vector effect
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>
2020-07-10 18:09:53 +00:00
Florin Malita
082323b57d [skottie] Fill-over-stroke support for text
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>
2020-07-10 14:44:23 +00:00
Florin Malita
cfbb56c6e1 [skottie] Auto-orient fixes
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>
2020-07-08 13:52:27 +00:00
Florin Malita
c7b49bbb9b [skottie] Fix merge paths <-> paints interaction
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>
2020-07-07 17:28:47 +00:00
Florin Malita
6ec66b9d38 [skottie] Add shape layer Offset Paths support
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>
2020-07-06 16:31:52 +00:00
Florin Malita
8155976877 [skottie] Add line-spacing animator support
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>
2020-07-06 15:41:12 +00:00
Brian Osman
9c3eccd5d7 Runtime effect implementation of color cube filter
Bug: skia:10274
Change-Id: Ifb2ef8bf031e74d9d5c8183efe5aff4e6f3d2e7c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292562
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-05-28 15:45:48 +00:00
Florin Malita
6a414b277b [skottie] Layer auto-orient support
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>
2020-05-25 16:19:23 +00:00
Ben Wagner
0c228e3f64 Add ahem.ttf.
This font comes up fairly often due to being included as a primary font
in css testing. There are several Paragraph samples which already assume
it is present at this location. It is fairly small and very liberally
licensed.

This font file is ahem.ttf from
https://www.w3.org/Style/CSS/Test/Fonts/Ahem/ .

Change-Id: I6fdcb036cecca66e725ecb30e0a07fef1dfb1cdf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289445
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2020-05-13 16:32:52 +00:00
Florin Malita
fbddfbb9f3 [skottie] Introduce an external layer API
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>
2020-05-06 20:31:14 +00:00
Florin Malita
a9379fb8ed [skottie] Contrast cleanup
- fix/update sample labels
  - make a note of sin-based improved approximation

TBR=
Change-Id: I53b02cd8a6dd1499805b9782fb6378d344476b87
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286037
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-04-29 13:57:22 +00:00
Florin Malita
f2072332f4 [skottie] Non-legacy (is this modern?) contrast effect support
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>
2020-04-29 12:42:41 +00:00
Florin Malita
fc75d5c52d [skottie] Brightness and Contrast effect
Add support for brightness/contrast, "legacy mode".  This effect can
be represented as a color matrix.

Brightness transfer function: https://www.desmos.com/calculator/zne0oqwwzb

Contrast transfer function: https://www.desmos.com/calculator/x5rxzhowhs

Change-Id: I2e6bb0f5f809aa0f33362bf753d2fe447059eaaa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285577
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
2020-04-28 14:33:12 +00:00
Florin Malita
bf03ac53f1 [skottie] Initial outer/inner glow
Supported controls:

  - color
  - opacity
  - size
  - inner source (edge/center)

Change-Id: I1ada43fe46fa5557e11279abca6128042acef965
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285005
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-04-23 13:46:48 +00:00
Florin Malita
e35a7ea7a9 [skottie] Initial inner shadow layer style support
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>
2020-04-17 19:57:08 +00:00
Herb Derby
31f6d043af Schedule using tree order traversal the DAG.
Trace out the tree from the DAG. Trace nodes
with fan-out > 1 after all out edges have been traced.

Change-Id: Ic078d212adf95a19146fcbd9fb8d103ea23360ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283557
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-04-15 17:13:06 +00:00
Mike Klein
45d9cc86b3 remove i16x2 ops
These are neat but mostly just a distraction for now.
I've left all the assembly in place and unit tested
to make putting these back easy when we want to.

Change-Id: Id2bd05eca363baf9c4e31125ee79e722ded54cb7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283307
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2020-04-13 19:08:11 +00:00
Brian Osman
95c26efc90 Pure SkSL RNG for particles
Change-Id: I2cb6255a553852a292427d6dc9ef8c5ed7f8286d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252926
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-04-10 17:20:07 +00:00