Path: blob/master/thirdparty/msdfgen/core/Scanline.h
10279 views
1#pragma once23#include <vector>4#include "base.h"56namespace msdfgen {78/// Fill rule dictates how intersection total is interpreted during rasterization.9enum FillRule {10FILL_NONZERO,11FILL_ODD, // "even-odd"12FILL_POSITIVE,13FILL_NEGATIVE14};1516/// Resolves the number of intersection into a binary fill value based on fill rule.17bool interpretFillRule(int intersections, FillRule fillRule);1819/// Represents a horizontal scanline intersecting a shape.20class Scanline {2122public:23/// An intersection with the scanline.24struct Intersection {25/// X coordinate.26double x;27/// Normalized Y direction of the oriented edge at the point of intersection.28int direction;29};3031static double overlap(const Scanline &a, const Scanline &b, double xFrom, double xTo, FillRule fillRule);3233Scanline();34/// Populates the intersection list.35void setIntersections(const std::vector<Intersection> &intersections);36#ifdef MSDFGEN_USE_CPP1137void setIntersections(std::vector<Intersection> &&intersections);38#endif39/// Returns the number of intersections left of x.40int countIntersections(double x) const;41/// Returns the total sign of intersections left of x.42int sumIntersections(double x) const;43/// Decides whether the scanline is filled at x based on fill rule.44bool filled(double x, FillRule fillRule) const;4546private:47std::vector<Intersection> intersections;48mutable int lastIndex;4950void preprocess();51int moveTo(double x) const;5253};5455}565758