mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-24 19:28:48 +00:00
LibWeb: Avoid unnecessary save/restore in paint_background()
`paint_background()` is invoked for each PaintableBox, so by avoiding save/restore pair emitted for each call, we substantially decrease display list size. Website | DisplayList Items Before | DisplayList Items After -------------|--------------------------|------------------------- ladybird.org | 2753 | 1431 null.com | 5298 | 4714 discord.com | 6598 | 5360
This commit is contained in:
parent
62c5f4b822
commit
46097c6753
Notes:
github-actions[bot]
2025-07-08 08:25:26 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 46097c6753
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5345
Reviewed-by: https://github.com/gmta ✅
1 changed files with 7 additions and 2 deletions
|
@ -90,9 +90,11 @@ void paint_background(PaintContext& context, PaintableBox const& paintable_box,
|
|||
display_list_recorder.save_layer();
|
||||
}
|
||||
|
||||
DisplayListRecorderStateSaver state { display_list_recorder };
|
||||
bool is_root_element = paintable_box.layout_node().is_root_element();
|
||||
if (resolved_background.needs_text_clip && !is_root_element) {
|
||||
bool needs_text_clip = resolved_background.needs_text_clip && !is_root_element;
|
||||
|
||||
if (needs_text_clip) {
|
||||
display_list_recorder.save();
|
||||
auto display_list = compute_text_clip_paths(context, paintable_box, resolved_background.background_rect.location());
|
||||
auto rect = context.rounded_device_rect(resolved_background.background_rect);
|
||||
display_list_recorder.add_mask(move(display_list), rect.to_type<int>());
|
||||
|
@ -335,6 +337,9 @@ void paint_background(PaintContext& context, PaintableBox const& paintable_box,
|
|||
}
|
||||
}
|
||||
|
||||
if (needs_text_clip) {
|
||||
display_list_recorder.restore();
|
||||
}
|
||||
if (paint_into_isolated_group) {
|
||||
display_list_recorder.restore();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue