Commit Graph

67 Commits

Author SHA1 Message Date
John Stiles
7134646ebd Migrate SkSLExternalFunction to the ir/ directory.
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>
2021-04-13 14:17:16 +00:00
Brian Osman
4d76f63e45 Fix particle bug where uniforms are allocated too late
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>
2021-02-03 22:50:28 +00:00
Brian Osman
360035c244 Particle cleanup
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>
2021-02-03 17:59:49 +00:00
Brian Osman
383168902b Particle refactor: Only have one code string, uniforms, etc.
Leverage the field visitor to temporarily support effects with the old
JSON layout.

See also: https://skia-review.googlesource.com/c/buildbot/+/363784

Change-Id: Ifab128172089fe9e570be96d7067c6c9d25aae9b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363878
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
2021-02-01 19:29:48 +00:00
Brian Osman
38d8deae8f Revert "Add particle GM that uses uniforms, fix related bug in particle effect"
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>
2021-01-29 19:21:49 +00:00
Brian Osman
964b4465c4 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>
2021-01-29 18:01:48 +00:00
Brian Osman
e89d8ea20b Update particle system to use skvm, rather than ByteCode
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>
2021-01-21 23:07:29 +00:00
Brian Osman
ace3f2939f Remove SkEffectBinding feature from particle system
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>
2021-01-12 19:36:27 +00:00
Brian Osman
be0b3b7363 Strip down SkSL::ExternalValues, limit them to functions
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>
2021-01-07 14:28:41 +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
265064450f Remove 'flags' feature from particles
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>
2020-12-22 21:05:23 +00:00
Brian Osman
32d53550c8 Remove unsafe compiler methods related to external values
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>
2020-09-24 14:12:08 +00:00
John Stiles
a6841be235 Enable ClangTidy check llvm-namespace-comment.
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>
2020-08-06 19:07:52 +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
Brian Osman
b08cc024cd Switch back to stack-based SkSL interpreter
It's slower, but code size is quite a bit smaller, memory usage is
smaller, and we think that mapping it to SkVM is just as easy.

This effectively reverts all of the following commits:

"Fix gcc9 warning around size of memset."
https://skia-review.googlesource.com/c/skia/+/279861

"Remove unused (and misleading) 'instruction' from SkSLInterpreter.h"
https://skia-review.googlesource.com/c/skia/+/278177

"Interpreter: Fix intrinsics when called with vector types"
https://skia-review.googlesource.com/c/skia/+/272721

"Make it easier to add vector versions of byte code instructions"
https://skia-review.googlesource.com/c/skia/+/272527

"Interpreter: Support returns from runStriped"
https://skia-review.googlesource.com/c/skia/+/268941

"add SkSLInterpreter vector instructions"
https://skia-review.googlesource.com/c/skia/+/266560

"Fix crash when editing particle scripts"
https://skia-review.googlesource.com/c/skia/+/269487

"Revert "Revert "Complete rewrite of the SkSL interpreter"""
https://skia-review.googlesource.com/c/skia/+/266205

Change-Id: I4258596399c4ca94489d4faf8aacfec88afeee13
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281205
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-04-03 17:20:04 +00:00
Ethan Nicholas
b962eff76c Revert "Revert "Complete rewrite of the SkSL interpreter""
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>
2020-01-24 14:42:37 +00:00
Ben Wagner
470e0ac14a Revert "Revert "Revert "Complete rewrite of the SkSL interpreter"""
This reverts commit 7deb1c26ba.

Revert "maybe fixed?"

This reverts commit 7ad3f229c7.

Revert "removed extraneous change"

This reverts commit 682f299aa8.

Revert "test change"

This reverts commit 5f40986cef.

Revert "derp"

This reverts commit 4f830b8df3.

Revert "let's see what happens"

This reverts commit d5290563f0.

Change-Id: Ib3c13c2a6ade9fc42382509d036e212c7fe50cc6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265979
Reviewed-by: Ben Wagner aka dogben <benjaminwagner@google.com>
2020-01-22 21:59:48 +00:00
Ethan Nicholas
7deb1c26ba Revert "Revert "Complete rewrite of the SkSL interpreter""
This reverts commit 99c54f0290.
2020-01-22 16:44:31 -05:00
Ethan Nicholas
99c54f0290 Revert "Complete rewrite of the SkSL interpreter"
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>
2020-01-21 16:07:08 +00:00
Ethan Nicholas
2cde3a1320 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>
2020-01-21 14:49:59 +00:00
Brian Osman
6104ba0dca Particles: Do a cleanup/standardization pass on the API
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>
2019-12-03 20:06:18 +00:00
Brian Osman
9dac0d8216 Particles: Better integration for ResourceProvider
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>
2019-12-03 14:12:50 +00:00
Brian Osman
d12f2786e2 Use ResourceProvider in particles
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>
2019-11-27 16:45:23 +00:00
Brian Osman
5b43113e75 Interpreter: Reflect all uniform variables in ByteCode
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>
2019-10-16 15:35:48 +00:00
Brian Osman
df18296f98 Add accessors to get/set SkParticleEffect fields
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>
2019-10-15 14:54:50 +00:00
Brian Osman
7edfb69406 Remove SkCurve and SkColorCurve
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>
2019-10-08 15:38:20 +00:00
Brian Osman
9b8b4558d2 Change ByteCode and ByteCodeFunction to classes
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>
2019-09-30 18:02:24 +00:00
Brian Osman
559ffe4a23 Particles: Added particle flags for tracking state (one-time triggers, etc)
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>
2019-09-25 15:58:09 +00:00
Brian Osman
9a8b846baf Particles: Sub-effect spawning and some slight refactoring
* 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>
2019-09-19 15:18:13 +00:00
Brian Osman
d1846d85ad Update SkParticleEffect comments based on review feedback
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>
2019-09-17 18:10:00 +00:00
Brian Osman
d46cb9729b Particle effect scripting update
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>
2019-09-16 17:48:04 +00:00
Brian Osman
61e17c51ad Particles: Change effect lifetime logic to work like particles
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>
2019-09-03 13:56:39 +00:00
Brian Osman
33f9d69353 Pass SkPaint by const-ref to SkParticleDrawable
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>
2019-08-30 19:03:36 +00:00
Brian Osman
2aa85df8e7 Particle cleanup: split SkParticleBinding out of SkParticleEffect
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>
2019-08-30 15:32:38 +00:00
Mike Klein
334a642b20 remove unused sk_sp comparison operators
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>
2019-08-27 14:52:01 +00:00
Brian Osman
3da607ec72 Finish and document particle public API
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>
2019-07-29 13:30:26 +00:00
Brian Osman
e59acb79b8 Particles: Merge spawn & update into one code string with two functions
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>
2019-07-25 23:51:07 +00:00
Brian Osman
d6108add51 Particles: Use list of lines for multi-line string serialization
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>
2019-07-25 20:55:43 +00:00
Brian Osman
fe49163cd1 Major rewrite of the particle system based on the SkSL interpreter
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>
2019-07-25 19:59:03 +00:00
Brian Osman
e1cb9ac0e1 Particles: SkScalar -> float
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>
2019-06-24 15:10:38 +00:00
Brian Osman
fb32ddf622 Revert "Revert "Shuffle SkSL sources around so compiler and bytecode can be used w/o GPU""
This reverts commit 37a59ef1af.

Change-Id: If38da265ebbb196e72c7d035ba51028438787e2e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221541
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-06-18 14:47:12 +00:00
Robert Phillips
37a59ef1af Revert "Shuffle SkSL sources around so compiler and bytecode can be used w/o GPU"
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>
2019-06-18 11:35:18 +00:00
Brian Osman
90507286cc 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>
2019-06-17 21:16:18 +00:00
Mike Klein
c0bd9f9fe5 rewrite includes to not need so much -Ifoo
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>
2019-04-24 16:27:11 +00:00
Brian Osman
d0c1bd43d9 Particle cleanup: IWYU
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>
2019-03-06 22:26:40 +00:00
Brian Osman
93c47cc8e3 SkReflected - avoid double registration, auto register base types, etc.
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>
2019-03-06 20:29:38 +00:00
Brian Osman
b77d502946 Particles: Cleanup and better UI
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>
2019-03-06 18:42:11 +00:00
Kevin Lubick
269fe89950 [canvaskit] Add particles integration
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>
2019-03-06 14:52:56 +00:00
Brian Osman
bdcdf1a7c3 Add SkParticleValue to allow further customization of curve behavior
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>
2019-03-04 22:04:17 +00:00
Brian Osman
3d76d1bf46 Particles: Removed emitters, added more full-featured position affectors
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>
2019-02-28 21:16:02 +00:00