mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 07:33:20 +00:00

This patch introduces a per-Gfx::Font cache for harfbuzz text shaping results. As long as the same OpenType features are used, we now cache the results of harfbuzz shaping, saving massive amounts of time during text layout. As an example, it saves multiple seconds when loading the ECMAScript specification at <https://tc39.es/ecma262>. Before this change, harfbuzz shaping was taking up roughly 11% of a profile of loading that page. The cache brings it down to 1.8%. Note that the cache currently grows unbounded. I've left a FIXME about adding some limits.
21 lines
368 B
C++
21 lines
368 B
C++
/*
|
|
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
namespace Gfx {
|
|
|
|
struct ShapeFeature {
|
|
char tag[4];
|
|
u32 value;
|
|
|
|
bool operator==(ShapeFeature const&) const = default;
|
|
bool operator!=(ShapeFeature const&) const = default;
|
|
};
|
|
|
|
using ShapeFeatures = Vector<ShapeFeature, 4>;
|
|
|
|
}
|