Add "enabled" flag to affectors, fix curve interaction with stable random
Flag is helpful while editing things (and could be a useful property to
animate, as well). The curve change fixes a bug where the stable generator
gets out of phase if all segments of a curve don't use the same options.
Bug: skia:
Change-Id: Ie151e775aee22957e79fa88feaafad72b6c781ff
Reviewed-on: https://skia-review.googlesource.com/c/195120
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/modules/particles/include/SkCurve.h b/modules/particles/include/SkCurve.h
index b3c0ca6..ec61228 100644
--- a/modules/particles/include/SkCurve.h
+++ b/modules/particles/include/SkCurve.h
@@ -45,7 +45,7 @@
*/
struct SkCurveSegment {
- SkScalar eval(SkScalar x, SkRandom& random) const;
+ SkScalar eval(SkScalar x, SkScalar t, bool negate) const;
void visitFields(SkFieldVisitor* v);
void setConstant(SkScalar c) {
diff --git a/modules/particles/include/SkParticleAffector.h b/modules/particles/include/SkParticleAffector.h
index 97a5b0f..9a10d9c 100644
--- a/modules/particles/include/SkParticleAffector.h
+++ b/modules/particles/include/SkParticleAffector.h
@@ -21,7 +21,8 @@
public:
REFLECTED_ABSTRACT(SkParticleAffector, SkReflected)
- virtual void apply(SkParticleUpdateParams& params, SkParticleState& ps) = 0;
+ void apply(SkParticleUpdateParams& params, SkParticleState& ps);
+ void visitFields(SkFieldVisitor* v) override;
static void RegisterAffectorTypes();
@@ -36,6 +37,11 @@
static sk_sp<SkParticleAffector> MakeSize(const SkCurve& curve);
static sk_sp<SkParticleAffector> MakeFrame(const SkCurve& curve);
static sk_sp<SkParticleAffector> MakeColor(const SkColorCurve& curve);
+
+private:
+ virtual void onApply(SkParticleUpdateParams& params, SkParticleState& ps) = 0;
+
+ bool fEnabled = true;
};
#endif // SkParticleAffector_DEFINED