2019-02-15 19:29:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Google LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkParticleDrawable_DEFINED
|
|
|
|
#define SkParticleDrawable_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "modules/particles/include/SkReflected.h"
|
2019-02-15 19:29:38 +00:00
|
|
|
|
|
|
|
class SkCanvas;
|
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:14:50 +00:00
|
|
|
struct SkParticles;
|
2019-02-15 19:29:38 +00:00
|
|
|
class SkPaint;
|
|
|
|
class SkString;
|
|
|
|
|
2019-11-27 15:34:18 +00:00
|
|
|
namespace skresources { class ResourceProvider; }
|
|
|
|
|
2019-02-15 19:29:38 +00:00
|
|
|
class SkParticleDrawable : public SkReflected {
|
|
|
|
public:
|
|
|
|
REFLECTED_ABSTRACT(SkParticleDrawable, SkReflected)
|
|
|
|
|
2019-11-27 15:34:18 +00:00
|
|
|
virtual void draw(const skresources::ResourceProvider* resourceProvider, SkCanvas* canvas,
|
|
|
|
const SkParticles& particles, int count, const SkPaint& paint) = 0;
|
2019-02-15 19:29:38 +00:00
|
|
|
|
|
|
|
static void RegisterDrawableTypes();
|
|
|
|
|
|
|
|
static sk_sp<SkParticleDrawable> MakeCircle(int radius);
|
2019-11-27 15:34:18 +00:00
|
|
|
static sk_sp<SkParticleDrawable> MakeImage(const SkString& path, const SkString& name,
|
|
|
|
int cols, int rows);
|
2019-02-15 19:29:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SkParticleEffect_DEFINED
|