1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

LibGfx+LibWeb: Move Gfx::ScaledFont caching from LibWeb into LibGfx

Before this change, we would only cache and reuse Gfx::ScaledFont
instances for downloaded CSS fonts.

By moving it into Gfx::VectorFont, we get caching for all vector fonts,
including local system TTFs etc.

This avoids a *lot* of style invalidations in LibWeb, since we now vend
the same Gfx::Font pointer for the same font when used repeatedly.
This commit is contained in:
Andreas Kling 2023-12-25 12:45:18 +01:00
parent bf8107b247
commit f900957d26
16 changed files with 54 additions and 137 deletions

View file

@ -17,7 +17,6 @@
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/FontCache.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Layout/BoxModelMetrics.h>
#include <LibWeb/Painting/PaintContext.h>
@ -300,7 +299,8 @@ inline Gfx::Font const& Node::scaled_font(PaintContext& context) const
inline Gfx::Font const& Node::scaled_font(float scale_factor) const
{
return document().style_computer().font_cache().scaled_font(first_available_font(), scale_factor);
auto const& font = first_available_font();
return *font.with_size(font.point_size() * scale_factor);
}
inline const CSS::ImmutableComputedValues& Node::computed_values() const