mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibWeb: Optimize painting if all background layers have normal blending
a73cd88
resulted in a severe performance regression because now we emit
for every paintable an expensive SaveLayer display list item, for which
Skia internally allocates a new surface.
With this change we emit a SaveLayer only if paintable has any layers
with non-normal blending.
This commit is contained in:
parent
a73cd88f0c
commit
82dba26d79
1 changed files with 13 additions and 5 deletions
|
@ -78,10 +78,16 @@ void paint_background(PaintContext& context, PaintableBox const& paintable_box,
|
|||
{
|
||||
auto& display_list_recorder = context.display_list_recorder();
|
||||
|
||||
// https://drafts.fxtf.org/compositing/#background-blend-mode
|
||||
// Background layers must not blend with the content that is behind the element,
|
||||
// instead they must act as if they are rendered into an isolated group.
|
||||
display_list_recorder.save_layer();
|
||||
auto has_any_layers_with_non_normal_blending = any_of(resolved_background.layers, [](auto& layer) {
|
||||
return mix_blend_mode_to_compositing_and_blending_operator(layer.blend_mode) != Gfx::CompositingAndBlendingOperator::Normal;
|
||||
});
|
||||
|
||||
if (has_any_layers_with_non_normal_blending) {
|
||||
// https://drafts.fxtf.org/compositing/#background-blend-mode
|
||||
// Background layers must not blend with the content that is behind the element,
|
||||
// instead they must act as if they are rendered into an isolated group.
|
||||
display_list_recorder.save_layer();
|
||||
}
|
||||
|
||||
DisplayListRecorderStateSaver state { display_list_recorder };
|
||||
if (resolved_background.needs_text_clip) {
|
||||
|
@ -306,7 +312,9 @@ void paint_background(PaintContext& context, PaintableBox const& paintable_box,
|
|||
}
|
||||
}
|
||||
|
||||
display_list_recorder.restore();
|
||||
if (has_any_layers_with_non_normal_blending) {
|
||||
display_list_recorder.restore();
|
||||
}
|
||||
}
|
||||
|
||||
ResolvedBackground resolve_background_layers(Vector<CSS::BackgroundLayerData> const& layers, PaintableBox const& paintable_box, Color background_color, CSSPixelRect const& border_rect, BorderRadiiData const& border_radii)
|
||||
|
|
Loading…
Add table
Reference in a new issue