2018-01-04 22:05:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkCubicMap_DEFINED
|
|
|
|
#define SkCubicMap_DEFINED
|
|
|
|
|
|
|
|
#include "SkPoint.h"
|
|
|
|
|
2018-08-13 20:03:25 +00:00
|
|
|
/**
|
|
|
|
* Fast evaluation of a cubic ease-in / ease-out curve. This is defined as a parametric cubic
|
|
|
|
* curve inside the unit square.
|
|
|
|
*
|
|
|
|
* pt[0] is implicitly { 0, 0 }
|
|
|
|
* pt[3] is implicitly { 1, 1 }
|
2019-03-29 17:25:41 +00:00
|
|
|
* pts[1,2].X are inside the unit [0..1]
|
2018-08-13 20:03:25 +00:00
|
|
|
*/
|
2019-02-28 15:37:45 +00:00
|
|
|
class SK_API SkCubicMap {
|
2018-01-04 22:05:11 +00:00
|
|
|
public:
|
2019-03-06 21:34:21 +00:00
|
|
|
SkCubicMap(SkPoint p1, SkPoint p2);
|
2018-01-04 22:05:11 +00:00
|
|
|
|
|
|
|
float computeYFromX(float x) const;
|
|
|
|
|
2018-08-13 20:03:25 +00:00
|
|
|
SkPoint computeFromT(float t) const;
|
2018-01-04 22:05:11 +00:00
|
|
|
|
|
|
|
private:
|
2018-08-14 21:21:23 +00:00
|
|
|
enum Type {
|
|
|
|
kLine_Type, // x == y
|
|
|
|
kCubeRoot_Type, // At^3 == x
|
|
|
|
kSolver_Type, // general monotonic cubic solver
|
|
|
|
};
|
2019-03-06 21:34:21 +00:00
|
|
|
|
2018-08-13 20:03:25 +00:00
|
|
|
SkPoint fCoeff[3];
|
2018-08-14 21:21:23 +00:00
|
|
|
Type fType;
|
2018-01-04 22:05:11 +00:00
|
|
|
};
|
2018-08-13 20:03:25 +00:00
|
|
|
|
2018-01-04 22:05:11 +00:00
|
|
|
#endif
|
|
|
|
|