• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkPoint.h"
12 
13 /**
14  *  Fast evaluation of a cubic ease-in / ease-out curve. This is defined as a parametric cubic
15  *  curve inside the unit square.
16  *
17  *  pt[0] is implicitly { 0, 0 }
18  *  pt[3] is implicitly { 1, 1 }
19  *  pts[1,2] are inside the unit square
20  */
21 class SK_API SkCubicMap {
22 public:
23     SkCubicMap(SkPoint p1, SkPoint p2);
24 
25     float computeYFromX(float x) const;
26 
27     SkPoint computeFromT(float t) const;
28 
29 private:
30     enum Type {
31         kLine_Type,     // x == y
32         kCubeRoot_Type, // At^3 == x
33         kSolver_Type,   // general monotonic cubic solver
34     };
35 
36     SkPoint fCoeff[3];
37     Type    fType;
38 };
39 
40 #endif
41 
42