1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:37:34 +00:00

LibGfx: Revert #2154 and properly handle simple polygons

The existing scanline method works just fine, and only needs the points
to be available as floats.
This commit reverts the complex polygon mitigation, and instead fixes
the rasterization process to avoid generating complex polygons because
of precision issues.
This commit is contained in:
AnotherTest 2020-05-08 21:22:38 +04:30 committed by Andreas Kling
parent 0f0d73d1b5
commit 88738aefa3
3 changed files with 5 additions and 187 deletions

View file

@ -71,7 +71,7 @@ public:
void close();
struct LineSegment {
Point from, to;
FloatPoint from, to;
float inverse_slope;
float x_of_minimum_y;
float maximum_y;
@ -79,13 +79,7 @@ public:
float x;
};
enum ShapeKind {
Simple,
Complex,
};
const Vector<Segment>& segments() const { return m_segments; }
Vector<LineSegment> split_lines(ShapeKind);
const auto& split_lines()
{
if (m_split_lines.has_value())
@ -101,30 +95,12 @@ private:
void invalidate_split_lines()
{
m_split_lines.clear();
m_graph_node_map.clear();
}
void segmentize_path();
void generate_path_graph();
bool is_part_of_closed_polygon(const Point& p0, const Point& p1);
static unsigned hash_line(const Point& from, const Point& to);
Vector<Segment> m_segments;
Optional<Vector<LineSegment>> m_split_lines {};
struct PathGraphNode {
PathGraphNode(u32 hash, const LineSegment& line)
: hash(hash)
, line(line)
{
}
Vector<const PathGraphNode*> children;
u32 hash;
LineSegment line;
};
Optional<HashMap<u32, OwnPtr<PathGraphNode>>> m_graph_node_map;
};
inline const LogStream& operator<<(const LogStream& stream, const Path& path)