• 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 class SkCubicMap {
14 public:
15     void setPts(SkPoint p1, SkPoint p2);
setPts(float x1,float y1,float x2,float y2)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 
26 private:
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 
43