Coverage Report

Created: 2021-08-22 09:07

/src/skia/include/core/SkCubicMap.h
Line
Count
Source
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 "include/core/SkPoint.h"
12
13
/**
14
 *  Fast evaluation of a cubic ease-in / ease-out curve. This is defined as a parametric cubic
15
 *  curve inside the unit square.
16
 *
17
 *  pt[0] is implicitly { 0, 0 }
18
 *  pt[3] is implicitly { 1, 1 }
19
 *  pts[1,2].X are inside the unit [0..1]
20
 */
21
class SK_API SkCubicMap {
22
public:
23
    SkCubicMap(SkPoint p1, SkPoint p2);
24
25
65.3k
    static bool IsLinear(SkPoint p1, SkPoint p2) {
26
65.3k
        return SkScalarNearlyEqual(p1.fX, p1.fY) && SkScalarNearlyEqual(p2.fX, p2.fY);
27
65.3k
    }
28
29
    float computeYFromX(float x) const;
30
31
    SkPoint computeFromT(float t) const;
32
33
private:
34
    enum Type {
35
        kLine_Type,     // x == y
36
        kCubeRoot_Type, // At^3 == x
37
        kSolver_Type,   // general monotonic cubic solver
38
    };
39
40
    SkPoint fCoeff[3];
41
    Type    fType;
42
};
43
44
#endif
45