blob: bd372e07d337b77de2974d568740260988e2eea5 [file] [log] [blame]
Mike Reed4c79ecf2018-01-04 17:05:11 -05001/*
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
13class SkCubicMap {
14public:
15 void setPts(SkPoint p1, SkPoint p2);
16 void setPts(float x1, float y1, float x2, float y2) {
17 this->setPts({x1, y1}, {x2, y2});
18 }
19
20 SkPoint computeFromT(float t) const;
21 float computeYFromX(float x) const;
22
23 // experimental
24 float hackYFromX(float x) const;
25
26private:
27 SkPoint fCoeff[4];
28 // x->t lookup
29 enum { kTableCount = 16 };
30 struct Rec {
31 float fT0;
32 float fDT;
33
34 float fY0;
35 float fDY;
36 };
37 Rec fXTable[kTableCount];
38
39 void buildXTable();
40};
41#endif
42