summaryrefslogtreecommitdiff
path: root/thirdparty/msdfgen/core/contour-combiners.h
blob: 944b119aba85b3365c041644ddc88bfedc184d46 (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

#pragma once

#include "Shape.h"
#include "edge-selectors.h"

namespace msdfgen {

/// Simply selects the nearest contour.
template <class EdgeSelector>
class SimpleContourCombiner {

public:
    typedef EdgeSelector EdgeSelectorType;
    typedef typename EdgeSelector::DistanceType DistanceType;

    explicit SimpleContourCombiner(const Shape &shape);
    void reset(const Point2 &p);
    EdgeSelector & edgeSelector(int i);
    DistanceType distance() const;

private:
    EdgeSelector shapeEdgeSelector;

};

/// Selects the nearest contour that actually forms a border between filled and unfilled area.
template <class EdgeSelector>
class OverlappingContourCombiner {

public:
    typedef EdgeSelector EdgeSelectorType;
    typedef typename EdgeSelector::DistanceType DistanceType;

    explicit OverlappingContourCombiner(const Shape &shape);
    void reset(const Point2 &p);
    EdgeSelector & edgeSelector(int i);
    DistanceType distance() const;

private:
    Point2 p;
    std::vector<int> windings;
    std::vector<EdgeSelector> edgeSelectors;

};

}