Debian Codegraph @

thirdparty/msdfgen/core/Scanline.h

raw symbols SCIP
1
2 #pragma once
3
4 #include <vector>
5 #include "base.h"
6
7 namespace msdfgen {
8
9 /// Fill rule dictates how intersection total is interpreted during rasterization.
10 enum FillRule {
11 FILL_NONZERO,
12 FILL_ODD, // "even-odd"
13 FILL_POSITIVE,
14 FILL_NEGATIVE
15 };
16
17 /// Resolves the number of intersection into a binary fill value based on fill rule.
18 bool interpretFillRule(int intersections, FillRule fillRule);
19
20 /// Represents a horizontal scanline intersecting a shape.
21 class Scanline {
22
23 public:
24 /// An intersection with the scanline.
25 struct Intersection {
26 /// X coordinate.
27 double x;
28 /// Normalized Y direction of the oriented edge at the point of intersection.
29 int direction;
30 };
31
32 static double overlap(const Scanline &a, const Scanline &b, double xFrom, double xTo, FillRule fillRule);
33
34 Scanline();
35 /// Populates the intersection list.
36 void setIntersections(const std::vector<Intersection> &intersections);
37 #ifdef MSDFGEN_USE_CPP11
38 void setIntersections(std::vector<Intersection> &&intersections);
39 #endif
40 /// Returns the number of intersections left of x.
41 int countIntersections(double x) const;
42 /// Returns the total sign of intersections left of x.
43 int sumIntersections(double x) const;
44 /// Decides whether the scanline is filled at x based on fill rule.
45 bool filled(double x, FillRule fillRule) const;
46
47 private:
48 std::vector<Intersection> intersections;
49 mutable int lastIndex;
50
51 void preprocess();
52 int moveTo(double x) const;
53
54 };
55
56 }