Flutter Engine
The Flutter Engine
SkCubicMap.h
Go to the documentation of this file.
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
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 */
24public:
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
35private:
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
#define SK_API
Definition: SkAPI.h:35
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:107
static bool IsLinear(SkPoint p1, SkPoint p2)
Definition: SkCubicMap.h:27
double x
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165