1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:37:35 +00:00

LibGFX: Transform vertices when drawing antialiased lines

Previously we transformed each rasterized point when drawing a line.
Now we transform the lines' endpoints instead.

That means running two transforms per line instead of transforms for
each pixel. It is not clear that the overhead for the fast path is
still worth it. If we still want to optimize identity and translations,
it is probably better to do that inside AffineTransform.

In addition this will behave nicer if the transform includes scaling.
Previously this would rasterize lines before scaling. Which means
drawing too many points when scaling down, and not drawing enough
points when scaling up.
With the new approach we will automatically rasterize at pixel scale.

This is essentially the same as OpenGL, where vertices are transformed
and rasterization happens in screen space.
This commit is contained in:
Florian Stellbrink 2022-04-11 01:19:49 +02:00 committed by Andreas Kling
parent b4a8be5dc9
commit af3174c9ce
2 changed files with 8 additions and 21 deletions

View file

@ -37,7 +37,7 @@ private:
OnlyEnds,
Full,
};
template<AntiAliasPolicy policy, bool apply_transform>
template<AntiAliasPolicy policy>
void draw_anti_aliased_line(FloatPoint const&, FloatPoint const&, Color, float thickness, Painter::LineStyle style, Color alternate_color);
Painter& m_underlying_painter;