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/src/SkCurve.cpp b/modules/particles/src/SkCurve.cpp
index aa03853..1f14a79 100644
--- a/modules/particles/src/SkCurve.cpp
+++ b/modules/particles/src/SkCurve.cpp
@@ -24,12 +24,12 @@
     return pts[0]*(ix*ix*ix) + pts[1]*(3*ix*ix*x) + pts[2]*(3*ix*x*x) + pts[3]*(x*x*x);
 }
 
-SkScalar SkCurveSegment::eval(SkScalar x, SkRandom& random) const {
+SkScalar SkCurveSegment::eval(SkScalar x, SkScalar t, bool negate) const {
     SkScalar result = fConstant ? fMin[0] : eval_cubic(fMin, x);
     if (fRanged) {
-        result += ((fConstant ? fMax[0] : eval_cubic(fMax, x)) - result) * random.nextF();
+        result += ((fConstant ? fMax[0] : eval_cubic(fMax, x)) - result) * t;
     }
-    if (fBidirectional && random.nextBool()) {
+    if (fBidirectional && negate) {
         result = -result;
     }
     return result;
@@ -66,7 +66,12 @@
         segmentX = rangeMin;
     }
     SkASSERT(0.0f <= segmentX && segmentX <= 1.0f);
-    return fSegments[i].eval(segmentX, random);
+
+    // Always pull t and negate here, so that the stable generator behaves consistently, even if
+    // our segments use an inconsistent feature-set.
+    SkScalar t = random.nextF();
+    bool negate = random.nextBool();
+    return fSegments[i].eval(segmentX, t, negate);
 }
 
 void SkCurve::visitFields(SkFieldVisitor* v) {