aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/graphics/SkCullPoints.h
blob: def938d7ae11285490abab2e958e873055d7cbc4 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef SkCullPoints_DEFINED
#define SkCullPoints_DEFINED

#include "SkRect.h"

class SkCullPoints {
public:
    SkCullPoints();
    SkCullPoints(const SkRect16& r);
    
    void    reset(const SkRect16& r);
    
    /** Start a contour at (x,y). Follow this with call(s) to lineTo(...)
    */
    void    moveTo(int x, int y);
    
    enum LineToResult {
        kNo_Result,             //!< line segment was completely clipped out
        kLineTo_Result,         //!< path.lineTo(pts[1]);
        kMoveToLineTo_Result    //!< path.moveTo(pts[0]); path.lineTo(pts[1]);
    };
    /** Connect a line to the previous call to lineTo (or moveTo).
    */
    LineToResult lineTo(int x, int y, SkPoint16 pts[2]);

private:
    SkRect16    fR;
    SkPoint16   fAsQuad[4];
    SkPoint32   fPrevPt;    // local state
    
    bool sect_test(int x0, int y0, int x1, int y1) const;
};

/////////////////////////////////////////////////////////////////////////////////

class SkPath;

/** \class SkCullPointsPath

    Similar to SkCullPoints, but this class handles the return values
    from lineTo, and automatically builds a SkPath with the result(s).
*/
class SkCullPointsPath {
public:
    SkCullPointsPath();
    SkCullPointsPath(const SkRect16& r, SkPath* dst);

    void reset(const SkRect16& r, SkPath* dst);
    
    void    moveTo(int x, int y);
    void    lineTo(int x, int y);

private:
    SkCullPoints    fCP;
    SkPath*         fPath;
};

#endif