Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Skia for 2D canvas, SVG, CSS borders, etc. #1024

Merged
merged 17 commits into from
Aug 20, 2024

Conversation

awesomekling
Copy link
Member

This PR renames Gfx::Painter and Gfx::Path to DeprecatedPainter and DeprecatedPath respectively.

We then introduce new Gfx::Painter and Gfx::Path classes that sit on top of Skia. They both have virtual internals, to keep the door open for using other rasterizers.

2D canvas, SVG and CSS code that uses path rendering is moved on top of the new classes, giving us a solid performance boost.

Finally, we yeet a bunch of now-unused code from LibGfx. We still need some of the OpenType font code for text layout, but that will eventually go as well.

This new painter is written with a virtual interface from the start,
and we begin with a Skia backend.

This patch adds enough to support our basic 2D HTML canvas usecase.
This thing is essentially a wrapper around an SkPath, although we do
some indirection via a PathImpl class to keep the door open for
alternative rasterizer/path backends in the future.

We also update the 2D canvas code, since that was the only code that
used Painter+DeprecatedPath, and this allows us to just drop that
code instead of temporarily supporting it until the next commit.
SVG and and CSS border rendering now sits on top of SkPath instead of
the old Gfx::DeprecatedPath.

Due to an imperceptible (255, 255, 255) vs (255, 254, 255) color diff
in one ref test, I changed that test to not depend on border rendering
for a positive result, since that was incidental.
We're not quite ready to remove the old OpenType implementation yet,
but let's carve off some unused stuff.
Now that the underlying Gfx::Painter is being transformed as we go,
we don't need to pre-emptively transform geometry before painting it.
This ensures that any internal state maintained by the painter gets
synchronized appropriately.
The CRC2D path should be unaffected by the CRC2D transform changing.
To achieve this, we transform the path to compensate whenever the
CRC2D transform is changed.
This allows us to get identical metrics on macOS and Linux. Without
this, Skia will use CoreText on macOS and give us slightly different
text metrics. That causes layout tests to be slightly different on
different platforms, which is a huge headache. So let's not do that.

You can now launch Ladybird and headless-browser with --force-fontconfig
to load fonts through fontconfig. Tests run in this mode by default.
@awesomekling awesomekling marked this pull request as ready for review August 20, 2024 07:28
@awesomekling awesomekling merged commit dd1b8de into LadybirdBrowser:master Aug 20, 2024
6 checks passed
@awesomekling awesomekling deleted the new_painter branch August 20, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant