Change-Id: I8ca4fbba551624c61a4ebe7a4716750fe0b48196
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/395818
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Also adds an example particle system that uses uniforms, and an instance
of the particles GM that draws it.
Change-Id: I64e2514fd17c8ce615b4e13b9f82424f80b8424e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356840
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Remove/rename some fields now that data migration is done, adjust
comments to reflect new data, etc.
Change-Id: I77a8ff182fc73699407eb711a54cf5642f23c257
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365480
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This reverts commit 964b4465c4.
Reason for revert: Earlier CL needs revert
Original change's description:
> Add particle GM that uses uniforms, fix related bug in particle effect
>
> We weren't allocating uniform storage until after the first update, far
> too late for users to pump uniform values in. They're now allocated as
> soon as the effect is created, which is tested by the new GM.
>
> Change-Id: Ia0084bcec5986479c350ead27d14344c3ed82520
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362176
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
TBR=brianosman@google.com
Change-Id: Ib6f963840af2abba0a4e6b99185f4010b61dde54
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362418
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
We weren't allocating uniform storage until after the first update, far
too late for users to pump uniform values in. They're now allocated as
soon as the effect is created, which is tested by the new GM.
Change-Id: Ia0084bcec5986479c350ead27d14344c3ed82520
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362176
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This was the last remaining user of ByteCode. The skvm solution
is faster, and lets us delete the ByteCode system.
Testing on 15 instances of sinusoidal_emitter (90k particles):
- ByteCode ~9 ms
- ByteCode (older, optimized): ~5.5 ms
- skvm ~2.1 ms
Change-Id: Ia2e5c9ab2d36c97e59af28a6f989bf212889e439
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356919
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This is no longer used, and the current design is fairly incompatible
with skvm.
Change-Id: Ibebb9b42a0f4277c333839c3d1e9cf0f691b37cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/353079
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Previously ExternalValues were flexible, and could be used as raw values
(with the ability to chain access via dot notation), or they could be
callable. The only non-test use-case has been for functions (in
particles) for a long time. With the push towards SkVM, limiting
ourselves to this interface simplifies things: external functions are
basically custom intrinsics (and with the SkVM backend, they'll just get
access to the builder, and be able to do any math, as well as
loads/stores, etc).
By narrowing the feature set, we can rename everything to reflect that,
and it's overall clearer (the SkSL types now mirror FunctionReference
and FunctionCall directly, particularly in how they're handled by the
CFG and inliner).
Change-Id: Ib5dd34158ff85aae6c297408a92ace5485a08190
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350704
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
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>
No longer used by any example content, and it requires unsigned integers
and bitwise ops (which are both going to be hidden from public SkSL).
Bug: skia:11093
Change-Id: I1941f7a1bed6c8512a5117ef256d18e420cbabee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346779
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
We don't want to be polluting the global namespace with external values,
especially when the typical/recommended way to use the Compiler is with
a single long-lived instance. Force client code to manage ownership (the
only non-unit-test case was already doing this), and pass external
values to convertProgram, so they can be added to the Program's symbol
table.
Change-Id: If4c1db5e48a62e2cf4333b8d80420f2dfede27ab
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319125
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This fixes a large number of SkSL namespaces which were labeled as if
they were anonymous, and also a handful of other mislabeled namespaces.
Missing namespace-end comments have been added throughout.
A number of diffs are just indentation-related (adjusting 1- or 3-
space indents to 2-space).
Change-Id: I6c62052a0d3aea4ae12ca07e0c2a8587b2fce4ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308503
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
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>
This reverts commit 99c54f0290.
Change-Id: I010ac4fdb6c5b6bfbdf63f4dcac5dbf962b0ad9c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266205
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This reverts commit 2cde3a1320.
Reason for revert: breaking the Chrome roll
Original change's description:
> Complete rewrite of the SkSL interpreter
>
> Change-Id: Idf4037b04c22f8ace5c1ef16c7a28d8c3df92e91
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/250817
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
TBR=brianosman@google.com,ethannicholas@google.com
Change-Id: If0fbc78118173e0cacbe1e01cabe3331e35aa49e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265516
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Change-Id: Idf4037b04c22f8ace5c1ef16c7a28d8c3df92e91
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/250817
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
For clients not using JSON, the factories were inconsistent.
Change-Id: Ifd920fa1e18f5edffa12de238af8488406951e5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257683
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This untangles some of the dirty state tracking and dynamic rebuilding
support (that's only needed for the GUI editor), so the core code is
more streamlined. It also paves the way for feeding the RP to bindings.
Change-Id: I208ec59622154fdb2845c3ae8f7efb070d1abfc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257476
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Currently just for image drawable, but going to use this for
references to other kinds of data in bindings, too.
Change-Id: Ic6673530013337bbaadd2d3f1c040626ec24ffb8
Bug: skia:9513
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256776
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Gives enough information to locate variables by name (using the same
scheme as glGetUniformLocation), and provide hints about type and size.
Bug: skia:9513
Change-Id: I9444f1042471967a79c9f05167dcdb78eca41bad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244502
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Simplify burst handling. Scripts should just add to burst (if
they want to handle programmatic bursting, as well).
Update most effects to handle dynamic updates to position better,
and add a sample effect meant to be used with mouse tracking.
Change-Id: Ia302e1d04e62e2b07974807c44067786cc10a8ad
Bug: skia:9513
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248798
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This was only being used in one effect (and for no good reason). SkSL is
plenty powerful to re-implement something similar if required, at no
real performance cost.
Re-implemented the one effect that used it with simpler math in the
script, updated the copy of that effect in the gallery.
Docs-Preview: https://skia.org/?cl=247040
Change-Id: I68c86d6550dd4f003f6ba5ecd0febab37b86540b
Bug: skia:9513
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/247040
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
The lack of encapsulation was finally starting to bother me. Had to
change the Interpreter namespace to a struct so that it could be
friended, but otherwise this was a nice and simple cleanup.
Also updated the comments on the two run functions, and renamed
fInputSlots to fUniformSlots, to reflect recent clarification
around in vs. uniform.
Change-Id: I24bbc59778b3ab6448bffcf98133d5c149a060a9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244883
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Also removed some older effects that weren't interesting, improved others,
cleaned up the unused functions in several, and renamed most of them to
reflect which feature they're demonstrating.
Change-Id: Ib44a00ec3d25e852a1d1661918137ba13d30c86b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244119
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
* Added a new binding type, SkEffectBinding. This stores another
entire effect params structure (so the JSON is just nested).
The name is a callable value that spawns a new instance of
that effect, inheriting the parameters of the spawning effect
or particle (depending on which kind of script made the call).
* Broke up the monolithic update function into some helpers,
got some code reuse with the script calling logic.
* Unlike particle capacity, there is no upper limit on child
effects (yet), so it's easy to trigger runaway memory and
CPU consumption. Be careful.
* Added death scripts to effects and particles, which are a
common place to want to spawn sub-effects. Like spawn,
these run on each loop, but for one-shots they play at the
end. Even with loops, this is helpful for timing sub-effects
(see fireworks2.json).
* Finally, added a much more comprehensive example effect,
raincloud.json. This includes a total of three effects, to
generate a cloud, raindrops, and splashes when those drops
hit "the ground".
Change-Id: I3d7b72bcbb684642cd9723518b67ab1c7d7a538a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242479
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Change-Id: I3436ee95c4cc13067b53b170515fd10c19b329b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242136
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This change adds another layer of complexity and control to
the particle system. There are now two code chunks: the old
code that's run per-particle, and new code that's run for
the effect itself. This allows for effect lifetime to be set
by the script (eg, randomly), as well as the emission rate.
Rate can vary over time (see pulse.json), and particles can
be emitted in bursts by setting the effect's burst field
(see fireworks.json).
Additionally, the effect has its own frame of reference and
color, which becomes the default state for newly emitted
particles. This allows synchronizing state across particles
in various interesting ways (see color in fireworks.json).
Change-Id: Iec2f7a3427ce1d6411ed7ef5b3023cbef2e8a134
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/240498
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Change-Id: I9f71bfbd506b56eae4fe6a430b70f8f9a31d7009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238445
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Makes it clearer that this isn't optional, for drawables that route to
similar canvas calls.
Change-Id: I12142c11676ba6baeea3e2779ec05af601d8beb3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238440
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Also simplify type registration.
Change-Id: Ia47febb2ae2cd5821476c3dd33a688b688aa6d6d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238359
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
These unused comparison operators are the only users of
<functional> in SkRefCnt.h, for std::less. <functional>
is an expensive header to compile, and SkRefCnt.h is popular,
so it helps to cut dependencies like this.
Mostly we just need to add #include <functional> in a few
places that were picking it up via SkRefCnt.h.
In SkPixmapPriv.h, it looked simpler to template the argument,
since everything was inline anyway.
Change-Id: I7c125bb26a04199847357c729a1b178256c6ef8d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/236942
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Added factories to create particle binding objects, which were the only
piece that couldn't be generated programmatically.
Commented most of the things that a user needs to know to create an
effect from within code. (Except for all the details of SkSL).
Change-Id: I4003e536e46c77e0c1c9e83486cf99f0c2cf54d1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230120
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Change-Id: If57fb79db8f8c5fd185fefaa202167c8082dd846
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229921
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Change-Id: Ic81b3433b485ca9ce0e60bd10ec12706e673ee89
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229917
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This removes all of the fixed-function particle affector classes.
Instead, each particle effect just has two SkSL snippets, one for
spawn logic, and one for update logic. Each one gets an inout copy
of the particle struct. Ultimately, this makes the effects much
simpler and smaller, while also being far more flexible (you can
do whatever you want with any values you want). Finally, because
the interpreter is vectorized and a particular effect's scripts
are usually tuned to the specific behaviors desired, it's faster
on basically every effect I compared.
I re-created all of the old effects in the new system. Many just
use pure SkSL (no curves or anything). Some of the old curve and
path/text stuff was very handy, though - so those are now exposed
as external values in the interpreter. Basically, an effect can
have any number of named "bindings" that are a callable thing.
This can be a path, text (shortcut for making fancy paths), curve,
or color curve. The path ones return a float4 with position and
normal, the curves return one or four floats.
... and this transposes all of the particle data storage into
SoA form, so that it can use the much faster interpreter entry
point.
Change-Id: Iebe711c45994c4201041b12d171af976bc5e758e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/222057
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Pulling this cleanup out of a larger CL
Change-Id: Ib3ecff5d242eba72a7f2bc3ce07e09760a9ba7b7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223181
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This reverts commit 90507286cc.
Reason for revert: Seems to be breaking some builds
Original change's description:
> Shuffle SkSL sources around so compiler and bytecode can be used w/o GPU
>
> Change-Id: I7236a30040ab532086e68d6e9de2898dd7acaa32
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221098
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Mike Reed <reed@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>
TBR=mtklein@google.com,kjlubick@google.com,brianosman@google.com,ethannicholas@google.com,reed@google.com
Change-Id: Ie230315a72ebcfae32bc9ce7bafec1f87106cff2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221536
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Change-Id: I7236a30040ab532086e68d6e9de2898dd7acaa32
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221098
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Current strategy: everything from the top
Things to look at first are the manual changes:
- added tools/rewrite_includes.py
- removed -Idirectives from BUILD.gn
- various compile.sh simplifications
- tweak tools/embed_resources.py
- update gn/find_headers.py to write paths from the top
- update gn/gn_to_bp.py SkUserConfig.h layout
so that #include "include/config/SkUserConfig.h" always
gets the header we want.
No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Bug: skia:
Change-Id: If9d8a22a770e4125391d0fbd263521f6bdb7725d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198246
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Bug: skia:
Change-Id: I99913987ec5de044ecc9302335771f59d85126dc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198243
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Remove SkAnimTimer from the module interface entirely.
Clean up some other SkParticleEffect methods. Simplify
VisitTypes to just visit all of them, it's easier for
the client to do any filtering.
In the slide, make the UI far nicer. Load all files in
a given directory, and allow editing (and saving) them
all at once, or adding a new entry. Support multiple
playing effects, with a draggable handle to set the
position.
Bug: skia:
Change-Id: I0bec4077f9135bc122569f1410bebc96d5439480
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/197243
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Bug: skia:
Change-Id: I5bf08e8007b59b5e21005f5004d698e53b99ffe6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/197849
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
All curves (and path affectors) are driven by an SkParticleValue. The
value can derive its value from the current defaults (age of particle
or effect), or explicitly choose the other one, a random value, or any
other particle value. Values can be range adjusted and support repeat,
clamp, and mirror tiling.
Also fixed some more issues related to resource path in the slide GUI.
Bug: skia:
Change-Id: I4755018d5b57ae2d5ec400d541055ca4fb542978
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/196760
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Bug: skia:
Change-Id: Ie6485a11bb57fecef470d727dcf3b4fe5dff0b90
Reviewed-on: https://skia-review.googlesource.com/c/195582
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>