Debian Codegraph @

include/core/SkCubicMap.h

raw
1 /*
2 * Copyright 2018 Google Inc.
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 SkCubicMap_DEFINED
9 #define SkCubicMap_DEFINED
10
11 #include "include/core/SkPoint.h"
12 #include "include/core/SkScalar.h"
13 #include "include/core/SkTypes.h"
14
15 /**
16 * Fast evaluation of a cubic ease-in / ease-out curve. This is defined as a parametric cubic
17 * curve inside the unit square.
18 *
19 * pt[0] is implicitly { 0, 0 }
20 * pt[3] is implicitly { 1, 1 }
21 * pts[1,2].X are inside the unit [0..1]
22 */
23 class SK_API SkCubicMap {
24 public:
25 SkCubicMap(SkPoint p1, SkPoint p2);
26
27 static bool IsLinear(SkPoint p1, SkPoint p2) {
28 return SkScalarNearlyEqual(p1.fX, p1.fY) && SkScalarNearlyEqual(p2.fX, p2.fY);
29 }
30
31 float computeYFromX(float x) const;
32
33 SkPoint computeFromT(float t) const;
34
35 private:
36 enum Type {
37 kLine_Type, // x == y
38 kCubeRoot_Type, // At^3 == x
39 kSolver_Type, // general monotonic cubic solver
40 };
41
42 SkPoint fCoeff[3];
43 Type fType;
44 };
45
46 #endif
47