ladybird/Libraries/LibWeb/Painting/DisplayListPlayerSkia.h
Aliaksandr Kalenik d96dc6535f LibWeb+Compositor+WebContent: Simplify nested context composition
Nested navigables were represented through compositor surface ids owned
by the parent context. That forced CompositorState and ContextState to
maintain bidirectional attach/detach bookkeeping, publish child
snapshots into a surface map, and keep presentation mode variants just
to distinguish UI presentation from parent composition.

Record the child compositor context id directly in the display list and
let the compositor resolve it against the painting parent at playback
time. Child contexts now keep their parent context id and latest
rendered surface, while parents no longer track child maps or compositor
surface ids. UI presentation is represented separately from parent
composition, so closing a page only stops client presentation and nested
contexts keep using set_parent_context.
2026-06-18 07:08:34 +02:00

65 lines
2.2 KiB
C++

/*
* Copyright (c) 2024-2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefPtr.h>
#include <LibGfx/Forward.h>
#include <LibWeb/Painting/DisplayList.h>
#include <LibWeb/Painting/DisplayListCommand.h>
#include <LibWeb/Painting/DisplayListRecorder.h>
class GrDirectContext;
class SkPaint;
namespace Web::Painting {
class WEB_API DisplayListPlayerSkia final : public DisplayListPlayer {
public:
using CompositedContextResolver = Function<RefPtr<Gfx::PaintingSurface>(Web::Compositor::CompositorContextId)>;
DisplayListPlayerSkia();
explicit DisplayListPlayerSkia(RefPtr<Gfx::SkiaBackendContext>);
~DisplayListPlayerSkia();
using DisplayListPlayer::execute;
void execute(
DisplayList const&,
AccumulatedVisualContextTree const&,
DisplayListResourceStorage const&,
ScrollStateSnapshot const&,
RefPtr<Gfx::PaintingSurface>,
CanvasSurfaceRegistry const*,
CompositedContextResolver const*);
void flush(Gfx::PaintingSurface&) override;
void flush_async(Gfx::PaintingSurface&, Function<void()>&&);
void paint_scrollbar(Gfx::PaintingSurface&, PaintScrollBar const&);
private:
#define DECLARE_PLAY_COMMAND(command_type, player_method) \
void play_command(command_type const&) override;
ENUMERATE_DISPLAY_LIST_COMMANDS(DECLARE_PLAY_COMMAND)
#undef DECLARE_PLAY_COMMAND
void play_command(ApplyEffects const&, Gfx::Filter const*) override;
void apply_transform(Gfx::FloatPoint origin, Gfx::FloatMatrix4x4 const&) override;
void add_clip_path(Gfx::Path const&) override;
bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override;
SkPaint paint_style_to_skia_paint(DisplayListPaintStyle const&, Gfx::FloatRect const& bounding_rect);
Gfx::Path path_from_data(DisplayListDataSpan) const;
ReadonlySpan<Color> gradient_colors(DisplayListGradientColorStops) const;
ReadonlySpan<float> gradient_positions(DisplayListGradientColorStops) const;
RefPtr<Gfx::SkiaBackendContext> m_skia_backend_context;
CompositedContextResolver const* m_composited_context_resolver { nullptr };
};
}