skia2/include/core/SkCubicMap.h
Florin Malita 8dd5ea1a75 [skottie] Allow extra-normal Bezier interpolation
AE/Lottie allow Bezier control Ys to be outside the [0..1] range.

Update SkCubicMap to do the same.

Bug: skia:8931
Change-Id: I54ee8dbb4e6e0a33a917500523c82fe56c854d4a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205002
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-03-29 18:23:03 +00:00

42 lines
844 B
C++

/*
* 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"
/**
* 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 }
* pts[1,2].X are inside the unit [0..1]
*/
class SK_API SkCubicMap {
public:
SkCubicMap(SkPoint p1, SkPoint p2);
float computeYFromX(float x) const;
SkPoint computeFromT(float t) const;
private:
enum Type {
kLine_Type, // x == y
kCubeRoot_Type, // At^3 == x
kSolver_Type, // general monotonic cubic solver
};
SkPoint fCoeff[3];
Type fType;
};
#endif