1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 10:17:34 +00:00

LibGfx: Optimize anti-aliased line drawing and stroking

This patch optimizes the drawing of aa-lines by rotating the drawn
rectangle to the direction where the line points. That enables us to
draw non-straight lines with the proper width.
If a aa-line is drawn that is infact a straigt line we now dont plot
those lines with multipe rectangles across the line - insted we draw
straight lines in one go with just one rectangle of proper size.
Stroking of lines has been enhanced to take care of the edges between
two lines with drawing the stroke till the intersections of two
connected lines.
This commit is contained in:
Torstennator 2022-08-23 19:12:04 +02:00 committed by Andreas Kling
parent 7c09d7c52f
commit b2a6066042
2 changed files with 181 additions and 6 deletions

View file

@ -7,6 +7,8 @@
#pragma once
#include <LibGfx/Painter.h>
#include <LibGfx/Path.h>
#include <LibGfx/Quad.h>
namespace Gfx {
@ -81,9 +83,13 @@ private:
};
template<AntiAliasPolicy policy>
void draw_anti_aliased_line(FloatPoint const&, FloatPoint const&, Color, float thickness, Painter::LineStyle style, Color alternate_color);
void stroke_segment_intersection(FloatPoint const& current_line_a, FloatPoint const& current_line_b, FloatLine const& previous_line, Color, float thickness);
FloatQuad build_rotated_rectangle(FloatPoint const& direction, float width);
Painter& m_underlying_painter;
AffineTransform m_transform;
Path m_intersection_edge_path;
Path m_rotated_rectangle_path;
};
}