1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:47:44 +00:00

LibWeb: Add fixed position stacking context support in GPU painter

This commit is contained in:
Aliaksandr Kalenik 2023-11-27 16:49:10 +01:00 committed by Andreas Kling
parent 93e172895a
commit 0ff977bd04

View file

@ -90,8 +90,13 @@ CommandResult PaintingCommandExecutorGPU::set_font(Gfx::Font const&)
return CommandResult::Continue; return CommandResult::Continue;
} }
CommandResult PaintingCommandExecutorGPU::push_stacking_context(float opacity, bool, Gfx::IntRect const& source_paintable_rect, Gfx::IntPoint post_transform_translation, CSS::ImageRendering, StackingContextTransform, Optional<StackingContextMask>) CommandResult PaintingCommandExecutorGPU::push_stacking_context(float opacity, bool is_fixed_position, Gfx::IntRect const& source_paintable_rect, Gfx::IntPoint post_transform_translation, CSS::ImageRendering, StackingContextTransform, Optional<StackingContextMask>)
{ {
painter().save();
if (is_fixed_position) {
auto const& translation = painter().transform().translation();
painter().translate(-translation);
}
if (opacity < 1) { if (opacity < 1) {
auto painter = AccelGfx::Painter::create(); auto painter = AccelGfx::Painter::create();
auto canvas = AccelGfx::Canvas::create(source_paintable_rect.size()); auto canvas = AccelGfx::Canvas::create(source_paintable_rect.size());
@ -102,7 +107,6 @@ CommandResult PaintingCommandExecutorGPU::push_stacking_context(float opacity, b
.opacity = opacity, .opacity = opacity,
.destination = source_paintable_rect }); .destination = source_paintable_rect });
} else { } else {
painter().save();
painter().translate(post_transform_translation.to_type<float>()); painter().translate(post_transform_translation.to_type<float>());
} }
return CommandResult::Continue; return CommandResult::Continue;
@ -113,9 +117,8 @@ CommandResult PaintingCommandExecutorGPU::pop_stacking_context()
if (stacking_contexts.last().opacity < 1) { if (stacking_contexts.last().opacity < 1) {
auto stacking_context = stacking_contexts.take_last(); auto stacking_context = stacking_contexts.take_last();
painter().blit_canvas(stacking_context.destination, *stacking_context.canvas, stacking_context.opacity); painter().blit_canvas(stacking_context.destination, *stacking_context.canvas, stacking_context.opacity);
} else {
painter().restore();
} }
painter().restore();
return CommandResult::Continue; return CommandResult::Continue;
} }