aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkCubicMap.h
blob: bd372e07d337b77de2974d568740260988e2eea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * 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"

class SkCubicMap {
public:
    void setPts(SkPoint p1, SkPoint p2);
    void setPts(float x1, float y1, float x2, float y2) {
        this->setPts({x1, y1}, {x2, y2});
    }

    SkPoint computeFromT(float t) const;
    float computeYFromX(float x) const;

    // experimental
    float hackYFromX(float x) const;

private:
    SkPoint fCoeff[4];
    // x->t lookup
    enum { kTableCount = 16 };
    struct Rec {
        float   fT0;
        float   fDT;

        float fY0;
        float fDY;
    };
    Rec fXTable[kTableCount];

    void buildXTable();
};
#endif