blob: 3b9bfc49310d0d30b12ec63371b520fdbc4036bf [file] [log] [blame]
Brian Osman7c979f52019-02-12 13:27:51 -05001/*
2* Copyright 2019 Google LLC
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
8#ifndef SkCurve_DEFINED
9#define SkCurve_DEFINED
10
11#include "SkScalar.h"
12
13class SkFieldVisitor;
14class SkRandom;
15
16// TODO: Generalize this to a keyframed list of cubics
17
18struct SkCurve {
19 SkCurve(SkScalar c = 0.0f) {
20 fRanged = false;
21 fMin[0] = fMin[1] = fMin[2] = fMin[3] = c;
22 fMax[0] = fMax[1] = fMax[2] = fMax[3] = c;
23 }
24
25 SkScalar eval(float x, SkRandom& random) const;
26 void visitFields(SkFieldVisitor* v);
27
28 bool fRanged;
29 SkScalar fMin[4];
30 SkScalar fMax[4]; // used if ranged
31};
32
33// Ranged constant. Keeping this here temporarily. Phase this out in favor of SkCurve everywhere.
34struct SkRangedFloat {
35 float eval(SkRandom& random) const;
36 float* vec() { return &fMin; }
37
38 float fMin = 0.0f;
39 float fMax = 0.0f;
40
41 void visitFields(SkFieldVisitor* v);
42};
43
44#endif // SkCurve_DEFINED