Skip to content

Truly independent web browser

LibCompositing+LibWeb+Compositor: Keep SVG image records in the tape

Aliaksandr Kalenik975974038863
diff --git a/Libraries/LibCompositing/DisplayList/DisplayListResourceStorage.cpp b/Libraries/LibCompositing/DisplayList/DisplayListResourceStorage.cpp
index fed9d4e54d9..dcf4013ea35 100644
--- a/Libraries/LibCompositing/DisplayList/DisplayListResourceStorage.cpp
+++ b/Libraries/LibCompositing/DisplayList/DisplayListResourceStorage.cpp
@@ -31,7 +31,7 @@ bool DisplayListResourceSet::is_empty() const
{
return fonts.is_empty()
&& image_frames.is_empty()
- && display_lists.is_empty();
+ && vector_images.is_empty();
}
void DisplayListResourceSet::include(DisplayListResourceSet const& other)
@@ -40,8 +40,8 @@ void DisplayListResourceSet::include(DisplayListResourceSet const& other)
fonts.set(id, AK::HashSetExistingEntryBehavior::Keep);
for (auto id : other.image_frames)
image_frames.set(id, AK::HashSetExistingEntryBehavior::Keep);
- for (auto id : other.display_lists)
- display_lists.set(id, AK::HashSetExistingEntryBehavior::Keep);
+ for (auto id : other.vector_images)
+ vector_images.set(id, AK::HashSetExistingEntryBehavior::Keep);
}
DisplayListResourceStorage::DisplayListResourceStorage() = default;
@@ -163,9 +163,9 @@ DisplayListResourceTransaction DisplayListResourceStorage::create_transaction(
if (!current.image_frames.contains(id))
transaction.image_frame_ids_to_remove.append(id);
}
- for (auto id : previous.display_lists) {
- if (!current.display_lists.contains(id))
- transaction.display_list_ids_to_remove.append(id);
+ for (auto id : previous.vector_images) {
+ if (!current.vector_images.contains(id))
+ transaction.vector_image_ids_to_remove.append(id);
}
return transaction;
}
diff --git a/Libraries/LibCompositing/DisplayList/DisplayListResourceStorage.h b/Libraries/LibCompositing/DisplayList/DisplayListResourceStorage.h
index c02f5d66ec6..a3543dfeb02 100644
--- a/Libraries/LibCompositing/DisplayList/DisplayListResourceStorage.h
+++ b/Libraries/LibCompositing/DisplayList/DisplayListResourceStorage.h
@@ -35,7 +35,7 @@ struct COMPOSITING_API DisplayListResourceSet {
HashTable<FontResourceId> fonts;
HashTable<ImageFrameResourceId> image_frames;
- HashTable<DisplayListResourceId> display_lists;
+ HashTable<DisplayListResourceId> vector_images;
};
struct DisplayListFontResource {
@@ -65,7 +65,7 @@ struct DisplayListResourceTransaction {
Vector<FontResourceId> font_ids_to_remove;
Vector<ImageFrameResourceId> image_frame_ids_to_remove;
- Vector<DisplayListResourceId> display_list_ids_to_remove;
+ Vector<DisplayListResourceId> vector_image_ids_to_remove;
};
class COMPOSITING_API DisplayListResourceStorage {
diff --git a/Libraries/LibCompositing/DisplayList/DisplayListResourceTransaction.cpp b/Libraries/LibCompositing/DisplayList/DisplayListResourceTransaction.cpp
index e2e459a4a46..824d8c68010 100644
--- a/Libraries/LibCompositing/DisplayList/DisplayListResourceTransaction.cpp
+++ b/Libraries/LibCompositing/DisplayList/DisplayListResourceTransaction.cpp
@@ -75,11 +75,9 @@ ErrorOr<void> encode(Encoder& encoder, Compositing::DisplayListResourceTransacti
{
TRY(encoder.encode(transaction.fonts));
TRY(encoder.encode(transaction.image_frames));
- // Only Rust sends nested display lists, which only the compositor's Rust receives.
- TRY(encoder.encode_size(0));
TRY(encoder.encode(transaction.font_ids_to_remove));
TRY(encoder.encode(transaction.image_frame_ids_to_remove));
- TRY(encoder.encode(transaction.display_list_ids_to_remove));
+ TRY(encoder.encode(transaction.vector_image_ids_to_remove));
return {};
}
@@ -89,17 +87,12 @@ ErrorOr<Compositing::DisplayListResourceTransaction> decode(Decoder& decoder)
auto fonts = TRY(decoder.decode<Vector<Compositing::DisplayListFontResource>>());
auto image_frames = TRY(decoder.decode<Vector<Compositing::DisplayListImageFrameResource>>());
- // Only the compositor's Rust receives nested display lists, with the visual context trees they were recorded
- // against.
- if (TRY(decoder.decode_size()) != 0)
- return Error::from_string_literal("Display list resources only go to the compositor's Rust");
-
return Compositing::DisplayListResourceTransaction {
.fonts = move(fonts),
.image_frames = move(image_frames),
.font_ids_to_remove = TRY(decoder.decode<Vector<Compositing::FontResourceId>>()),
.image_frame_ids_to_remove = TRY(decoder.decode<Vector<Compositing::ImageFrameResourceId>>()),
- .display_list_ids_to_remove = TRY(decoder.decode<Vector<Compositing::DisplayListResourceId>>()),
+ .vector_image_ids_to_remove = TRY(decoder.decode<Vector<Compositing::DisplayListResourceId>>()),
};
}
diff --git a/Libraries/LibCompositing/Rust/build.rs b/Libraries/LibCompositing/Rust/build.rs
index 916a72ee799..a05edd9f2cf 100644
--- a/Libraries/LibCompositing/Rust/build.rs
+++ b/Libraries/LibCompositing/Rust/build.rs
@@ -605,7 +605,7 @@ fn main() -> Result<(), Box<dyn Error>> {
"DrawCompositedContext",
"DeclareMaskContent",
"DrawIsolatedGroup",
- "PaintNestedDisplayList",
+ "PaintVectorImage",
];
let belongs_to_list = |macro_name: &str, name: &str| {
let is_canvas_2d_command = name.starts_with("Canvas2D");
diff --git a/Libraries/LibCompositing/Rust/src/display_list/commands.rs b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
index b505cd57c16..3c8293b71c8 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/commands.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/commands.rs
@@ -40,7 +40,7 @@ pub enum DisplayListCommandType {
DrawLine,
BackdropFilterRegion,
DrawRect,
- PaintNestedDisplayList,
+ PaintVectorImage,
DrawIsolatedGroup,
DeclareMaskContent,
CompositorWheelHitTestTarget,
@@ -142,7 +142,7 @@ impl DisplayListCommandType {
Self::DrawLine => "DrawLine",
Self::BackdropFilterRegion => "BackdropFilterRegion",
Self::DrawRect => "DrawRect",
- Self::PaintNestedDisplayList => "PaintNestedDisplayList",
+ Self::PaintVectorImage => "PaintVectorImage",
Self::DrawIsolatedGroup => "DrawIsolatedGroup",
Self::DeclareMaskContent => "DeclareMaskContent",
Self::CompositorWheelHitTestTarget => "CompositorWheelHitTestTarget",
@@ -1400,22 +1400,31 @@ impl DisplayListCommand for PaintConicGradient {
}
}
+// Paints the records an SVG image's document was recorded as, scaled from the size they were recorded at into `rect`.
+// The records name no visual context of their own and sit in this command's payload. The process that records a tape
+// leaves them out and names them by `vector_image_id` until it sends the tape, so that a tape it keeps does not hold a
+// copy of the image for each place that draws it.
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(C)]
-pub struct PaintNestedDisplayList {
- pub display_list_id: DisplayListResourceId,
+pub struct PaintVectorImage {
+ pub vector_image_id: DisplayListResourceId,
pub rect: FloatRect,
- // The size the nested list was recorded at; replay scales it into the destination rect.
- pub list_size: IntSize,
-}
-ffi_bytes_fields!(PaintNestedDisplayList {
- display_list_id,
+ pub recorded_size: IntSize,
+ pub records: DisplayListDataSpan,
+ // Whether a raster of the records can differ from replaying them in place: they read what was painted before them,
+ // or draw content that changes under them.
+ pub requires_direct_replay: bool,
+}
+ffi_bytes_fields!(PaintVectorImage {
+ vector_image_id,
rect,
- list_size
+ recorded_size,
+ records,
+ requires_direct_replay
});
-impl DisplayListCommand for PaintNestedDisplayList {
- const COMMAND_TYPE: DisplayListCommandType = DisplayListCommandType::PaintNestedDisplayList;
+impl DisplayListCommand for PaintVectorImage {
+ const COMMAND_TYPE: DisplayListCommandType = DisplayListCommandType::PaintVectorImage;
fn bounding_rect(&self) -> Option<IntRect> {
Some(enclosing_int_rect(self.rect))
}
diff --git a/Libraries/LibCompositing/Rust/src/display_list/damage.rs b/Libraries/LibCompositing/Rust/src/display_list/damage.rs
index 4c3234ce63e..7ebc8a2d245 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/damage.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/damage.rs
@@ -106,10 +106,9 @@ fn static_mask_contents(tape: Tape<'_>, effect_count: usize) -> Vec<Option<Stati
let content = super::nested_records::span_bytes(payload, declaration.content);
let nested = collect_nested_command_references(content, run.context, run.offset + offset as u32);
// Mask groups use their declaration's visual context. Only compare drawing commands whose
- // complete appearance is encoded in the payload, without canvas or video. The id of a nested
- // display list, such as that of an SVG mask image, names one recording whose commands never
- // change. The video and animated image frames drawn only inside it can, and for those
- // ContextPresenter damages the whole viewport.
+ // complete appearance is encoded in the payload, without canvas or video. The records of an SVG
+ // image, such as a mask image, are in its payload. The video and animated image frames drawn only
+ // inside them can change, and for those ContextPresenter damages the whole viewport.
if nested.iter().all(|nested| match nested.header.command_type {
DisplayListCommandType::FillRect => read_command::<FillRect>(nested.payload)
.background_color_animation_effect
@@ -127,7 +126,7 @@ fn static_mask_contents(tape: Tape<'_>, effect_count: usize) -> Vec<Option<Stati
DisplayListCommandType::PaintLinearGradient
| DisplayListCommandType::PaintRadialGradient
| DisplayListCommandType::PaintConicGradient
- | DisplayListCommandType::PaintNestedDisplayList
+ | DisplayListCommandType::PaintVectorImage
| DisplayListCommandType::DrawEllipse
| DisplayListCommandType::DrawLine
| DisplayListCommandType::DrawRect => true,
@@ -1811,7 +1810,7 @@ mod tests {
use crate::display_list::commands::{
BackdropFilterRegion, CanvasId, CompositorMainThreadWheelEventRegion, DisplayListCommand, DisplayListGlyph,
DisplayListResourceId, DrawCanvas, DrawCompositedContext, DrawIsolatedGroup, DrawVideoFrame, FillRect,
- FontResourceId, InlineClipKind, PaintNestedDisplayList, TextShadowLayer,
+ FontResourceId, InlineClipKind, PaintVectorImage, TextShadowLayer,
};
use crate::display_list::ffi_bytes::FfiBytes;
use crate::node_slot_id::NodeSlotId;
@@ -3558,7 +3557,7 @@ mod tests {
enum MaskContent {
Fill,
Canvas,
- NestedDisplayList(u64),
+ VectorImage(u64),
}
let make_scene = |color, insert_effect, mask_content| {
let mut tree = identity_tree();
@@ -3583,11 +3582,13 @@ mod tests {
Some(rect),
context,
),
- MaskContent::NestedDisplayList(id) => command_bytes(
- &PaintNestedDisplayList {
- display_list_id: DisplayListResourceId(id),
+ MaskContent::VectorImage(id) => command_bytes(
+ &PaintVectorImage {
+ vector_image_id: DisplayListResourceId(id),
rect: rect.to_float(),
- list_size: IntSize { width: 20, height: 20 },
+ recorded_size: IntSize { width: 20, height: 20 },
+ records: DisplayListDataSpan::default(),
+ requires_direct_replay: false,
},
Some(rect),
context,
@@ -3634,14 +3635,14 @@ mod tests {
damage(&bytes, &tree, &bytes, &tree),
Some(rect.inflated_edges(1, 1, 1, 1))
);
- // A nested display list is the same content for as long as its id is.
- let (old_bytes, old_tree) = make_scene(RED, false, MaskContent::NestedDisplayList(1));
- let (new_bytes, new_tree) = make_scene(RED, false, MaskContent::NestedDisplayList(1));
+ // The records of an SVG image are the same for as long as its id is.
+ let (old_bytes, old_tree) = make_scene(RED, false, MaskContent::VectorImage(1));
+ let (new_bytes, new_tree) = make_scene(RED, false, MaskContent::VectorImage(1));
assert_eq!(
damage(&old_bytes, &old_tree, &new_bytes, &new_tree),
Some(IntRect::default())
);
- let (new_bytes, new_tree) = make_scene(RED, false, MaskContent::NestedDisplayList(2));
+ let (new_bytes, new_tree) = make_scene(RED, false, MaskContent::VectorImage(2));
assert_eq!(
damage(&old_bytes, &old_tree, &new_bytes, &new_tree),
Some(rect.inflated_edges(1, 1, 1, 1))
diff --git a/Libraries/LibCompositing/Rust/src/display_list/nested_records.rs b/Libraries/LibCompositing/Rust/src/display_list/nested_records.rs
index edd569097f1..c5b5af012f0 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/nested_records.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/nested_records.rs
@@ -14,6 +14,7 @@ pub enum NestedRecordsRole {
RepeatedTile,
MaskContent,
PatternTile,
+ VectorImage,
}
pub fn for_each_nested_record_span(
@@ -47,6 +48,12 @@ pub fn for_each_nested_record_span(
read_command::<DeclareMaskContent>(payload).content,
);
}
+ DisplayListCommandType::PaintVectorImage => {
+ visit(
+ NestedRecordsRole::VectorImage,
+ read_command::<PaintVectorImage>(payload).records,
+ );
+ }
DisplayListCommandType::FillPath => {
let command = read_command::<FillPath>(payload);
visit_pattern_tile(command.paint_kind, command.paint_style);
diff --git a/Libraries/LibCompositing/Rust/src/display_list/replay.rs b/Libraries/LibCompositing/Rust/src/display_list/replay.rs
index 5203292e6a6..51dce2f33b8 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/replay.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/replay.rs
@@ -11,17 +11,15 @@ use crate::display_list::commands::{
ClipMode, ClipNodeIndex, DeclareMaskContent, DisplayListCommandHeader, DisplayListCommandRun,
DisplayListCommandType, DisplayListPaintStyleType, DrawCompositedContext, DrawIsolatedGroup, DrawRepeatedTile,
EffectNodeIndex, FillPath, FillRect, FillRectWithRoundedCorners, InlineClipKind, OptionalFloatRect, PaintCaret,
- PaintNestedDisplayList, PaintScrollBar, PathPaintKind, ReplayClip, ReplayLayer, ReplayMask, SpatialNodeIndex,
- StrokePath,
+ PaintScrollBar, PaintVectorImage, PathPaintKind, ReplayClip, ReplayLayer, ReplayMask, SpatialNodeIndex, StrokePath,
};
use crate::display_list::depth_sorted_plan::{DepthSortedReplayStepKind, build_depth_sorted_replay_plan};
use crate::display_list::effect_clip_plan::EffectClipPlan;
use crate::display_list::effect_geometry::{EffectGeometry, Extent, compute_effect_geometry};
use crate::display_list::nested_records::span_bytes;
-use crate::display_list::storage::DisplayListStorage;
use crate::host::{
- CompositedContextDraw, IsolatedGroup, NestedDisplayListPlacement, NestedDisplayListReplay, PresentedScrollbar,
- RecordSpan, ResolvedFillRect, ResolvedFillRectWithRoundedCorners, TileRaster,
+ CompositedContextDraw, IsolatedGroup, PresentedScrollbar, RecordSpan, ResolvedFillRect,
+ ResolvedFillRectWithRoundedCorners, TileRaster, VectorImagePlacement, VectorImageReplay,
};
use crate::visual_context::queries::TreeCullingScratch;
use crate::visual_context::{
@@ -70,13 +68,13 @@ pub trait ReplayPainter {
// Answers whether the tile records are to be replayed into the raster, which `end_tile_raster` then finishes.
fn begin_tile_raster(&mut self, tile: &TileRaster) -> bool;
fn end_tile_raster(&mut self);
- // Unless the painter skips the list, the replay of the list is followed by `end_nested_display_list`.
- fn begin_nested_display_list(
+ // Unless the painter skips the image, the replay of its records is followed by `end_vector_image`.
+ fn begin_vector_image(
&mut self,
- placement: &NestedDisplayListPlacement,
+ placement: &VectorImagePlacement,
requires_direct_replay: bool,
- ) -> NestedDisplayListReplay;
- fn end_nested_display_list(&mut self);
+ ) -> VectorImageReplay;
+ fn end_vector_image(&mut self);
fn execute_run<'t>(&mut self, _run_index: usize, records: &'t [u8], context: &RecordsContext<'_, 't>) {
replay_records(records, context, self);
@@ -95,21 +93,6 @@ pub struct ScrollbarShownByFrame {
pub opacity: f32,
}
-/// A display list nested in another: its tape, the tree it was recorded against, the color of its root group, and
-/// whether a raster of it can differ from replaying it.
-#[derive(Clone, Copy)]
-pub struct NestedDisplayList<'a> {
- pub storage: &'a DisplayListStorage,
- pub tree: &'a VisualContextTree,
- pub root_group_color: Color,
- pub requires_direct_replay: bool,
-}
-
-/// Where a replay finds the display lists that the lists it plays nest, by their resource ids.
-pub trait NestedDisplayLists {
- fn nested_display_list(&self, display_list_id: u64) -> Option<NestedDisplayList<'_>>;
-}
-
/// The surface that shows the frame of a context drawn into another, and the part of it the frame is in.
#[derive(Clone, Copy, Debug)]
pub struct ResolvedCompositedContext {
@@ -143,35 +126,23 @@ impl CompositedContexts for NoCompositedContexts {
}
}
-/// The resources of a replay that nests no display list.
-pub struct NoNestedDisplayLists;
-
-impl NestedDisplayLists for NoNestedDisplayLists {
- fn nested_display_list(&self, _display_list_id: u64) -> Option<NestedDisplayList<'_>> {
- None
- }
-}
-
/// What a replay paints a display list with besides the list: where the frame presents the scroll containers and the
-/// scrollbars, the time it shows a blinking caret at, the display lists the list nests, and the frames of the contexts
-/// it draws.
+/// scrollbars, the time it shows a blinking caret at, and the frames of the contexts it draws.
#[derive(Clone, Copy)]
pub struct ReplayFrame<'a> {
pub scroll_offsets: &'a [FloatPoint],
pub scrollbars: &'a [ScrollbarShownByFrame],
pub time_ns: i64,
- pub nested_display_lists: &'a dyn NestedDisplayLists,
pub composited_contexts: &'a dyn CompositedContexts,
}
-impl<'a> ReplayFrame<'a> {
+impl ReplayFrame<'_> {
/// A frame that scrolls nothing, presents no scrollbar of its own, and draws no other context.
- pub fn unscrolled(time_ns: i64, nested_display_lists: &'a dyn NestedDisplayLists) -> Self {
+ pub fn unscrolled(time_ns: i64) -> Self {
Self {
scroll_offsets: &[],
scrollbars: &[],
time_ns,
- nested_display_lists,
composited_contexts: &NoCompositedContexts,
}
}
@@ -184,8 +155,8 @@ impl<'a> ReplayFrame<'a> {
}
}
- // A nested display list scrolls nothing, and the scrollbars of the frame do not belong to its scroll nodes.
- fn for_nested_display_list(&self) -> Self {
+ // The records of an SVG image scroll nothing, and the scrollbars of the frame do not belong to its scroll nodes.
+ fn for_vector_image_records(&self) -> Self {
Self {
scroll_offsets: &[],
scrollbars: &[],
@@ -546,37 +517,27 @@ fn play_record<'t, Painter: ReplayPainter + ?Sized>(
rasterize_pattern_tile_of(command.paint_kind, &command.paint_style, payload, context, painter);
painter.play_command(header.command_type, payload, payload);
}
- DisplayListCommandType::PaintNestedDisplayList => {
- let command = read_command::<PaintNestedDisplayList>(payload);
- let Some(nested) = context
- .frame
- .nested_display_lists
- .nested_display_list(command.display_list_id.0)
- else {
- return;
- };
- let placement = NestedDisplayListPlacement {
- display_list_id: command.display_list_id.0,
+ DisplayListCommandType::PaintVectorImage => {
+ let command = read_command::<PaintVectorImage>(payload);
+ let placement = VectorImagePlacement {
+ vector_image_id: command.vector_image_id.0,
rect: command.rect,
- list_size: command.list_size,
+ recorded_size: command.recorded_size,
};
- if painter.begin_nested_display_list(&placement, nested.requires_direct_replay)
- == NestedDisplayListReplay::Skipped
- {
+ if painter.begin_vector_image(&placement, command.requires_direct_replay) == VectorImageReplay::Skipped {
return;
}
- let nested_frame = context.frame.for_nested_display_list();
- replay_display_list(
- nested.tree,
- nested.storage.bytes(),
- nested.storage.command_runs(),
- nested.storage.effect_clip_plan(nested.tree),
- nested.root_group_color,
- &nested_frame,
- ReplaySelection::default(),
+ let vector_image_frame = context.frame.for_vector_image_records();
+ replay_records(
+ span_bytes(payload, command.records),
+ &RecordsContext {
+ list: context.list,
+ frame: &vector_image_frame,
+ clip_space_matrix: &|_| None,
+ },
painter,
);
- painter.end_nested_display_list();
+ painter.end_vector_image();
}
_ => painter.play_command(header.command_type, payload, payload),
}
@@ -1552,14 +1513,14 @@ mod tests {
false
}
fn end_tile_raster(&mut self) {}
- fn begin_nested_display_list(
+ fn begin_vector_image(
&mut self,
- _placement: &NestedDisplayListPlacement,
+ _placement: &VectorImagePlacement,
_requires_direct_replay: bool,
- ) -> NestedDisplayListReplay {
- NestedDisplayListReplay::Skipped
+ ) -> VectorImageReplay {
+ VectorImageReplay::Skipped
}
- fn end_nested_display_list(&mut self) {}
+ fn end_vector_image(&mut self) {}
fn execute_run<'t>(&mut self, run_index: usize, records: &'t [u8], _context: &RecordsContext<'_, 't>) {
self.events.push(PainterEvent::Run(run_index));
@@ -1660,7 +1621,7 @@ mod tests {
) {
let tree = identity_tree();
let list = ListReplay::new(&tree);
- let frame = ReplayFrame::unscrolled(0, &NoNestedDisplayLists);
+ let frame = ReplayFrame::unscrolled(0);
replay_records(
records,
&RecordsContext {
@@ -1679,7 +1640,7 @@ mod tests {
runs,
&EffectClipPlan::new(tree, runs).unwrap(),
Color::TRANSPARENT,
- &ReplayFrame::unscrolled(0, &NoNestedDisplayLists),
+ &ReplayFrame::unscrolled(0),
ReplaySelection::default(),
painter,
);
@@ -1703,7 +1664,7 @@ mod tests {
runs,
&EffectClipPlan::new(tree, runs).unwrap(),
Color::TRANSPARENT,
- &ReplayFrame::unscrolled(0, &NoNestedDisplayLists),
+ &ReplayFrame::unscrolled(0),
selection,
&mut painter,
);
@@ -2586,7 +2547,7 @@ mod tests {
&runs,
&EffectClipPlan::new(&tree, &runs).unwrap(),
white,
- &ReplayFrame::unscrolled(0, &NoNestedDisplayLists),
+ &ReplayFrame::unscrolled(0),
ReplaySelection::default(),
&mut painter,
);
@@ -2715,7 +2676,7 @@ mod tests {
Color::TRANSPARENT,
&ReplayFrame {
scroll_offsets: &scroll_offsets,
- ..ReplayFrame::unscrolled(0, &NoNestedDisplayLists)
+ ..ReplayFrame::unscrolled(0)
},
ReplaySelection::default(),
&mut painter,
diff --git a/Libraries/LibCompositing/Rust/src/display_list/summary.rs b/Libraries/LibCompositing/Rust/src/display_list/summary.rs
index b1437ce6124..e5b4e5ae6ed 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/summary.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/summary.rs
@@ -10,7 +10,6 @@
use super::builder::{HEADER_SIZE, for_each_command, read_command};
use super::commands::*;
use super::nested_records::{for_each_nested_record_span, span_bytes};
-use crate::visual_context::VisualContextTree;
use libgfx_rust::CompositingAndBlendingOperator;
use libgfx_rust::filter::Filter;
use std::collections::HashSet;
@@ -43,7 +42,7 @@ pub struct DisplayListSummary {
pub font_ids: Vec<u64>,
pub image_frame_ids: Vec<u64>,
pub video_sink_handles: Vec<u64>,
- pub display_list_ids: Vec<u64>,
+ pub vector_image_ids: Vec<u64>,
pub canvas_ids: Vec<u64>,
pub composited_context_ids: Vec<u64>,
pub carets: Vec<IndexedRecord>,
@@ -57,7 +56,7 @@ struct ReferencedIds {
fonts: HashSet<u64>,
image_frames: HashSet<u64>,
video_sinks: HashSet<u64>,
- display_lists: HashSet<u64>,
+ vector_images: HashSet<u64>,
canvases: HashSet<u64>,
composited_contexts: HashSet<u64>,
}
@@ -113,9 +112,9 @@ fn note_referenced_ids(command_type: DisplayListCommandType, payload: &[u8], ids
T::DrawCanvas => {
ids.canvases.insert(read_command::<DrawCanvas>(payload).canvas_id.0);
}
- T::PaintNestedDisplayList => {
- ids.display_lists
- .insert(read_command::<PaintNestedDisplayList>(payload).display_list_id.0);
+ T::PaintVectorImage => {
+ ids.vector_images
+ .insert(read_command::<PaintVectorImage>(payload).vector_image_id.0);
}
T::DrawCompositedContext => {
ids.composited_contexts
@@ -233,7 +232,7 @@ pub fn summarize(tape: &[u8], command_runs: &[DisplayListCommandRun]) -> Display
summary.font_ids = sorted(ids.fonts);
summary.image_frame_ids = sorted(ids.image_frames);
summary.video_sink_handles = sorted(ids.video_sinks);
- summary.display_list_ids = sorted(ids.display_lists);
+ summary.vector_image_ids = sorted(ids.vector_images);
summary.canvas_ids = sorted(ids.canvases);
summary.composited_context_ids = sorted(ids.composited_contexts);
summary
@@ -306,7 +305,7 @@ fn command_blend(
| T::DrawLine
| T::BackdropFilterRegion
| T::DrawRect
- | T::PaintNestedDisplayList
+ | T::PaintVectorImage
| T::DeclareMaskContent
| T::CompositorWheelHitTestTarget
| T::CompositorWheelHitTestTargetWithCornerRadii
@@ -342,49 +341,35 @@ fn draws_live_content(command_type: DisplayListCommandType) -> bool {
)
}
-/// Whether reusing a raster of the list can produce different pixels than replaying it in place, leaving out the
-/// display lists it nests. That is the case when a destination-reading operation can see content painted before the
-/// list began: a non-normal blend on a command or a visual context effect, or a backdrop filter of an effect. A blend
-/// inside a group recorded in the list reads only content of the list. It is also the case when the list draws live
-/// content that changes under its immutable commands: video frames, canvases and composited child contexts.
-pub fn requires_direct_replay_without_nested_lists(
- tape: &[u8],
- command_runs: &[DisplayListCommandRun],
- tree: &VisualContextTree,
-) -> bool {
- if tree.has_unisolated_destination_reading_effect() {
- return true;
- }
+/// Whether reusing a raster of an SVG image's records can produce different pixels than replaying them in place. That
+/// is the case when a destination-reading operation can see content painted before the records began: a non-normal
+/// blend on a command, or on a group of them. A blend inside a group reads only content of the group. It is also the
+/// case when the records draw live content that changes under them: video frames, canvases and composited child
+/// contexts.
+pub fn vector_image_records_require_direct_replay(records: &[u8]) -> bool {
let mut requires_direct_replay = false;
- for run in command_runs {
- let records = &tape[run.offset as usize..(run.offset + run.size) as usize];
- for_each_command(records, |header, _, payload| {
- if requires_direct_replay {
- return;
- }
- if draws_live_content(header.command_type) {
- requires_direct_replay = true;
- return;
- }
- if let Some((blend, blends_with_isolated_backdrop_color)) = command_blend(header.command_type, payload)
- && blend != CompositingAndBlendingOperator::Normal
- && !blends_with_isolated_backdrop_color
- && !tree.effect_is_isolated_by_layer(run.context.effect)
- {
- requires_direct_replay = true;
- return;
- }
- for_each_nested_record_span(header.command_type, payload, |_, span| {
- for_each_record_including_nested(span_bytes(payload, span), &mut |command_type, _| {
- requires_direct_replay |= draws_live_content(command_type);
- });
- });
- });
+ for_each_command(records, |header, _, payload| {
if requires_direct_replay {
- return true;
+ return;
}
- }
- false
+ if draws_live_content(header.command_type) {
+ requires_direct_replay = true;
+ return;
+ }
+ if let Some((blend, blends_with_isolated_backdrop_color)) = command_blend(header.command_type, payload)
+ && blend != CompositingAndBlendingOperator::Normal
+ && !blends_with_isolated_backdrop_color
+ {
+ requires_direct_replay = true;
+ return;
+ }
+ for_each_nested_record_span(header.command_type, payload, |_, span| {
+ for_each_record_including_nested(span_bytes(payload, span), &mut |command_type, _| {
+ requires_direct_replay |= draws_live_content(command_type);
+ });
+ });
+ });
+ requires_direct_replay
}
/// Visits the compositor metadata commands of the runs that hold any, in tape order.
diff --git a/Libraries/LibCompositing/Rust/src/display_list/validate.rs b/Libraries/LibCompositing/Rust/src/display_list/validate.rs
index 8f2290351eb..6c4b0e8aa0d 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/validate.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/validate.rs
@@ -345,7 +345,7 @@ fn command_struct_size(command_type: DisplayListCommandType) -> usize {
T::DrawLine => size_of::<DrawLine>(),
T::BackdropFilterRegion => size_of::<BackdropFilterRegion>(),
T::DrawRect => size_of::<DrawRect>(),
- T::PaintNestedDisplayList => size_of::<PaintNestedDisplayList>(),
+ T::PaintVectorImage => size_of::<PaintVectorImage>(),
T::DrawIsolatedGroup => size_of::<DrawIsolatedGroup>(),
T::DeclareMaskContent => size_of::<DeclareMaskContent>(),
T::CompositorWheelHitTestTarget => size_of::<CompositorWheelHitTestTarget>(),
@@ -529,6 +529,10 @@ fn validate_command_fields(
p.enum_at::<MaskKind>(offset_of!(DrawIsolatedGroup, mask_kind))?;
}
T::DeclareMaskContent => nested.add(offset_of!(DeclareMaskContent, content))?,
+ T::PaintVectorImage => {
+ nested.add(offset_of!(PaintVectorImage, records))?;
+ p.bool_at(offset_of!(PaintVectorImage, requires_direct_replay))?;
+ }
T::CompositorScrollbar => {
p.bool_at(offset_of!(CompositorScrollbar, vertical))?;
p.bool_at(offset_of!(CompositorScrollbar, is_painted_by_compositor))?;
@@ -575,7 +579,6 @@ fn validate_command_fields(
| T::FillRoundedRectRing
| T::DrawEllipse
| T::BackdropFilterRegion
- | T::PaintNestedDisplayList
| T::CompositorWheelHitTestTarget
| T::CompositorWheelHitTestTargetWithCornerRadii
| T::CompositorMainThreadWheelEventRegion
diff --git a/Libraries/LibCompositing/Rust/src/host/replay.rs b/Libraries/LibCompositing/Rust/src/host/replay.rs
index a9d5b25b717..e0ff0adb848 100644
--- a/Libraries/LibCompositing/Rust/src/host/replay.rs
+++ b/Libraries/LibCompositing/Rust/src/host/replay.rs
@@ -121,24 +121,25 @@ pub struct TileRaster {
pub cacheable: bool,
}
-/// Where a display list nested in another is painted, and the size it was recorded at.
+/// Where the records of an SVG image are painted, and the size they were recorded at. The records stay the same for as
+/// long as the id does.
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(C)]
-pub struct NestedDisplayListPlacement {
- pub display_list_id: u64,
+pub struct VectorImagePlacement {
+ pub vector_image_id: u64,
pub rect: FloatRect,
- pub list_size: IntSize,
+ pub recorded_size: IntSize,
}
-/// How the painter takes a nested display list.
+/// How the painter takes the records of an SVG image.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
-pub enum NestedDisplayListReplay {
- /// The painter drew the list from a raster it keeps, or it draws nothing of it.
+pub enum VectorImageReplay {
+ /// The painter drew the image from a raster it keeps, or it draws nothing of it.
Skipped,
- /// The list is replayed into a raster the painter keeps, which it draws once the replay ends.
+ /// The records are replayed into a raster the painter keeps, which it draws once the replay ends.
IntoRaster,
- /// The list is replayed in place.
+ /// The records are replayed in place.
Directly,
}
@@ -178,11 +179,10 @@ pub struct FfiRasterPainter {
/// The command that draws the tiles comes next.
pub begin_tile_raster: unsafe extern "C" fn(*mut c_void, *const TileRaster) -> bool,
pub end_tile_raster: unsafe extern "C" fn(*mut c_void),
- /// Arguments: the placement, and whether a raster of the list can differ from replaying it. Unless the list is
- /// skipped, its replay is followed by `end_nested_display_list`.
- pub begin_nested_display_list:
- unsafe extern "C" fn(*mut c_void, *const NestedDisplayListPlacement, bool) -> NestedDisplayListReplay,
- pub end_nested_display_list: unsafe extern "C" fn(*mut c_void),
+ /// Arguments: the placement, and whether a raster of the image's records can differ from replaying them. Unless
+ /// the image is skipped, the replay of its records is followed by `end_vector_image`.
+ pub begin_vector_image: unsafe extern "C" fn(*mut c_void, *const VectorImagePlacement, bool) -> VectorImageReplay,
+ pub end_vector_image: unsafe extern "C" fn(*mut c_void),
}
impl ReplayPainter for FfiRasterPainter {
@@ -317,17 +317,17 @@ impl ReplayPainter for FfiRasterPainter {
unsafe { (self.end_tile_raster)(self.context) };
}
- fn begin_nested_display_list(
+ fn begin_vector_image(
&mut self,
- placement: &NestedDisplayListPlacement,
+ placement: &VectorImagePlacement,
requires_direct_replay: bool,
- ) -> NestedDisplayListReplay {
+ ) -> VectorImageReplay {
// SAFETY: The C++ painter answers synchronously.
- unsafe { (self.begin_nested_display_list)(self.context, placement, requires_direct_replay) }
+ unsafe { (self.begin_vector_image)(self.context, placement, requires_direct_replay) }
}
- fn end_nested_display_list(&mut self) {
- // SAFETY: The C++ painter finishes the list synchronously.
- unsafe { (self.end_nested_display_list)(self.context) };
+ fn end_vector_image(&mut self) {
+ // SAFETY: The C++ painter finishes the image synchronously.
+ unsafe { (self.end_vector_image)(self.context) };
}
}
diff --git a/Libraries/LibCompositing/Rust/src/ipc_types.rs b/Libraries/LibCompositing/Rust/src/ipc_types.rs
index a84cdfd8d04..9502fddd3c6 100644
--- a/Libraries/LibCompositing/Rust/src/ipc_types.rs
+++ b/Libraries/LibCompositing/Rust/src/ipc_types.rs
@@ -12,7 +12,6 @@
use crate::css_pixels::{CssPixelPoint, CssPixels};
use crate::display_list::commands::{CompositorContextId, UniqueNodeId};
-use crate::display_list::storage::{DisplayListStorage, packed_size, receive_packed};
use crate::visual_context::VisualContextTree;
use libipc_rust::wire::{Decode, DecodeError, Decoder, Encode, EncodeError, Encoder, File};
use std::sync::Arc;
@@ -189,50 +188,21 @@ impl Decode for SharedDisplayList {
}
}
-/// A display list that another one nests, with the tree it was recorded against.
-#[derive(Clone)]
-pub struct NestedDisplayListResource {
- pub properties: Compositing_DisplayListProperties,
- pub storage: Arc<DisplayListStorage>,
- pub tree: Arc<VisualContextTree>,
-}
-
-impl NestedDisplayListResource {
- /// Encodes the list as a resource transaction carries it: what travels alongside its tape, the tape and run table,
- /// and its tree.
- pub fn encode_into(&self, encoder: &mut Encoder) -> Result<(), EncodeError> {
- encoder.encode(&self.properties)?;
- encoder.encode_size(self.storage.bytes().len())?;
- encoder.encode_size(self.storage.command_runs().len())?;
- encoder.append_bytes(&self.storage.packed());
- encoder.encode(&self.tree)
- }
-}
-
-impl std::fmt::Debug for NestedDisplayListResource {
- fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- formatter
- .debug_struct("NestedDisplayListResource")
- .field("properties", &self.properties)
- .finish_non_exhaustive()
- }
-}
-
/// `Compositing::DisplayListResourceTransaction` as it reaches the compositor's logic, which holds no fonts and no
/// image frames: those go ahead of it, in messages that the C++ of the compositor takes.
#[derive(Clone, Debug, Default)]
pub struct Compositing_DisplayListResourceTransaction {
- pub display_lists: Vec<NestedDisplayListResource>,
pub font_ids_to_remove: Vec<u64>,
pub image_frame_ids_to_remove: Vec<u64>,
- pub display_list_ids_to_remove: Vec<u64>,
+ /// The SVG images that no display list of the context draws any longer, whose rasters the compositor drops.
+ pub vector_image_ids_to_remove: Vec<u64>,
}
impl Compositing_DisplayListResourceTransaction {
pub fn removes_anything(&self) -> bool {
!self.font_ids_to_remove.is_empty()
|| !self.image_frame_ids_to_remove.is_empty()
- || !self.display_list_ids_to_remove.is_empty()
+ || !self.vector_image_ids_to_remove.is_empty()
}
}
@@ -241,13 +211,9 @@ impl Encode for Compositing_DisplayListResourceTransaction {
// No fonts, and no image frames.
encoder.encode_size(0)?;
encoder.encode_size(0)?;
- encoder.encode_size(self.display_lists.len())?;
- for display_list in &self.display_lists {
- display_list.encode_into(encoder)?;
- }
encoder.encode(&self.font_ids_to_remove)?;
encoder.encode(&self.image_frame_ids_to_remove)?;
- encoder.encode(&self.display_list_ids_to_remove)
+ encoder.encode(&self.vector_image_ids_to_remove)
}
}
@@ -260,38 +226,10 @@ impl Decode for Compositing_DisplayListResourceTransaction {
"a display list's fonts and image frames go ahead of it",
));
}
- let display_list_count = decoder.decode_size()?;
- let mut display_lists = Vec::new();
- for _ in 0..display_list_count {
- let properties: Compositing_DisplayListProperties = decoder.decode()?;
- let tape_size = decoder.decode_size()?;
- let run_count = decoder.decode_size()?;
- let packed_size =
- packed_size(tape_size, run_count).ok_or(DecodeError::InvalidValue("Display list sizes overflow"))?;
- let packed = decoder.read_bytes(packed_size)?;
- let storage = receive_packed(packed, tape_size, run_count).map_err(DecodeError::InvalidValue)?;
- let tree: Arc<VisualContextTree> = decoder.decode()?;
- if properties.compatible_visual_context_tree_structural_epoch != tree.structural_epoch {
- return Err(DecodeError::InvalidValue(
- "Display list resource does not match its visual context tree",
- ));
- }
- if !tree.display_list_references_only_live_nodes(storage.command_runs()) {
- return Err(DecodeError::InvalidValue(
- "Display list resource references nodes its visual context tree does not hold",
- ));
- }
- display_lists.push(NestedDisplayListResource {
- properties,
- storage,
- tree,
- });
- }
Ok(Self {
- display_lists,
font_ids_to_remove: decoder.decode()?,
image_frame_ids_to_remove: decoder.decode()?,
- display_list_ids_to_remove: decoder.decode()?,
+ vector_image_ids_to_remove: decoder.decode()?,
})
}
}
diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h
index ae5037b2ce3..a6d846cc871 100644
--- a/Libraries/LibWeb/DOM/Document.h
+++ b/Libraries/LibWeb/DOM/Document.h
@@ -770,7 +770,7 @@ public:
void set_svg_image_color_scheme(CSS::PreferredColorScheme color_scheme) { m_svg_image_color_scheme = color_scheme; }
// Whether this document of an SVG image holds content that is not SVG, which only paints in full through the
- // document's visual contexts. Such an image is drawn from a raster of the document.
+ // document's visual contexts. Such an image is drawn from a raster of the document instead of from its records.
bool decoded_svg_holds_foreign_content() const { return m_decoded_svg_holds_foreign_content; }
void set_decoded_svg_holds_foreign_content(bool holds_foreign_content) { m_decoded_svg_holds_foreign_content = holds_foreign_content; }
diff --git a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
index c89227969da..50a6f30d31b 100644
--- a/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
+++ b/Libraries/LibWeb/Painting/PaintingRustBridge.cpp
@@ -563,6 +563,7 @@ Optional<DisplayListRecording> start_rust_display_list_recording(Layout::BegunRe
if (auto schemes = document.supported_color_schemes(); schemes.has_value())
inputs.document_supports_light_or_dark = schemes->contains_slow("light"_utf16) || schemes->contains_slow("dark"_utf16);
inputs.image_fallback_color_scheme = to_underlying(document.svg_image_color_scheme().value_or(document.page().preferred_color_scheme()));
+ inputs.records_without_visual_contexts = document.is_decoded_svg() && !document.decoded_svg_holds_foreign_content();
// The AT focus ring paints as an outline on one paintable, whether or not that element has a CSS outline of
// its own. So the recorder learns which paintable that is here, up front — its paint-phase mask would
// otherwise skip that paintable's outline phase as empty.
diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs b/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs
index 0670bec4e0f..6a1d53fe0bb 100644
--- a/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs
+++ b/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs
@@ -19,6 +19,7 @@ use crate::painting::dump::{
push_float_size, push_int_point, push_int_rect, push_int_size,
};
use crate::painting::paint_read::PaintRead;
+use crate::painting::vector_image_records::display_list_holding_vector_image_records;
use crate::painting::visual_context::VisualContextTree;
use crate::painting::visual_context::VisualContextTreeDump;
use crate::painting::visual_context::dump::SlotKind;
@@ -64,18 +65,6 @@ impl FfiPaintingDumpCallbacks {
}
}
-/// The display lists the dumped one nests, at any depth.
-struct DumpCallbacks<'a> {
- nested_display_lists: &'a HashMap<u64, std::sync::Arc<crate::painting::display_list_resources::NestedDisplayList>>,
-}
-
-impl DumpCallbacks<'_> {
- fn nested_display_list(&self, display_list_id: DisplayListResourceId) -> &DisplayListStorage {
- // Nested ids come from records the recording produced, so they resolve in what it draws.
- &self.nested_display_lists[&display_list_id.0].resource.storage
- }
-}
-
struct VisualContextNodeOwners {
spatial: HashMap<u32, NodeSlotId>,
clip: HashMap<u32, NodeSlotId>,
@@ -204,17 +193,17 @@ pub unsafe extern "C" fn painting_dump(
let recording =
crate::painting::ffi::read_arena(host, read, (), |arena, ()| arena.paint_state().last_recording.clone())
.expect("the dump records the document first");
+ // The dump shows the tape as the compositor replays it, with the records of the SVG images it draws.
let display_list = DisplayListStorage::recorded(
- recording.display_list.clone(),
+ std::sync::Arc::new(display_list_holding_vector_image_records(
+ &recording.display_list,
+ &recording.resources.vector_images,
+ )),
recording
.visual_context_tree
.clone()
.expect("a recording was recorded against a tree"),
);
- let nested_display_lists = recording.resources.with_nested_resources().nested_display_lists;
- let dump_callbacks = DumpCallbacks {
- nested_display_lists: &nested_display_lists,
- };
let (tape, command_runs) = (display_list.bytes(), display_list.command_runs());
let owners = {
crate::painting::ffi::read_arena(host, read, viewport, |arena, viewport| {
@@ -241,15 +230,9 @@ pub unsafe extern "C" fn painting_dump(
output.push_str("\nDisplayList:\n");
match layer_plan {
Some(layer_plan) => {
- dump_top_level_commands_with_their_layers(
- &main_thread,
- &mut output,
- &dump_callbacks,
- &display_list,
- &layer_plan,
- );
+ dump_top_level_commands_with_their_layers(&main_thread, &mut output, &display_list, &layer_plan);
}
- None => dump_commands(&main_thread, &mut output, &dump_callbacks, &display_list, 0),
+ None => dump_commands(&main_thread, &mut output, &display_list, 0),
}
callbacks.append_text(&main_thread, &output);
}
@@ -306,17 +289,11 @@ fn dump_compositor_scroll_table(output: &mut String, table: &CompositorScrollTab
}
}
-fn dump_commands(
- main_thread: &MainThread,
- output: &mut String,
- callbacks: &DumpCallbacks,
- display_list: &DisplayListStorage,
- base_indent: usize,
-) {
+fn dump_commands(main_thread: &MainThread, output: &mut String, display_list: &DisplayListStorage, base_indent: usize) {
let (bytes, command_runs) = (display_list.bytes(), display_list.command_runs());
for run in command_runs {
let run_bytes = &bytes[run.offset as usize..(run.offset + run.size) as usize];
- dump_command_bytes(main_thread, output, callbacks, run_bytes, run.context, base_indent);
+ dump_command_bytes(main_thread, output, run_bytes, run.context, base_indent);
}
}
@@ -369,7 +346,6 @@ fn dump_layers_if_every_canvas_and_video_kept_updating(
fn dump_top_level_commands_with_their_layers(
main_thread: &MainThread,
output: &mut String,
- callbacks: &DumpCallbacks,
display_list: &DisplayListStorage,
layer_plan: &LayerPlan,
) {
@@ -380,7 +356,7 @@ fn dump_top_level_commands_with_their_layers(
let layer_label = format!("L{} ", layer_plan.layer_of_record(run.offset + offset_in_run as u32));
let record_bytes = &run_bytes[offset_in_run..offset_in_run + HEADER_SIZE + payload.len()];
let record_dump_start = output.len();
- dump_command_bytes(main_thread, output, callbacks, record_bytes, run.context, 0);
+ dump_command_bytes(main_thread, output, record_bytes, run.context, 0);
let record_dump = output.split_off(record_dump_start);
for (line_index, line) in record_dump.split_inclusive('\n').enumerate() {
if line_index == 0 {
@@ -397,7 +373,6 @@ fn dump_top_level_commands_with_their_layers(
fn dump_command_bytes(
main_thread: &MainThread,
output: &mut String,
- callbacks: &DumpCallbacks,
command_bytes: &[u8],
context: ContextRef,
base_indent: usize,
@@ -419,42 +394,17 @@ fn dump_command_bytes(
dump_records_inside(
main_thread,
output,
- callbacks,
header.command_type,
payload,
context,
base_indent + 1,
);
- let Some(nested) = nested_display_lists(header.command_type, payload) else {
- return;
- };
- dump_commands(
- main_thread,
- output,
- callbacks,
- callbacks.nested_display_list(nested.display_list),
- base_indent + 1,
- );
});
}
-struct NestedDisplayLists {
- display_list: DisplayListResourceId,
-}
-
-fn nested_display_lists(command_type: DisplayListCommandType, payload: &[u8]) -> Option<NestedDisplayLists> {
- match command_type {
- DisplayListCommandType::PaintNestedDisplayList => Some(NestedDisplayLists {
- display_list: read_command::<PaintNestedDisplayList>(payload).display_list_id,
- }),
- _ => None,
- }
-}
-
fn dump_records_inside(
main_thread: &MainThread,
output: &mut String,
- callbacks: &DumpCallbacks,
command_type: DisplayListCommandType,
payload: &[u8],
context: ContextRef,
@@ -466,7 +416,8 @@ fn dump_records_inside(
NestedRecordsRole::PatternTile => Some("PatternTile:\n"),
NestedRecordsRole::IsolatedGroupContent
| NestedRecordsRole::RepeatedTile
- | NestedRecordsRole::MaskContent => None,
+ | NestedRecordsRole::MaskContent
+ | NestedRecordsRole::VectorImage => None,
};
let mut nested_indent = indent;
if let Some(label) = label {
@@ -474,14 +425,7 @@ fn dump_records_inside(
output.push_str(label);
nested_indent += 1;
}
- dump_command_bytes(
- main_thread,
- output,
- callbacks,
- span_bytes(payload, span),
- context,
- nested_indent,
- );
+ dump_command_bytes(main_thread, output, span_bytes(payload, span), context, nested_indent);
});
}
@@ -772,8 +716,8 @@ fn dump_command(output: &mut String, command_type: DisplayListCommandType, paylo
write_field(output, "color", command.color);
write!(output, " rough={}", command.rough).unwrap();
}
- DisplayListCommandType::PaintNestedDisplayList => {
- let command = read_command::<PaintNestedDisplayList>(payload);
+ DisplayListCommandType::PaintVectorImage => {
+ let command = read_command::<PaintVectorImage>(payload);
write_field(output, "rect", command.rect);
}
DisplayListCommandType::DrawIsolatedGroup => {
diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
index e7c52476620..aba40dccb1a 100644
--- a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
+++ b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs
@@ -1324,17 +1324,21 @@ impl DisplayListRecorder {
);
}
- pub fn paint_nested_display_list(
+ /// Paints the records of the SVG image `vector_image_id` names, which were recorded at `recorded_size`, into
+ /// `rect`. The tape takes the records in where it is sent.
+ pub fn paint_vector_image_records(
&mut self,
- display_list_id: DisplayListResourceId,
+ vector_image_id: DisplayListResourceId,
rect: FloatRect,
- list_size: IntSize,
+ recorded_size: IntSize,
) {
self.append_command(
- &PaintNestedDisplayList {
- display_list_id,
+ &PaintVectorImage {
+ vector_image_id,
rect,
- list_size,
+ recorded_size,
+ records: DisplayListDataSpan::default(),
+ requires_direct_replay: false,
},
&[],
);
diff --git a/Libraries/LibWeb/Rust/src/painting/display_list_resources.rs b/Libraries/LibWeb/Rust/src/painting/display_list_resources.rs
index a2fc0e14e66..e9ef161c843 100644
--- a/Libraries/LibWeb/Rust/src/painting/display_list_resources.rs
+++ b/Libraries/LibWeb/Rust/src/painting/display_list_resources.rs
@@ -4,18 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! What a display list draws besides its tape: fonts, image frames and the display lists it nests, which the list holds
-//! for as long as anything holds the list. The compositor is sent the ones it lacks ahead of the list.
+//! What a display list draws besides its tape: fonts, image frames and the SVG images its commands name, which the list
+//! holds for as long as anything holds the list. The compositor is sent the fonts and image frames it lacks ahead of
+//! the list, and the records of the SVG images in the list's tape.
use crate::painting::display_list::builder::RecordedDisplayList;
-use crate::painting::display_list::commands::ImageFrameResourceId;
-use crate::painting::display_list::ids::allocate_display_list_id;
-use crate::painting::display_list::recorder::DisplayListRecorder;
-use crate::painting::display_list::storage::DisplayListStorage;
use crate::painting::display_list::summary::{DisplayListSummary, summarize};
-use crate::painting::force_dark::ForceDarkRole;
-use crate::painting::visual_context::VisualContextTree;
-use libcompositing_rust::ipc_types::{Compositing_DisplayListProperties, NestedDisplayListResource};
+use crate::painting::vector_image_records::VectorImageRecords;
use libgfx_rust::font::FontHandle;
use libgfx_rust::image_frame::ImageFrameHandle;
use std::collections::{HashMap, HashSet};
@@ -26,52 +21,37 @@ use std::sync::Arc;
pub(crate) struct DisplayListResources {
pub(crate) fonts: HashMap<u64, FontHandle>,
pub(crate) image_frames: HashMap<u64, ImageFrameHandle>,
- pub(crate) nested_display_lists: HashMap<u64, Arc<NestedDisplayList>>,
+ pub(crate) vector_images: HashMap<u64, Arc<VectorImageRecords>>,
}
impl DisplayListResources {
/// Takes what `other` holds that this does not.
pub(crate) fn include(&mut self, other: &Self) {
+ self.include_fonts_and_image_frames(other);
+ for (id, vector_image) in &other.vector_images {
+ self.vector_images.entry(*id).or_insert_with(|| vector_image.clone());
+ }
+ }
+
+ pub(crate) fn include_fonts_and_image_frames(&mut self, other: &Self) {
for (id, font) in &other.fonts {
self.fonts.entry(*id).or_insert_with(|| font.clone());
}
for (id, frame) in &other.image_frames {
self.image_frames.entry(*id).or_insert_with(|| frame.clone());
}
- for (id, display_list) in &other.nested_display_lists {
- self.nested_display_lists
- .entry(*id)
- .or_insert_with(|| display_list.clone());
- }
}
- /// These and what the display lists they nest draw, at any depth: everything the compositor needs to replay a list
- /// that draws these.
- pub(crate) fn with_nested_resources(&self) -> Self {
+ /// These and what the records of their SVG images draw: everything the compositor needs to replay a list that
+ /// draws these.
+ pub(crate) fn with_vector_image_resources(&self) -> Self {
let mut closure = self.clone();
- let mut pending: Vec<Arc<NestedDisplayList>> = self.nested_display_lists.values().cloned().collect();
- let mut visited: HashSet<u64> = closure.nested_display_lists.keys().copied().collect();
- while let Some(display_list) = pending.pop() {
- closure.include_own(&display_list.resources);
- for (id, nested) in &display_list.resources.nested_display_lists {
- if visited.insert(*id) {
- closure.nested_display_lists.insert(*id, nested.clone());
- pending.push(nested.clone());
- }
- }
+ for vector_image in self.vector_images.values() {
+ closure.include_fonts_and_image_frames(&vector_image.resources);
}
closure
}
- fn include_own(&mut self, other: &Self) {
- let nested = std::mem::take(&mut self.nested_display_lists);
- self.include(&Self {
- nested_display_lists: HashMap::new(),
- ..other.clone()
- });
- self.nested_display_lists = nested;
- }
-
/// Takes what `source` holds of what `summary` names and this lacks: what a recording copied from the one it read
/// paint commands from draws.
pub(crate) fn complete_from(&mut self, summary: &DisplayListSummary, source: &Self) {
@@ -85,11 +65,9 @@ impl DisplayListResources {
self.image_frames.entry(*id).or_insert_with(|| frame.clone());
}
}
- for id in &summary.display_list_ids {
- if let Some(display_list) = source.nested_display_lists.get(id) {
- self.nested_display_lists
- .entry(*id)
- .or_insert_with(|| display_list.clone());
+ for id in &summary.vector_image_ids {
+ if let Some(vector_image) = source.vector_images.get(id) {
+ self.vector_images.entry(*id).or_insert_with(|| vector_image.clone());
}
}
}
@@ -98,99 +76,17 @@ impl DisplayListResources {
ResourceIds {
fonts: self.fonts.keys().copied().collect(),
image_frames: self.image_frames.keys().copied().collect(),
- display_lists: self.nested_display_lists.keys().copied().collect(),
+ vector_images: self.vector_images.keys().copied().collect(),
}
}
}
-/// The ids of resources a receiver holds.
+/// The ids of resources a receiver holds, and of the SVG images it may keep rasters of.
#[derive(Clone, Default, Debug, PartialEq, Eq)]
pub(crate) struct ResourceIds {
pub(crate) fonts: HashSet<u64>,
pub(crate) image_frames: HashSet<u64>,
- pub(crate) display_lists: HashSet<u64>,
-}
-
-/// A display list another one nests, such as an SVG image or an image paint: what the compositor stores under its id,
-/// and what it draws.
-pub(crate) struct NestedDisplayList {
- pub(crate) resource: NestedDisplayListResource,
- pub(crate) resources: DisplayListResources,
-}
-
-impl NestedDisplayList {
- /// The list `display_list` recorded against `visual_context_tree`, under a new id, drawing `resources`.
- pub(crate) fn recorded(
- display_list: Arc<RecordedDisplayList>,
- visual_context_tree: Arc<VisualContextTree>,
- root_group_color: libgfx_rust::Color,
- resources: DisplayListResources,
- ) -> Arc<Self> {
- let storage = DisplayListStorage::recorded(display_list, visual_context_tree.clone());
- Self::new(storage, visual_context_tree, root_group_color, resources)
- }
-
- /// A list that draws `frame`, the raster of an SVG image of `size`, under a new id.
- pub(crate) fn drawing_image_frame(frame: ImageFrameHandle, size: libgfx_rust::IntSize) -> Arc<Self> {
- let mut recorder = DisplayListRecorder::new(None);
- recorder.draw_scaled_decoded_image_frame(
- libgfx_rust::FloatRect::new(0.0, 0.0, size.width as f32, size.height as f32),
- None,
- ImageFrameResourceId(frame.id()),
- libgfx_rust::ScalingMode::Bilinear,
- libgfx_rust::CompositingAndBlendingOperator::Normal,
- None,
- ForceDarkRole::None,
- );
- let mut resources = DisplayListResources::default();
- resources.image_frames.insert(frame.id(), frame);
- Self::recorded(
- Arc::new(recorder.into_builder().finish()),
- Arc::new(VisualContextTree::create_identity()),
- libgfx_rust::Color::TRANSPARENT,
- resources,
- )
- }
-
- /// An empty list, which stands in for an SVG image that has nothing to show.
- pub(crate) fn empty() -> Arc<Self> {
- let storage = DisplayListStorage::empty();
- let visual_context_tree = storage
- .visual_context_tree()
- .cloned()
- .expect("an empty list holds the tree it was recorded against");
- Self::new(
- storage,
- visual_context_tree,
- libgfx_rust::Color::TRANSPARENT,
- DisplayListResources::default(),
- )
- }
-
- fn new(
- storage: Arc<DisplayListStorage>,
- visual_context_tree: Arc<VisualContextTree>,
- root_group_color: libgfx_rust::Color,
- resources: DisplayListResources,
- ) -> Arc<Self> {
- Arc::new(Self {
- resource: NestedDisplayListResource {
- properties: Compositing_DisplayListProperties {
- id: allocate_display_list_id(),
- compatible_visual_context_tree_structural_epoch: visual_context_tree.structural_epoch,
- surface_clear_color: None,
- root_group_color,
- },
- storage,
- tree: visual_context_tree,
- },
- resources,
- })
- }
-
- pub(crate) fn id(&self) -> u64 {
- self.resource.properties.id
- }
+ pub(crate) vector_images: HashSet<u64>,
}
/// The ids of the resources the commands of `display_list` name.
diff --git a/Libraries/LibWeb/Rust/src/painting/host/paint.rs b/Libraries/LibWeb/Rust/src/painting/host/paint.rs
index 205fcd8832b..a2e3a82e94d 100644
--- a/Libraries/LibWeb/Rust/src/painting/host/paint.rs
+++ b/Libraries/LibWeb/Rust/src/painting/host/paint.rs
@@ -46,6 +46,7 @@ pub struct FfiRecordingInputs {
pub palette_is_dark: bool,
pub document_supports_light_or_dark: bool,
pub image_fallback_color_scheme: u8,
+ pub records_without_visual_contexts: bool,
pub accessibility_focus_target: crate::layout::node_data::NodeSlotId,
pub has_inspector_highlight: bool,
pub inspector_highlight_paintable: crate::layout::node_data::NodeSlotId,
@@ -195,6 +196,7 @@ impl FfiRecordingInputs {
palette_is_dark: self.palette_is_dark,
document_supports_light_or_dark: self.document_supports_light_or_dark,
image_fallback_color_scheme: self.image_fallback_color_scheme,
+ records_without_visual_contexts: self.records_without_visual_contexts,
accessibility_focus_target: (!self.accessibility_focus_target.is_invalid())
.then_some(self.accessibility_focus_target),
inspector_highlight: self.has_inspector_highlight.then(|| {
diff --git a/Libraries/LibWeb/Rust/src/painting/mod.rs b/Libraries/LibWeb/Rust/src/painting/mod.rs
index b67c017eb9f..89ce96ef004 100644
--- a/Libraries/LibWeb/Rust/src/painting/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/mod.rs
@@ -54,6 +54,7 @@ pub(crate) mod svg_masking;
pub(crate) mod svg_paint_resources;
pub mod text_fragment;
pub(crate) mod vector_image_cache;
+pub(crate) mod vector_image_records;
pub mod viewport_mapping;
pub mod visual_animation_builder;
pub mod visual_context;
diff --git a/Libraries/LibWeb/Rust/src/painting/presentation.rs b/Libraries/LibWeb/Rust/src/painting/presentation.rs
index d4b7b3275db..ab4e171d544 100644
--- a/Libraries/LibWeb/Rust/src/painting/presentation.rs
+++ b/Libraries/LibWeb/Rust/src/painting/presentation.rs
@@ -17,6 +17,7 @@ use crate::painting::display_list::storage::DisplayListStorage;
use crate::painting::display_list_resources::{DisplayListResources, ResourceIds};
use crate::painting::paint_passes::ClockTickVisualContexts;
use crate::painting::record::RecordingOutput;
+use crate::painting::vector_image_records::display_list_holding_vector_image_records;
use crate::painting::visual_context::VisualContextTree;
use libcompositing_rust::ipc_types::compositor_web_content_server::messages::{
ApplyScrollRequests, PresentFrame, UpdateDisplayList, UpdateScrollState, UpdateVisualContextTree,
@@ -308,7 +309,7 @@ impl PresenterState {
if !published.is_some_and(|published| published.replaces_paint_command_cache_source)
&& let Some(source) = &seal.paint_command_cache_source
{
- resources.include(&source.resources.with_nested_resources());
+ resources.include(&source.resources.with_vector_image_resources());
}
// The next frame a rendering update commits copies paint commands from the one it committed last, whatever a
// clock lane presented since.
@@ -365,16 +366,11 @@ impl PresenterState {
update.image_frames.push(frame);
}
}
- for (id, display_list) in resources.nested_display_lists {
- if !held.display_lists.contains(&id) {
- update.transaction.display_lists.push(display_list.resource.clone());
- }
- }
let removed =
|held: &HashSet<u64>, kept: &HashSet<u64>| -> Vec<u64> { held.difference(kept).copied().collect() };
update.transaction.font_ids_to_remove = removed(&held.fonts, &kept_ids.fonts);
update.transaction.image_frame_ids_to_remove = removed(&held.image_frames, &kept_ids.image_frames);
- update.transaction.display_list_ids_to_remove = removed(&held.display_lists, &kept_ids.display_lists);
+ update.transaction.vector_image_ids_to_remove = removed(&held.vector_images, &kept_ids.vector_images);
self.compositor_resource_ids = kept_ids;
update
}
@@ -425,7 +421,7 @@ impl PresenterState {
});
if let Some(published) = published.as_ref().filter(|_| !display_list_is_unchanged) {
let output = published.output.clone();
- let command_resources = output.resources.with_nested_resources();
+ let command_resources = output.resources.with_vector_image_resources();
let kept = self.kept_resources(seal, Some(published), &command_resources, visual_context_tree);
let mut async_scrolling_metadata = output
.async_scrolling_metadata
@@ -722,8 +718,16 @@ fn post_frame_through(poster: &crate::paint_stage::CompositorPoster, frame: Comp
if !post_resources_ahead(poster, context_id, &update.resources) {
return false;
}
+ // The compositor replays a tape with the records of the SVG images it draws in it.
+ let display_list = match update.output.resources.vector_images.is_empty() {
+ true => update.output.display_list.clone(),
+ false => Arc::new(display_list_holding_vector_image_records(
+ &update.output.display_list,
+ &update.output.resources.vector_images,
+ )),
+ };
let storage = DisplayListStorage::recorded(
- update.output.display_list.clone(),
+ display_list,
update
.output
.visual_context_tree
diff --git a/Libraries/LibWeb/Rust/src/painting/rasterize.rs b/Libraries/LibWeb/Rust/src/painting/rasterize.rs
index 0344af3e181..6378098086d 100644
--- a/Libraries/LibWeb/Rust/src/painting/rasterize.rs
+++ b/Libraries/LibWeb/Rust/src/painting/rasterize.rs
@@ -12,13 +12,14 @@ use crate::painting::display_list::builder::RecordedDisplayList;
use crate::painting::display_list::commands::{DisplayListResourceId, ImageFrameResourceId};
use crate::painting::display_list::ids::allocate_display_list_id;
use crate::painting::display_list::storage::DisplayListStorage;
-use crate::painting::display_list_resources::{DisplayListResources, NestedDisplayList};
+use crate::painting::display_list_resources::DisplayListResources;
use crate::painting::force_dark::ForceDarkRole;
use crate::painting::vector_image_cache::{FfiVectorImageKey, VectorImageKey};
+use crate::painting::vector_image_records::{VectorImageRecords, display_list_holding_vector_image_records};
use crate::painting::visual_context::VisualContextTree;
use crate::render_state::DocumentHost;
+use libcompositing_rust::ipc_types::Compositing_DisplayListProperties;
use libcompositing_rust::ipc_types::compositor_web_content_server::messages::RasterizeDisplayList;
-use libcompositing_rust::ipc_types::{Compositing_DisplayListProperties, Compositing_DisplayListResourceTransaction};
use libgfx_rust::font::FontHandle;
use libgfx_rust::image_frame::ImageFrameHandle;
use libgfx_rust::{CompositingAndBlendingOperator, FloatRect, IntSize, ScalingMode};
@@ -90,15 +91,15 @@ unsafe fn record_image(image: &FfiImageRasterization) -> (RecordedDisplayList, D
}
FfiImageRasterizationKind::VectorImage => {
// SAFETY: The caller keeps the host live for the call.
- let display_list = unsafe { image.vector_image_host.as_ref() }
+ let vector_image = unsafe { image.vector_image_host.as_ref() }
.and_then(|host| host.vector_image(&VectorImageKey::of(&image.vector_image_key)))
- .unwrap_or_else(NestedDisplayList::empty);
- recorder.paint_nested_display_list(
- DisplayListResourceId(display_list.id()),
+ .unwrap_or_else(VectorImageRecords::empty);
+ recorder.paint_vector_image_records(
+ DisplayListResourceId(vector_image.id()),
dest_rect,
image.vector_image_size,
);
- resources.nested_display_lists.insert(display_list.id(), display_list);
+ resources.vector_images.insert(vector_image.id(), vector_image);
}
FfiImageRasterizationKind::Gradient => {
// SAFETY: The caller keeps the gradient style value and the style its color stops resolve against live for
@@ -132,20 +133,21 @@ unsafe fn record_image(image: &FfiImageRasterization) -> (RecordedDisplayList, D
fn post_rasterization(
poster: &CompositorPoster,
token: u64,
- display_list: Arc<RecordedDisplayList>,
+ display_list: &RecordedDisplayList,
tree: Arc<VisualContextTree>,
root_group_color: libgfx_rust::Color,
resources: &DisplayListResources,
target_bitmap: *const c_void,
) -> bool {
- let resources = resources.with_nested_resources();
+ let display_list = display_list_holding_vector_image_records(display_list, &resources.vector_images);
+ let resources = resources.with_vector_image_resources();
let fonts: Vec<FontHandle> = resources.fonts.values().cloned().collect();
let image_frames: Vec<ImageFrameHandle> = resources.image_frames.values().cloned().collect();
// SAFETY: The caller keeps the bitmap live for the call.
if !unsafe { poster.stage_rasterization(token, &fonts, &image_frames, target_bitmap) } {
return false;
}
- let storage = DisplayListStorage::recorded(display_list, tree.clone());
+ let storage = DisplayListStorage::recorded(Arc::new(display_list), tree.clone());
let properties = Compositing_DisplayListProperties {
id: allocate_display_list_id(),
compatible_visual_context_tree_structural_epoch: tree.structural_epoch,
@@ -163,14 +165,6 @@ fn post_rasterization(
token,
display_list,
visual_context_tree: tree,
- nested_display_lists: Compositing_DisplayListResourceTransaction {
- display_lists: resources
- .nested_display_lists
- .values()
- .map(|display_list| display_list.resource.clone())
- .collect(),
- ..Default::default()
- },
})
}
@@ -195,7 +189,7 @@ pub unsafe extern "C" fn render_state_rasterize_image(
post_rasterization(
&poster,
token,
- Arc::new(display_list),
+ &display_list,
Arc::new(VisualContextTree::create_identity()),
libgfx_rust::Color::TRANSPARENT,
&resources,
@@ -233,7 +227,7 @@ pub unsafe extern "C" fn render_state_rasterize_last_recording(
post_rasterization(
&poster,
token,
- recording.display_list.clone(),
+ &recording.display_list,
tree,
recording.root_group_color,
&recording.resources,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/inputs.rs b/Libraries/LibWeb/Rust/src/painting/record/inputs.rs
index 2632ede9ab3..c4e6b1b0d25 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/inputs.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/inputs.rs
@@ -86,6 +86,9 @@ pub(crate) struct RecordingInputs {
pub document_supports_light_or_dark: bool,
// The color scheme an SVG image renders in where neither the box that draws it nor its document opts into one.
pub image_fallback_color_scheme: u8,
+ // Whether the document is an SVG image's, whose records go into the tapes of the documents that draw the image: the
+ // transforms, clips and effects of its boxes are recorded in the records, which name no visual context.
+ pub records_without_visual_contexts: bool,
// The paintable the assistive technology's browse-mode focus is on, which paints the AT focus ring.
pub accessibility_focus_target: Option<NodeSlotId>,
pub inspector_highlight: Option<InspectorHighlight>,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/mod.rs b/Libraries/LibWeb/Rust/src/painting/record/mod.rs
index 2621e6c14c1..f7c6091d603 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/mod.rs
@@ -64,8 +64,8 @@ pub struct RecordingOutput {
// Whether the window was focused, which the output of the producers that read it reflects.
pub(crate) window_is_focused: bool,
pub(crate) capture_log: Option<trace::CaptureLog>,
- /// The SVG images whose display lists, which the host rendered, the recording draws, and the ids of those lists.
- pub(crate) vector_image_display_lists: Vec<(vector_images::VectorImageRenderRequest, u64)>,
+ /// The SVG images the recording draws, which the host rendered, and the ids of their records.
+ pub(crate) vector_image_ids_by_request: Vec<(vector_images::VectorImageRenderRequest, u64)>,
/// What the display list draws besides its tape.
pub(crate) resources: crate::painting::display_list_resources::DisplayListResources,
/// The display list's id, which a recording that repeats the one published last shares with it.
@@ -261,7 +261,7 @@ impl<O: Observer> PaintRecorder<'_, O> {
return;
}
let group = self.recorder.begin_repeated_tile();
- self.recorder.paint_nested_display_list(
+ self.recorder.paint_vector_image_records(
display_list_id,
libgfx_rust::FloatRect::new(0.0, 0.0, dest_device_rect.width as f32, dest_device_rect.height as f32),
geometry.list_size,
@@ -285,7 +285,7 @@ impl<O: Observer> PaintRecorder<'_, O> {
return;
}
self.recorder
- .paint_nested_display_list(display_list_id, dest_rect, geometry.list_size);
+ .paint_vector_image_records(display_list_id, dest_rect, geometry.list_size);
}
pub(crate) fn own_scroll_container_offset(&self, paintable: NodeSlotId) -> crate::css::css_pixels::CssPixelPoint {
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/background.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/background.rs
index 400580c9d6a..43b491c59d6 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/background.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/background.rs
@@ -919,11 +919,11 @@ fn paint_image_layer_in_current_space<O: Observer>(
if inline_operator == CompositingAndBlendingOperator::Normal && tile_count == 1.0 && is_untransformed {
recorder
.recorder
- .paint_nested_display_list(display_list_id, dest_rect.to_float(), tile_size);
+ .paint_vector_image_records(display_list_id, dest_rect.to_float(), tile_size);
return;
}
let group = recorder.recorder.begin_repeated_tile();
- recorder.recorder.paint_nested_display_list(
+ recorder.recorder.paint_vector_image_records(
display_list_id,
FloatRect::new(0.0, 0.0, dest_rect.width as f32, dest_rect.height as f32),
tile_size,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/border_image.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/border_image.rs
index e7dc3c00fb3..da4843ccbcf 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/border_image.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/border_image.rs
@@ -310,7 +310,7 @@ fn paint_vector_border_image_slice<O: Observer>(
));
let group = recorder.recorder.begin_repeated_tile();
// The tile holds the whole image, offset so that the slice fills it, and clips away the rest.
- recorder.recorder.paint_nested_display_list(
+ recorder.recorder.paint_vector_image_records(
display_list_id,
FloatRect::new(
-source_rect.x * rendered_scale.width,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/publish.rs b/Libraries/LibWeb/Rust/src/painting/record/publish.rs
index e541ad70420..8314aa62425 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/publish.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/publish.rs
@@ -5,8 +5,8 @@
*/
use crate::layout::LayoutNodeArena;
-use crate::painting::display_list::commands::{DisplayListCommandType, DisplayListResourceId, PaintNestedDisplayList};
-use crate::painting::display_list_resources::{DisplayListResources, NestedDisplayList, summary_of};
+use crate::painting::display_list::commands::{DisplayListCommandType, DisplayListResourceId, PaintVectorImage};
+use crate::painting::display_list_resources::{DisplayListResources, summary_of};
use crate::painting::hit_test::HitTestList;
use crate::painting::host::FfiRecordingPublishCallbacks;
use crate::painting::paint_state::PendingRecording;
@@ -19,6 +19,7 @@ use crate::painting::record::{RecordingOutput, RecordingResult};
use crate::painting::recording_slot::Publication;
use crate::painting::svg_paint_resources::published_filter_image_frames_in;
use crate::painting::vector_image_cache::VectorImageKey;
+use crate::painting::vector_image_records::VectorImageRecords;
use crate::stage::MainThread;
use std::collections::HashMap;
use std::sync::Arc;
@@ -28,22 +29,22 @@ fn resolve_vector_image_placeholders(
requests: &[VectorImageRenderRequest],
main_thread: &MainThread,
publish: &FfiRecordingPublishCallbacks,
-) -> Vec<Arc<NestedDisplayList>> {
+) -> Vec<Arc<VectorImageRecords>> {
if requests.is_empty() {
return Vec::new();
}
- let display_lists = render_vector_images(requests, main_thread, publish);
- patch_vector_image_placeholders(output, &display_lists);
- display_lists
+ let vector_images = render_vector_images(requests, main_thread, publish);
+ patch_vector_image_placeholders(output, &vector_images);
+ vector_images
}
-/// Has the host render the SVG images of `requests`, and answers their display lists, one for each request: the one the
-/// image's document keeps for the request, or an empty one where the image has nothing to show.
+/// Has the host render the SVG images of `requests`, and answers their records, one for each request: those the
+/// image's document keeps for the request, or none where the image has nothing to show.
pub(crate) fn render_vector_images(
requests: &[VectorImageRenderRequest],
main_thread: &MainThread,
publish: &FfiRecordingPublishCallbacks,
-) -> Vec<Arc<NestedDisplayList>> {
+) -> Vec<Arc<VectorImageRecords>> {
requests
.iter()
.map(|request| {
@@ -51,28 +52,27 @@ pub(crate) fn render_vector_images(
publish
.render_vector_image(main_thread, &request)
.and_then(|image_host| image_host.vector_image(&VectorImageKey::of_request(&request)))
- .unwrap_or_else(NestedDisplayList::empty)
+ .unwrap_or_else(VectorImageRecords::empty)
})
.collect()
}
-/// Patches the placeholders of SVG images in `output` with the ids of `display_lists`, one for each image.
-fn patch_vector_image_placeholders(output: &mut RecordingOutput, display_lists: &[Arc<NestedDisplayList>]) {
+/// Patches the placeholders of SVG images in `output` with the ids of `vector_images`, one for each image.
+fn patch_vector_image_placeholders(output: &mut RecordingOutput, vector_images: &[Arc<VectorImageRecords>]) {
let display_list = std::sync::Arc::make_mut(&mut output.display_list);
- let id_field_offset = std::mem::offset_of!(PaintNestedDisplayList, display_list_id);
+ let id_field_offset = std::mem::offset_of!(PaintVectorImage, vector_image_id);
let mut patch_offsets = Vec::new();
crate::painting::display_list::nested_records::for_each_command_including_nested(
&display_list.bytes,
&mut |command_type, payload_offset, payload| {
- if command_type != DisplayListCommandType::PaintNestedDisplayList {
+ if command_type != DisplayListCommandType::PaintVectorImage {
return;
}
- let id =
- crate::painting::display_list::builder::read_command::<PaintNestedDisplayList>(payload).display_list_id;
+ let id = crate::painting::display_list::builder::read_command::<PaintVectorImage>(payload).vector_image_id;
if is_vector_image_placeholder(id) {
patch_offsets.push((
payload_offset + id_field_offset,
- display_lists[vector_image_placeholder_index(id)].id(),
+ vector_images[vector_image_placeholder_index(id)].id(),
));
}
},
@@ -144,25 +144,25 @@ pub(crate) fn publish_to_presenter(pending: PendingRecording, recorder: &Recorde
publish_resources(pending, recorder, |_, _| Vec::new())
}
-/// Makes the output of a recording that renders SVG images, beside the event loop, with `display_lists`, those the host
+/// Makes the output of a recording that renders SVG images, beside the event loop, with `vector_images`, those the host
/// rendered them as, one for each of the images.
pub(crate) fn publish_with_vector_images(
pending: PendingRecording,
recorder: &RecorderState,
- display_lists: &[Arc<NestedDisplayList>],
+ vector_images: &[Arc<VectorImageRecords>],
) -> RecordingOutput {
publish_resources(pending, recorder, |output, _| {
- patch_vector_image_placeholders(output, display_lists);
- display_lists.to_vec()
+ patch_vector_image_placeholders(output, vector_images);
+ vector_images.to_vec()
})
}
-/// The display lists the host rendered the SVG images of `pending` as for the recording published last with `recorder`,
-/// one for each of the images, or none where one of the images is new to that recording.
-pub(crate) fn published_vector_image_display_lists(
+/// The records the host rendered the SVG images of `pending` as for the recording published last with `recorder`, those
+/// of each of the images, or none where one of the images is new to that recording.
+pub(crate) fn published_vector_image_records(
pending: &PendingRecording,
recorder: &RecorderState,
-) -> Option<Vec<Arc<NestedDisplayList>>> {
+) -> Option<Vec<Arc<VectorImageRecords>>> {
let published = recorder.published_recording.as_ref()?;
pending
.recording
@@ -171,18 +171,17 @@ pub(crate) fn published_vector_image_display_lists(
.iter()
.map(|request| {
let id = published
- .vector_image_display_lists
+ .vector_image_ids_by_request
.iter()
.find_map(|(published_request, id)| (published_request == request).then_some(*id))?;
- published.resources.nested_display_lists.get(&id).cloned()
+ published.resources.vector_images.get(&id).cloned()
})
.collect()
}
-/// The SVG images whose display lists `output` draws, with their ids: those of `requests`, whose display lists are
-/// `resolved_ids`, and those of `published`, the recording published last, that the clean output `output` copied from
-/// it still draws.
-fn drawn_vector_image_display_lists(
+/// The SVG images `output` draws, with the ids of their records: those of `requests`, whose records are `resolved_ids`,
+/// and those of `published`, the recording published last, that the clean output `output` copied from it still draws.
+fn drawn_vector_image_ids(
output: &RecordingOutput,
requests: &[VectorImageRenderRequest],
resolved_ids: &[u64],
@@ -190,24 +189,23 @@ fn drawn_vector_image_display_lists(
) -> Vec<(VectorImageRenderRequest, u64)> {
let mut drawn: Vec<(VectorImageRenderRequest, u64)> =
requests.iter().copied().zip(resolved_ids.iter().copied()).collect();
- let carried = published.map_or(&[][..], |published| &published.vector_image_display_lists[..]);
+ let carried = published.map_or(&[][..], |published| &published.vector_image_ids_by_request[..]);
if carried.is_empty() {
return drawn;
}
- let mut nested_ids = std::collections::HashSet::new();
+ let mut drawn_ids = std::collections::HashSet::new();
crate::painting::display_list::nested_records::for_each_command_including_nested(
&output.display_list.bytes,
&mut |command_type, _, payload| {
- if command_type == DisplayListCommandType::PaintNestedDisplayList {
- nested_ids.insert(
- crate::painting::display_list::builder::read_command::<PaintNestedDisplayList>(payload)
- .display_list_id,
+ if command_type == DisplayListCommandType::PaintVectorImage {
+ drawn_ids.insert(
+ crate::painting::display_list::builder::read_command::<PaintVectorImage>(payload).vector_image_id,
);
}
},
);
for &(request, id) in carried {
- if nested_ids.contains(&DisplayListResourceId(id))
+ if drawn_ids.contains(&DisplayListResourceId(id))
&& !drawn.iter().any(|(drawn_request, _)| *drawn_request == request)
{
drawn.push((request, id));
@@ -221,7 +219,7 @@ fn drawn_vector_image_display_lists(
fn publish_resources(
pending: PendingRecording,
recorder: &RecorderState,
- resolve_vector_images: impl FnOnce(&mut RecordingOutput, &[VectorImageRenderRequest]) -> Vec<Arc<NestedDisplayList>>,
+ resolve_vector_images: impl FnOnce(&mut RecordingOutput, &[VectorImageRenderRequest]) -> Vec<Arc<VectorImageRecords>>,
) -> RecordingOutput {
let PendingRecording {
recording: RecordingResult { mut output, resources },
@@ -237,18 +235,18 @@ fn publish_resources(
let mut display_list_resources = DisplayListResources {
fonts: fonts.into_iter().map(|(id, font)| (id.0, font)).collect(),
image_frames,
- nested_display_lists: HashMap::new(),
+ vector_images: HashMap::new(),
};
// The filters of the visual context tree's effects draw these.
for frame in published_filter_image_frames_in(&svg_paint_resources) {
display_list_resources.image_frames.entry(frame.id()).or_insert(frame);
}
let resolved = resolve_vector_images(&mut output, &vector_image_render_requests);
- let resolved_ids: Vec<u64> = resolved.iter().map(|display_list| display_list.id()).collect();
- for display_list in resolved {
+ let resolved_ids: Vec<u64> = resolved.iter().map(|vector_image| vector_image.id()).collect();
+ for vector_image in resolved {
display_list_resources
- .nested_display_lists
- .insert(display_list.id(), display_list);
+ .vector_images
+ .insert(vector_image.id(), vector_image);
}
// What the recording copied from the one it read paint commands from draws what that one drew.
if let Some(source) = recorder.published_recording.as_deref() {
@@ -258,8 +256,8 @@ fn publish_resources(
// Only a recording that publishes becomes the one the next recording copies from, so only it keeps the SVG images
// it carried over from the one published last.
let published = recorder.published_recording.as_deref().filter(|_| publishes_recording);
- output.vector_image_display_lists =
- drawn_vector_image_display_lists(&output, &vector_image_render_requests, &resolved_ids, published);
+ output.vector_image_ids_by_request =
+ drawn_vector_image_ids(&output, &vector_image_render_requests, &resolved_ids, published);
output.is_identical_to_published_recording = recorder
.published_recording
.as_ref()
diff --git a/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs b/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
index 2ea6d182a0b..f6ee3dafce4 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs
@@ -280,6 +280,31 @@ impl<O: Observer> PaintRecorder<'_, O> {
self.recorder.set_accumulated_visual_context(walk.enclosing_context);
}
+ /// Records the document of an SVG image, whose viewport is `viewport`, as the content of an SVG resource is
+ /// recorded: under no visual context, with the transforms, clips and effects of its boxes in the records.
+ pub(crate) fn record_svg_image_document(&mut self, viewport: NodeSlotId) {
+ let consumer_clip_rect = self.inputs.bitmap_rect.to_float();
+ let walk = SvgResourceWalk {
+ enclosing_context: self.recorder.accumulated_visual_context(),
+ draws_clip_path_geometry: false,
+ consumer_clip_rect,
+ };
+ // The viewport paints the background its root propagates to it.
+ let enclosing_walk = self.svg_resource_walk.replace(walk);
+ let enclosing_transform = self
+ .recorder
+ .set_ambient_inline_transform(Some(AffineTransform::identity()));
+ self.record_box_phase_inside_resource(viewport, PaintPhase::Background);
+ self.recorder.set_ambient_inline_transform(enclosing_transform);
+ self.svg_resource_walk = enclosing_walk;
+ self.recorder.set_accumulated_visual_context(walk.enclosing_context);
+ let mut child = crate::painting::paint_order::first_paint_child(self.source, viewport);
+ while let Some(current) = child {
+ child = crate::painting::paint_order::next_paint_sibling(self.source, current);
+ self.walk_svg_resource(current, AffineTransform::identity(), true, false, consumer_clip_rect);
+ }
+ }
+
fn paint_svg_box_inside_resource(
&mut self,
svg_box: NodeSlotId,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
index 8ec0bbbe023..fe7771d7ce0 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/traversal.rs
@@ -153,6 +153,12 @@ fn record_display_list_impl<O: Observer>(
recorder.blocking_wheel_event_region_count = tree.read().root_entry().output().blocking_wheel_event_regions;
display_list
}
+ None if inputs.records_without_visual_contexts => {
+ recorder.trace_paint(Operation::Named(None, "svg-image-document"), |recorder| {
+ recorder.record_svg_image_document(viewport);
+ });
+ Arc::new(recorder.recorder.into_builder().finish())
+ }
None => {
let source_prologue_bytes = recorder.source_recording.as_ref().map(|frame| frame.prologue_bytes);
let mut marks = std::mem::take(&mut recorder.scratch.scope_marks);
@@ -191,7 +197,7 @@ fn record_display_list_impl<O: Observer>(
is_identical_to_published_recording: false,
window_is_focused: inputs.window_is_focused,
capture_log: recorder.observer.finish(),
- vector_image_display_lists: Vec::new(),
+ vector_image_ids_by_request: Vec::new(),
resources: Default::default(),
display_list_id: 0,
surface_clear_color: None,
diff --git a/Libraries/LibWeb/Rust/src/painting/recording_slot.rs b/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
index c4b9ef05bcd..5b6ba0d686f 100644
--- a/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
+++ b/Libraries/LibWeb/Rust/src/painting/recording_slot.rs
@@ -19,7 +19,6 @@
use crate::layout::node_data::NodeSlotId;
use crate::layout::{LayoutNodeArena, RowsVersion};
use crate::paint_stage::Presenting;
-use crate::painting::display_list_resources::NestedDisplayList;
use crate::painting::ffi::FfiFlightBlocker;
use crate::painting::hit_test::HitTestList;
use crate::painting::paint_read::PaintSource;
@@ -30,6 +29,7 @@ use crate::painting::record::publish::PresentedOutput;
use crate::painting::record::recorder_state::RecorderState;
use crate::painting::record::vector_images::VectorImageRenderRequest;
use crate::painting::record::{RecordingInputs, RecordingOutput};
+use crate::painting::vector_image_records::VectorImageRecords;
use crate::render_state::{LockstepProof, SampledFrame, TaskBoundary};
use crate::stage_thread::InFlight;
#[cfg(not(test))]
@@ -92,12 +92,12 @@ impl VectorImageFrame {
&self.pending.recording.resources.vector_image_render_requests
}
- /// Presents the frame, recorded with `recorder`, with `display_lists`, those of the SVG images the host rendered, one
- /// for each of the frame's requests, beside the event loop.
+ /// Presents the frame, recorded with `recorder`, with `vector_images`, the records of the SVG images the host
+ /// rendered, those of each of the frame's requests, beside the event loop.
pub(crate) fn present(
self,
recorder: RecorderState,
- display_lists: &[Arc<NestedDisplayList>],
+ vector_images: &[Arc<VectorImageRecords>],
presenting: &mut Presenting,
) -> RecordingAnswer {
let Self {
@@ -107,7 +107,7 @@ impl VectorImageFrame {
lane,
} = self;
let publishes_recording = pending.publishes_recording;
- let output = present_with_vector_images(&mut presentation, pending, &recorder, presenting, display_lists);
+ let output = present_with_vector_images(&mut presentation, pending, &recorder, presenting, vector_images);
let recorded = Recorded::Presented {
output,
publishes_recording,
@@ -280,18 +280,16 @@ impl RecordingJob {
let (pending, trace) = record_frame(frame, &mut recorder, viewport, trace_recordings, inputs);
// A recording that renders an SVG image the recording published last did not draw leaves its frame for the host
// to present, which renders it.
- let vector_image_display_lists = match crate::painting::record::publish::renders_vector_images(&pending) {
+ let rendered_vector_images = match crate::painting::record::publish::renders_vector_images(&pending) {
false => Some(None),
- true => {
- crate::painting::record::publish::published_vector_image_display_lists(&pending, &recorder).map(Some)
- }
+ true => crate::painting::record::publish::published_vector_image_records(&pending, &recorder).map(Some),
};
- let recorded = match (presentation.as_mut(), presenting, vector_image_display_lists) {
- (Some(presentation), Some(presenting), Some(vector_image_display_lists)) => {
+ let recorded = match (presentation.as_mut(), presenting, rendered_vector_images) {
+ (Some(presentation), Some(presenting), Some(rendered_vector_images)) => {
let publishes_recording = pending.publishes_recording;
- let output = match vector_image_display_lists {
- Some(display_lists) => {
- present_with_vector_images(presentation, pending, &recorder, presenting, &display_lists)
+ let output = match rendered_vector_images {
+ Some(vector_images) => {
+ present_with_vector_images(presentation, pending, &recorder, presenting, &vector_images)
}
None => present(presentation, pending, &recorder, presenting),
};
@@ -538,18 +536,18 @@ pub(crate) fn present(
}
/// Presents `pending`, which renders SVG images and was recorded with `recorder`, with `presentation`, beside the event
-/// loop, drawing them as `display_lists`, those the host rendered them as, and answers its output.
+/// loop, drawing them as `vector_images`, the records the host rendered them as, and answers its output.
pub(crate) fn present_with_vector_images(
presentation: &mut Presentation,
pending: PendingRecording,
recorder: &RecorderState,
presenting: &mut Presenting,
- display_lists: &[Arc<NestedDisplayList>],
+ vector_images: &[Arc<VectorImageRecords>],
) -> PresentedOutput {
let output = PresentedOutput::of(crate::painting::record::publish::publish_with_vector_images(
pending,
recorder,
- display_lists,
+ vector_images,
));
presentation.present(&output.output, presenting);
output
diff --git a/Libraries/LibWeb/Rust/src/painting/vector_image_cache.rs b/Libraries/LibWeb/Rust/src/painting/vector_image_cache.rs
index 4bc83c67186..45bc0d079de 100644
--- a/Libraries/LibWeb/Rust/src/painting/vector_image_cache.rs
+++ b/Libraries/LibWeb/Rust/src/painting/vector_image_cache.rs
@@ -4,12 +4,12 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! The display lists an SVG image's document was rendered as, which the document keeps for the sizes, scales, color
+//! The records an SVG image's document was rendered as, which the document keeps for the sizes, scales, color
//! schemes and force-dark settings the pages that draw it asked for, until what it shows changes.
use crate::css::css_pixels::CssPixels;
-use crate::painting::display_list_resources::NestedDisplayList;
use crate::painting::host::FfiVectorImageRenderRequest;
+use crate::painting::vector_image_records::VectorImageRecords;
use crate::render_state::DocumentHost;
use std::sync::Arc;
@@ -70,22 +70,22 @@ const KEPT_RENDERINGS: usize = 10;
/// The renderings of an SVG image's document, oldest first.
#[derive(Default)]
pub(crate) struct VectorImageCache {
- renderings: Vec<(VectorImageKey, Arc<NestedDisplayList>)>,
+ renderings: Vec<(VectorImageKey, Arc<VectorImageRecords>)>,
}
impl VectorImageCache {
- pub(crate) fn get(&self, key: &VectorImageKey) -> Option<Arc<NestedDisplayList>> {
+ pub(crate) fn get(&self, key: &VectorImageKey) -> Option<Arc<VectorImageRecords>> {
self.renderings
.iter()
- .find_map(|(rendered_key, display_list)| (rendered_key == key).then(|| display_list.clone()))
+ .find_map(|(rendered_key, vector_image)| (rendered_key == key).then(|| vector_image.clone()))
}
- fn keep(&mut self, key: VectorImageKey, display_list: Arc<NestedDisplayList>) {
+ fn keep(&mut self, key: VectorImageKey, vector_image: Arc<VectorImageRecords>) {
self.renderings.retain(|(rendered_key, _)| *rendered_key != key);
if self.renderings.len() >= KEPT_RENDERINGS {
self.renderings.remove(0);
}
- self.renderings.push((key, display_list));
+ self.renderings.push((key, vector_image));
}
pub(crate) fn clear(&mut self) {
@@ -94,8 +94,8 @@ impl VectorImageCache {
}
impl DocumentHost {
- /// The display list this SVG image's document was rendered as for `key`, if it keeps one.
- pub(crate) fn vector_image(&self, key: &VectorImageKey) -> Option<Arc<NestedDisplayList>> {
+ /// The records this SVG image's document was rendered as for `key`, if it keeps them.
+ pub(crate) fn vector_image(&self, key: &VectorImageKey) -> Option<Arc<VectorImageRecords>> {
self.vector_images().get(key)
}
}
@@ -117,24 +117,22 @@ pub unsafe extern "C" fn render_state_keep_last_recording_as_vector_image(
read: &crate::render_state::BegunRead,
key: &FfiVectorImageKey,
) {
- let display_list = crate::painting::ffi::read_arena(host, read, (), |arena, ()| {
+ let vector_image = crate::painting::ffi::read_arena(host, read, (), |arena, ()| {
let recording = arena.paint_state().last_recording.clone()?;
- let visual_context_tree = recording.visual_context_tree.clone()?;
- Some(NestedDisplayList::recorded(
- recording.display_list.clone(),
- visual_context_tree,
- recording.root_group_color,
- recording.resources.clone(),
+ Some(VectorImageRecords::recorded(
+ &recording.display_list,
+ &recording.resources,
))
});
host.vector_images().keep(
VectorImageKey::of(key),
- display_list.unwrap_or_else(NestedDisplayList::empty),
+ vector_image.unwrap_or_else(VectorImageRecords::empty),
);
}
-/// Has the SVG image document of `host` keep a display list that draws `image_frame`, a `Gfx::DecodedImageFrame` of
-/// `size` that the document was rasterized into, as its rendering for `key`.
+/// Has the SVG image document of `host` keep `image_frame`, a `Gfx::DecodedImageFrame` of `size` that it was rasterized
+/// into, as its rendering for `key`: the rendering of a document whose boxes are painted through visual contexts,
+/// which the tapes of the pages that draw the image cannot take in.
///
/// # Safety
///
@@ -150,7 +148,7 @@ pub unsafe extern "C" fn render_state_keep_image_frame_as_vector_image(
let frame = unsafe { libgfx_rust::image_frame::ImageFrameHandle::retain(image_frame) };
host.vector_images().keep(
VectorImageKey::of(key),
- NestedDisplayList::drawing_image_frame(frame, size),
+ VectorImageRecords::drawing_image_frame(frame, size),
);
}
diff --git a/Libraries/LibWeb/Rust/src/painting/vector_image_records.rs b/Libraries/LibWeb/Rust/src/painting/vector_image_records.rs
new file mode 100644
index 00000000000..50e2ca50d9a
--- /dev/null
+++ b/Libraries/LibWeb/Rust/src/painting/vector_image_records.rs
@@ -0,0 +1,501 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+//! The records an SVG image's document was recorded as, and how a tape that names them takes them into the payloads
+//! of the commands that paint them, which is the form the compositor replays a tape in.
+
+use crate::painting::display_list::builder::{
+ HEADER_SIZE, RecordedDisplayList, for_each_command, read_command, read_header,
+};
+use crate::painting::display_list::commands::{
+ DeclareMaskContent, DisplayListCommandHeader, DisplayListCommandRun, DisplayListCommandType, DisplayListDataSpan,
+ DisplayListGradientColorStops, DisplayListGradientPaintStyle, DisplayListInlineClip, DisplayListPaintStyle,
+ DrawIsolatedGroup, DrawRepeatedTile, EffectNodeIndex, FillPath, FillRect, FillRectWithRoundedCorners,
+ INLINE_CLIP_ENTRY_SIZE, ImageFrameResourceId, PaintVectorImage, StrokePath,
+};
+use crate::painting::display_list::ffi_bytes::FfiBytes;
+use crate::painting::display_list::ids::allocate_display_list_id;
+use crate::painting::display_list::nested_records::for_each_nested_record_span;
+use crate::painting::display_list::recorder::DisplayListRecorder;
+use crate::painting::display_list::summary::vector_image_records_require_direct_replay;
+use crate::painting::display_list_resources::DisplayListResources;
+use crate::painting::force_dark::ForceDarkRole;
+use libgfx_rust::image_frame::ImageFrameHandle;
+use libgfx_rust::{CompositingAndBlendingOperator, FloatRect, IntSize, ScalingMode};
+use smallvec::SmallVec;
+use std::collections::HashMap;
+use std::mem::{offset_of, size_of};
+use std::sync::Arc;
+
+/// The records an SVG image's document was recorded as, which name no visual context, and what they draw. They hold
+/// the records of the SVG images that the image itself draws.
+pub(crate) struct VectorImageRecords {
+ id: u64,
+ pub(crate) records: Vec<u8>,
+ pub(crate) requires_direct_replay: bool,
+ /// The fonts and image frames the records draw.
+ pub(crate) resources: DisplayListResources,
+}
+
+impl VectorImageRecords {
+ /// The records `display_list` holds, which its document recorded under no visual context, under a new id, drawing
+ /// `resources`.
+ pub(crate) fn recorded(display_list: &RecordedDisplayList, resources: &DisplayListResources) -> Arc<Self> {
+ debug_assert!(
+ display_list.command_runs.len() <= 1,
+ "the records of an SVG image are recorded under one visual context"
+ );
+ let mut records = display_list_holding_vector_image_records(display_list, &resources.vector_images).bytes;
+ forget_visual_context_nodes_named_by(&mut records);
+ let mut drawn = DisplayListResources::default();
+ drawn.include_fonts_and_image_frames(&resources.with_vector_image_resources());
+ Arc::new(Self {
+ id: allocate_display_list_id(),
+ requires_direct_replay: vector_image_records_require_direct_replay(&records),
+ records,
+ resources: drawn,
+ })
+ }
+
+ /// Records that draw `frame`, the raster of an SVG image of `size`, under a new id.
+ pub(crate) fn drawing_image_frame(frame: ImageFrameHandle, size: IntSize) -> Arc<Self> {
+ let mut recorder = DisplayListRecorder::new(None);
+ recorder.draw_scaled_decoded_image_frame(
+ FloatRect::new(0.0, 0.0, size.width as f32, size.height as f32),
+ None,
+ ImageFrameResourceId(frame.id()),
+ ScalingMode::Bilinear,
+ CompositingAndBlendingOperator::Normal,
+ None,
+ ForceDarkRole::None,
+ );
+ let mut resources = DisplayListResources::default();
+ resources.image_frames.insert(frame.id(), frame);
+ Arc::new(Self {
+ id: allocate_display_list_id(),
+ records: recorder.into_builder().finish().bytes,
+ // A raster of the records would hold the pixels the frame holds already.
+ requires_direct_replay: true,
+ resources,
+ })
+ }
+
+ /// No records, which stand in for an SVG image that has nothing to show.
+ pub(crate) fn empty() -> Arc<Self> {
+ Arc::new(Self {
+ id: allocate_display_list_id(),
+ records: Vec::new(),
+ requires_direct_replay: false,
+ resources: DisplayListResources::default(),
+ })
+ }
+
+ pub(crate) fn id(&self) -> u64 {
+ self.id
+ }
+}
+
+// The records replay against the visual context tree of whatever tape takes them in, of which they name no node.
+fn forget_visual_context_nodes_named_by(records: &mut [u8]) {
+ let mut effect_field_offsets = Vec::new();
+ crate::painting::display_list::nested_records::for_each_command_including_nested(
+ records,
+ &mut |command_type, payload_offset, _| match command_type {
+ DisplayListCommandType::FillRect => {
+ effect_field_offsets.push(payload_offset + offset_of!(FillRect, background_color_animation_effect));
+ }
+ DisplayListCommandType::FillRectWithRoundedCorners => effect_field_offsets
+ .push(payload_offset + offset_of!(FillRectWithRoundedCorners, background_color_animation_effect)),
+ _ => {}
+ },
+ );
+ for offset in effect_field_offsets {
+ EffectNodeIndex::NONE.write_ffi_bytes(&mut records[offset..offset + size_of::<EffectNodeIndex>()]);
+ }
+}
+
+// Where a payload grows as the records nested in it take in the records of SVG images: at `position` in the payload as
+// it was, by `growth` bytes.
+#[derive(Clone, Copy)]
+struct PayloadGrowth {
+ position: u32,
+ growth: u32,
+}
+
+fn offset_after_growth(offset: u32, growths: &[PayloadGrowth]) -> u32 {
+ offset
+ + growths
+ .iter()
+ .filter(|growth| growth.position <= offset)
+ .map(|growth| growth.growth)
+ .sum::<u32>()
+}
+
+// The offsets, in the payload of a command that can hold nested records, of every span its command struct holds.
+fn span_field_offsets_of(command_type: DisplayListCommandType) -> SmallVec<[usize; 6]> {
+ fn paint_style_span_field_offsets(paint_style: usize) -> [usize; 3] {
+ let color_stops = paint_style
+ + offset_of!(DisplayListPaintStyle, gradient)
+ + offset_of!(DisplayListGradientPaintStyle, color_stops);
+ [
+ color_stops + offset_of!(DisplayListGradientColorStops, colors),
+ color_stops + offset_of!(DisplayListGradientColorStops, positions),
+ paint_style + offset_of!(DisplayListPaintStyle, pattern_tile),
+ ]
+ }
+ let mut offsets = SmallVec::new();
+ match command_type {
+ DisplayListCommandType::DrawIsolatedGroup => offsets.extend([
+ offset_of!(DrawIsolatedGroup, content),
+ offset_of!(DrawIsolatedGroup, mask),
+ offset_of!(DrawIsolatedGroup, filter),
+ ]),
+ DisplayListCommandType::DrawRepeatedTile => offsets.push(offset_of!(DrawRepeatedTile, tile)),
+ DisplayListCommandType::DeclareMaskContent => offsets.push(offset_of!(DeclareMaskContent, content)),
+ DisplayListCommandType::PaintVectorImage => offsets.push(offset_of!(PaintVectorImage, records)),
+ DisplayListCommandType::FillPath => {
+ offsets.push(offset_of!(FillPath, path_data));
+ offsets.extend(paint_style_span_field_offsets(offset_of!(FillPath, paint_style)));
+ }
+ DisplayListCommandType::StrokePath => {
+ offsets.extend([offset_of!(StrokePath, dash_array), offset_of!(StrokePath, path_data)]);
+ offsets.extend(paint_style_span_field_offsets(offset_of!(StrokePath, paint_style)));
+ }
+ _ => {}
+ }
+ offsets
+}
+
+fn read_span(bytes: &[u8], offset: usize) -> DisplayListDataSpan {
+ read_command::<DisplayListDataSpan>(&bytes[offset..])
+}
+
+fn write_span(bytes: &mut [u8], offset: usize, span: DisplayListDataSpan) {
+ span.write_ffi_bytes(&mut bytes[offset..offset + size_of::<DisplayListDataSpan>()]);
+}
+
+// Appends the record `header` and `payload` make to `out`, with the records of the SVG images it paints, and of those
+// the records nested in it paint, in the payloads of the commands that paint them.
+fn append_record_holding_vector_image_records(
+ header: &DisplayListCommandHeader,
+ payload: &[u8],
+ vector_images: &HashMap<u64, Arc<VectorImageRecords>>,
+ out: &mut Vec<u8>,
+) {
+ let record_start = out.len();
+ out.extend_from_slice(&[0; HEADER_SIZE]);
+ let payload_start = out.len();
+
+ let mut nested_spans: SmallVec<[DisplayListDataSpan; 2]> = SmallVec::new();
+ for_each_nested_record_span(header.command_type, payload, |_, span| {
+ if !span.is_empty() {
+ nested_spans.push(span);
+ }
+ });
+ nested_spans.sort_unstable_by_key(|span| span.offset);
+
+ let mut growths: SmallVec<[PayloadGrowth; 2]> = SmallVec::new();
+ // The sizes the nested spans grow to, by the offsets they had.
+ let mut grown_span_sizes: SmallVec<[(u32, u32); 2]> = SmallVec::new();
+ let mut copied_up_to = 0;
+ let mut vector_image_records_span = None;
+ if header.command_type == DisplayListCommandType::PaintVectorImage {
+ let command = read_command::<PaintVectorImage>(payload);
+ if command.records.is_empty()
+ && let Some(vector_image) = vector_images.get(&command.vector_image_id.0)
+ && !vector_image.records.is_empty()
+ {
+ const { assert!(size_of::<PaintVectorImage>().is_multiple_of(8)) };
+ let position = size_of::<PaintVectorImage>();
+ out.extend_from_slice(&payload[..position]);
+ out.extend_from_slice(&vector_image.records);
+ copied_up_to = position;
+ let growth = u32::try_from(vector_image.records.len()).expect("display list payload exceeds u32");
+ growths.push(PayloadGrowth {
+ position: position as u32,
+ growth,
+ });
+ vector_image_records_span = Some((
+ DisplayListDataSpan {
+ offset: position as u32,
+ size: growth,
+ },
+ vector_image.requires_direct_replay,
+ ));
+ }
+ }
+ for span in &nested_spans {
+ let (start, end) = (span.offset as usize, (span.offset + span.size) as usize);
+ out.extend_from_slice(&payload[copied_up_to..start]);
+ let grown_start = out.len();
+ append_records_holding_vector_image_records(&payload[start..end], vector_images, out);
+ let grown_size = u32::try_from(out.len() - grown_start).expect("display list payload exceeds u32");
+ copied_up_to = end;
+ if grown_size != span.size {
+ growths.push(PayloadGrowth {
+ position: end as u32,
+ growth: grown_size - span.size,
+ });
+ grown_span_sizes.push((span.offset, grown_size));
+ }
+ }
+ out.extend_from_slice(&payload[copied_up_to..]);
+
+ let mut grown_header = *header;
+ if !growths.is_empty() {
+ let total_growth: u32 = growths.iter().map(|growth| growth.growth).sum();
+ grown_header.payload_size += total_growth;
+ let grown_payload = &mut out[payload_start..];
+ let mut span_field_offsets = span_field_offsets_of(header.command_type);
+ // The paths of the inline clips sit after everything else the payload holds but the entries that name them.
+ let clip_entries_start =
+ payload.len() + total_growth as usize - usize::from(header.inline_clip_count) * INLINE_CLIP_ENTRY_SIZE;
+ span_field_offsets.extend((0..usize::from(header.inline_clip_count)).map(|index| {
+ clip_entries_start + index * INLINE_CLIP_ENTRY_SIZE + offset_of!(DisplayListInlineClip, path_data)
+ }));
+ for field_offset in span_field_offsets {
+ let mut span = read_span(grown_payload, field_offset);
+ if let Some(&(_, grown_size)) = grown_span_sizes.iter().find(|(offset, _)| *offset == span.offset)
+ && !span.is_empty()
+ {
+ span.size = grown_size;
+ }
+ span.offset = offset_after_growth(span.offset, &growths);
+ write_span(grown_payload, field_offset, span);
+ }
+ if let Some((records_span, requires_direct_replay)) = vector_image_records_span {
+ write_span(grown_payload, offset_of!(PaintVectorImage, records), records_span);
+ grown_payload[offset_of!(PaintVectorImage, requires_direct_replay)] = u8::from(requires_direct_replay);
+ }
+ }
+ grown_header.write_ffi_bytes(&mut out[record_start..record_start + HEADER_SIZE]);
+}
+
+fn append_records_holding_vector_image_records(
+ records: &[u8],
+ vector_images: &HashMap<u64, Arc<VectorImageRecords>>,
+ out: &mut Vec<u8>,
+) {
+ for_each_command(records, |header, _, payload| {
+ append_record_holding_vector_image_records(header, payload, vector_images, out);
+ });
+}
+
+/// The tape of `display_list` with the records of `vector_images`, the SVG images its commands name, in the payloads
+/// of the commands that paint them, as the compositor replays it.
+pub(crate) fn display_list_holding_vector_image_records(
+ display_list: &RecordedDisplayList,
+ vector_images: &HashMap<u64, Arc<VectorImageRecords>>,
+) -> RecordedDisplayList {
+ if vector_images.is_empty() {
+ return display_list.clone();
+ }
+ let mut bytes = Vec::with_capacity(
+ display_list.bytes.len()
+ + vector_images
+ .values()
+ .map(|vector_image| vector_image.records.len())
+ .sum::<usize>(),
+ );
+ let mut command_runs = Vec::with_capacity(display_list.command_runs.len());
+ for run in &display_list.command_runs {
+ let offset = u32::try_from(bytes.len()).expect("display list exceeds u32");
+ let records = &display_list.bytes[run.offset as usize..(run.offset + run.size) as usize];
+ append_records_holding_vector_image_records(records, vector_images, &mut bytes);
+ command_runs.push(DisplayListCommandRun {
+ offset,
+ size: u32::try_from(bytes.len()).expect("display list exceeds u32") - offset,
+ ..*run
+ });
+ }
+ debug_assert!(
+ display_list.command_runs.is_empty() || read_header(&bytes).payload_size as usize + HEADER_SIZE <= bytes.len()
+ );
+ RecordedDisplayList { bytes, command_runs }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::painting::display_list::builder::{DisplayListBuilder, PendingInlineClip, inline_clips_of};
+ use crate::painting::display_list::commands::{ContextRef, DisplayListResourceId, Repeat};
+ use crate::painting::display_list::nested_records::span_bytes;
+ use crate::painting::display_list::storage::{DisplayListStorage, receive_packed};
+ use crate::painting::visual_context::VisualContextTree;
+ use libgfx_rust::path::Path;
+ use libgfx_rust::{
+ Color, CompositingAndBlendingOperator, FloatPoint, FloatRect, FloatSize, IntRect, IntSize, MaskKind,
+ ScalingMode, WindingRule,
+ };
+
+ fn fill(color: Color) -> FillRect {
+ FillRect {
+ rect: IntRect::new(0, 0, 10, 10),
+ color,
+ compositing_and_blending_operator: CompositingAndBlendingOperator::Normal,
+ background_color_animation_effect: EffectNodeIndex::NONE,
+ }
+ }
+
+ fn reference_to(vector_image: &VectorImageRecords) -> PaintVectorImage {
+ PaintVectorImage {
+ vector_image_id: DisplayListResourceId(vector_image.id()),
+ rect: FloatRect::new(0.0, 0.0, 10.0, 10.0),
+ recorded_size: IntSize { width: 10, height: 10 },
+ records: DisplayListDataSpan::default(),
+ requires_direct_replay: false,
+ }
+ }
+
+ fn vector_image_of(fills: &[FillRect]) -> Arc<VectorImageRecords> {
+ let mut builder = DisplayListBuilder::new();
+ for fill in fills {
+ builder.append(fill, &[], ContextRef::default());
+ }
+ VectorImageRecords::recorded(&builder.finish(), &DisplayListResources::default())
+ }
+
+ fn triangle_clip() -> PendingInlineClip {
+ let mut path = Path::new();
+ path.move_to(FloatPoint { x: 0.0, y: 0.0 });
+ path.line_to(FloatPoint { x: 10.0, y: 0.0 });
+ path.line_to(FloatPoint { x: 0.0, y: 10.0 });
+ path.close();
+ debug_assert_eq!(path.serialize_to_bytes(), triangle_clip_path_bytes());
+ PendingInlineClip::intersecting_path(&path, WindingRule::Nonzero)
+ }
+
+ fn triangle_clip_path_bytes() -> Vec<u8> {
+ let mut path = Path::new();
+ path.move_to(FloatPoint { x: 0.0, y: 0.0 });
+ path.line_to(FloatPoint { x: 10.0, y: 0.0 });
+ path.line_to(FloatPoint { x: 0.0, y: 10.0 });
+ path.close();
+ path.serialize_to_bytes()
+ }
+
+ // Checks the tape as the compositor does when it receives it.
+ fn assert_is_valid_for_the_compositor(display_list: &RecordedDisplayList) {
+ let storage = DisplayListStorage::recorded(
+ Arc::new(display_list.clone()),
+ Arc::new(VisualContextTree::create_identity()),
+ );
+ receive_packed(
+ &storage.packed(),
+ display_list.bytes.len(),
+ display_list.command_runs.len(),
+ )
+ .expect("the tape passes the compositor's validation");
+ }
+
+ #[test]
+ fn a_tape_takes_the_records_of_the_images_it_names_wherever_it_names_them() {
+ let vector_image = vector_image_of(&[fill(Color::from_rgb(255, 0, 0)), fill(Color::from_rgb(0, 255, 0))]);
+ let vector_images = HashMap::from([(vector_image.id(), vector_image.clone())]);
+
+ let mut builder = DisplayListBuilder::new();
+ let context = ContextRef::default();
+ builder.append(&fill(Color::from_rgb(0, 0, 255)), &[], context);
+ // A reference under a clip path, whose bytes sit after the command struct.
+ builder.append_with_inline_clips(&reference_to(&vector_image), &[], context, &[triangle_clip()]);
+ // A reference in a tile, in the content of a masked group whose filter bytes follow the nested records.
+ let mut group = builder.begin_group::<DrawIsolatedGroup>(vec![triangle_clip()]);
+ let tile = builder.begin_group::<DrawRepeatedTile>(Vec::new());
+ builder.append(&reference_to(&vector_image), &[], context);
+ let tile_span = builder.group_content_span(&tile);
+ builder.finish_group(
+ tile,
+ &DrawRepeatedTile {
+ dst_rect: FloatRect::new(0.0, 0.0, 10.0, 10.0),
+ clip_rect: IntRect::new(0, 0, 10, 10),
+ tile_size: IntSize { width: 10, height: 10 },
+ tile_step: FloatSize {
+ width: 10.0,
+ height: 10.0,
+ },
+ tile: tile_span,
+ scaling_mode: ScalingMode::Bilinear,
+ compositing_and_blending_operator: CompositingAndBlendingOperator::Normal,
+ repeat: Repeat { x: true, y: true },
+ },
+ context,
+ );
+ builder.begin_group_mask(&mut group);
+ builder.append(&reference_to(&vector_image), &[], context);
+ let filter = builder.append_group_inline_data(&mut group, &[1, 2, 3, 4, 5]);
+ let (content, mask) = (builder.group_content_span(&group), builder.group_mask_span(&group));
+ builder.finish_group(
+ group,
+ &DrawIsolatedGroup {
+ clip_rect: FloatRect::new(0.0, 0.0, 10.0, 10.0),
+ content,
+ mask,
+ filter,
+ opacity: 1.0,
+ compositing_and_blending_operator: CompositingAndBlendingOperator::Normal,
+ mask_kind: MaskKind::Alpha,
+ },
+ context,
+ );
+ builder.append(&fill(Color::from_rgb(255, 255, 255)), &[], context);
+ let display_list = builder.finish();
+
+ let expanded = display_list_holding_vector_image_records(&display_list, &vector_images);
+ assert_eq!(expanded.command_runs.len(), 1);
+ assert_eq!(expanded.command_runs[0].size as usize, expanded.bytes.len());
+ assert_eq!(
+ expanded.bytes.len(),
+ display_list.bytes.len() + 3 * vector_image.records.len()
+ );
+ assert_is_valid_for_the_compositor(&expanded);
+
+ let mut images_found = 0;
+ let mut clip_paths_found = 0;
+ let mut filters_found = 0;
+ crate::painting::display_list::nested_records::for_each_command_including_nested(
+ &expanded.bytes,
+ &mut |command_type, _, payload| match command_type {
+ DisplayListCommandType::PaintVectorImage => {
+ let command = read_command::<PaintVectorImage>(payload);
+ assert_eq!(span_bytes(payload, command.records), &vector_image.records[..]);
+ images_found += 1;
+ }
+ DisplayListCommandType::DrawIsolatedGroup => {
+ let command = read_command::<DrawIsolatedGroup>(payload);
+ assert_eq!(span_bytes(payload, command.filter), &[1, 2, 3, 4, 5]);
+ filters_found += 1;
+ }
+ _ => {}
+ },
+ );
+ assert_eq!((images_found, filters_found), (3, 1));
+ for_each_command(&expanded.bytes, |header, _, payload| {
+ for clip in inline_clips_of(header, payload) {
+ assert_eq!(span_bytes(payload, clip.path_data), &triangle_clip_path_bytes()[..]);
+ clip_paths_found += 1;
+ }
+ });
+ assert_eq!(clip_paths_found, 2);
+ }
+
+ #[test]
+ fn the_records_of_an_image_hold_those_of_the_images_it_draws() {
+ let inner = vector_image_of(&[fill(Color::from_rgb(255, 0, 0))]);
+ let mut builder = DisplayListBuilder::new();
+ builder.append(&reference_to(&inner), &[], ContextRef::default());
+ let resources = DisplayListResources {
+ vector_images: HashMap::from([(inner.id(), inner.clone())]),
+ ..Default::default()
+ };
+ let outer = VectorImageRecords::recorded(&builder.finish(), &resources);
+ assert!(outer.resources.vector_images.is_empty());
+ for_each_command(&outer.records, |header, _, payload| {
+ assert_eq!(header.command_type, DisplayListCommandType::PaintVectorImage);
+ let command = read_command::<PaintVectorImage>(payload);
+ assert_eq!(span_bytes(payload, command.records), &inner.records[..]);
+ });
+ }
+}
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rs
index c86cafe94a2..f2be61fbb6d 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs
@@ -46,9 +46,7 @@ use crate::painting::paintable_geometry::{
use crate::painting::presentation::Presentation;
use crate::painting::record::damage::PaintDamage;
use crate::painting::record::inputs::UnframedRecordingInputs;
-use crate::painting::record::publish::{
- published_vector_image_display_lists, renders_vector_images, take_in_recording,
-};
+use crate::painting::record::publish::{published_vector_image_records, renders_vector_images, take_in_recording};
use crate::painting::record::recorder_state::RecorderState;
use crate::painting::record::{PublishedHitTestItems, RecordingInputs, RecordingOutput};
use crate::painting::recording_slot::{
@@ -1845,9 +1843,9 @@ impl ClockRecorder {
visual_contexts,
}) = frame;
let (pending, _) = record_frame(frozen.frame, &mut self.recorder, viewport, false, inputs);
- let vector_image_display_lists = match renders_vector_images(&pending) {
- true => match published_vector_image_display_lists(&pending, &self.recorder) {
- Some(display_lists) => Some(display_lists),
+ let rendered_vector_images = match renders_vector_images(&pending) {
+ true => match published_vector_image_records(&pending, &self.recorder) {
+ Some(vector_images) => Some(vector_images),
None => {
self.leave_frame_to_host();
return self;
@@ -1858,13 +1856,13 @@ impl ClockRecorder {
if let Some(visual_contexts) = visual_contexts {
self.presentation.take_visual_context_tree(visual_contexts);
}
- let output = match vector_image_display_lists {
- Some(display_lists) => present_with_vector_images(
+ let output = match rendered_vector_images {
+ Some(vector_images) => present_with_vector_images(
&mut self.presentation,
pending,
&self.recorder,
presenting,
- &display_lists,
+ &vector_images,
),
None => present(&mut self.presentation, pending, &self.recorder, presenting),
};
diff --git a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
index e44daae5817..36d78970c7b 100644
--- a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
+++ b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp
@@ -282,8 +282,8 @@ Layout::RustFFI::DocumentHost const* SVGDecodedImageData::render_at_scale(Painti
return host;
}
- // Foreign content paints in full only through the document's visual contexts, so a page that draws the image
- // draws a raster of the document.
+ // The recording names the document's visual contexts, which the tape of a page that draws the image cannot take
+ // in, so the page draws a raster of it instead.
auto* compositor_host = host_compositor();
if (!compositor_host)
return nullptr;
diff --git a/Services/Compositor/CompositorState.cpp b/Services/Compositor/CompositorState.cpp
index 8dae24b27d2..4a95ced683f 100644
--- a/Services/Compositor/CompositorState.cpp
+++ b/Services/Compositor/CompositorState.cpp
@@ -1202,11 +1202,11 @@ void CompositorState::apply_resource_changes(Web::CompositorContextId context_id
transaction.image_frame_ids_to_remove.append(Compositing::ImageFrameResourceId { id });
auto& raster_targets = context.raster_targets;
raster_targets.apply_resource_transaction(move(transaction));
- // The display lists that the context's lists nest are held by the logic in Rust, and only their rasters here.
- Compositing::DisplayListResourceSet removed_display_lists;
- for (auto id : changes.display_list_ids_to_remove)
- removed_display_lists.display_lists.set(Compositing::DisplayListResourceId { id });
- raster_targets.raster_cache().evict(removed_display_lists);
+ // Only the rasters of the SVG images that the context's display lists draw are kept here.
+ Compositing::DisplayListResourceSet removed_vector_images;
+ for (auto id : changes.vector_image_ids_to_remove)
+ removed_vector_images.vector_images.set(Compositing::DisplayListResourceId { id });
+ raster_targets.raster_cache().evict(removed_vector_images);
show_animated_image_frames_in(context);
}
@@ -1218,7 +1218,7 @@ void CompositorState::set_drawn_video_sinks(Web::CompositorContextId context_id,
bool CompositorState::stage_rasterization(CompositorStateWebContentClient& client, u64 token, Compositing::DisplayListResourceTransaction&& resources, Gfx::ShareableBitmap target_bitmap)
{
- if (!resources.font_ids_to_remove.is_empty() || !resources.image_frame_ids_to_remove.is_empty() || !resources.display_list_ids_to_remove.is_empty())
+ if (!resources.font_ids_to_remove.is_empty() || !resources.image_frame_ids_to_remove.is_empty() || !resources.vector_image_ids_to_remove.is_empty())
return false;
// WebContent waits for each rasterization it stages, so it has only the one in flight per thread that rasterizes.
static constexpr size_t maximum_staged_rasterizations_per_client = 16;
diff --git a/Services/Compositor/CompositorWebContentServer.ipc b/Services/Compositor/CompositorWebContentServer.ipc
index 7b762205208..114f2078619 100644
--- a/Services/Compositor/CompositorWebContentServer.ipc
+++ b/Services/Compositor/CompositorWebContentServer.ipc
@@ -64,10 +64,9 @@ endpoint CompositorWebContentServer
get_placeholder_canvas_pixels(Compositing::CanvasId canvas_id, Gfx::IntRect rect) => (Gfx::ShareableBitmap pixels, bool origin_clean)
// A display list is rasterized into the target bitmap with the fonts and image frames staged for it under a token
- // that the next rasterize_display_list names, and with the display lists it nests, which come with it. The compositor
- // answers with did_rasterize_display_list().
+ // that the next rasterize_display_list names. The compositor answers with did_rasterize_display_list().
stage_rasterization(u64 token, Compositing::DisplayListResourceTransaction resources, Gfx::ShareableBitmap target_bitmap) =|
- [RustReceiver, RustSender] rasterize_display_list(u64 token, Compositing::DisplayList display_list, Compositing::VisualContextTree visual_context_tree, Compositing::DisplayListResourceTransaction nested_display_lists) =|
+ [RustReceiver, RustSender] rasterize_display_list(u64 token, Compositing::DisplayList display_list, Compositing::VisualContextTree visual_context_tree) =|
create_webgl_context(Compositing::WebGL::WebGLVersion webgl_version, Gfx::IntSize size, bool depth, bool stencil, bool antialias) => (bool success, Compositing::CanvasId canvas_id, Vector<String> supported_extensions)
webgl_set_command_buffer(Compositing::CanvasId canvas_id, Core::AnonymousBuffer command_buffer) =|
diff --git a/Services/Compositor/ContextRasterTargets.h b/Services/Compositor/ContextRasterTargets.h
index 3ccce54179e..b24e12e3ca7 100644
--- a/Services/Compositor/ContextRasterTargets.h
+++ b/Services/Compositor/ContextRasterTargets.h
@@ -59,8 +59,7 @@ public:
RefPtr<PresentableSurface> next_presentable_surface(u32 pool, Gfx::IntSize, RefPtr<Gfx::SkiaBackendContext> const&);
void drop_presentable_surface_pool(u32 pool) { m_presentable_surface_pools.remove(pool); }
- // The video sinks that the display list of the context and the lists it nests draw. Answers whether these are
- // other sinks than before.
+ // The video sinks that the display list of the context draws. Answers whether these are other sinks than before.
bool set_drawn_video_sinks(ReadonlySpan<u64> handles);
HashTable<Media::VideoSinkHandle> const& drawn_video_sinks() const { return m_drawn_video_sinks; }
bool draws_video_sink(Media::VideoSinkHandle handle) const { return m_drawn_video_sinks.contains(handle); }
diff --git a/Services/Compositor/DisplayListPlayerSkia.cpp b/Services/Compositor/DisplayListPlayerSkia.cpp
index 2ed0a6387e0..0eab39fc857 100644
--- a/Services/Compositor/DisplayListPlayerSkia.cpp
+++ b/Services/Compositor/DisplayListPlayerSkia.cpp
@@ -60,16 +60,16 @@ struct DisplayListPlayerSkia::RasterState {
// The raster of the tile records that the next command draws with.
sk_sp<SkImage> tile_raster_for_next_command;
- struct NestedDisplayList {
- RustFFI::NestedDisplayListReplay replay { RustFFI::NestedDisplayListReplay::Skipped };
- // For a list replayed into a raster:
- DisplayListResourceId display_list_id {};
- Gfx::IntRect raster_rect_in_list_space {};
- Gfx::IntRect visible_rect_in_list_space {};
+ struct VectorImageInProgress {
+ RustFFI::VectorImageReplay replay { RustFFI::VectorImageReplay::Skipped };
+ // For an image replayed into a raster:
+ DisplayListResourceId vector_image_id {};
+ Gfx::IntRect raster_rect_in_recorded_space {};
+ Gfx::IntRect visible_rect_in_recorded_space {};
SkMatrix placement {};
bool draws_pixel_exact { false };
};
- Vector<NestedDisplayList, 2> nested_display_lists_in_progress;
+ Vector<VectorImageInProgress, 2> vector_images_in_progress;
};
DisplayListPlayerSkia::DisplayListPlayerSkia()
@@ -122,8 +122,8 @@ struct DisplayListPlayerSkia::PainterCallbacks {
.end_isolated_group = [](void* context) { PainterCallbacks::player(context).end_isolated_group(); },
.begin_tile_raster = [](void* context, RustFFI::TileRaster const* tile) -> bool { return PainterCallbacks::player(context).begin_tile_raster(*tile); },
.end_tile_raster = [](void* context) { PainterCallbacks::player(context).end_tile_raster(); },
- .begin_nested_display_list = [](void* context, RustFFI::NestedDisplayListPlacement const* placement, bool requires_direct_replay) { return PainterCallbacks::player(context).begin_nested_display_list(*placement, requires_direct_replay); },
- .end_nested_display_list = [](void* context) { PainterCallbacks::player(context).end_nested_display_list(); },
+ .begin_vector_image = [](void* context, RustFFI::VectorImagePlacement const* placement, bool requires_direct_replay) { return PainterCallbacks::player(context).begin_vector_image(*placement, requires_direct_replay); },
+ .end_vector_image = [](void* context) { PainterCallbacks::player(context).end_vector_image(); },
};
}
};
@@ -143,7 +143,7 @@ void DisplayListPlayerSkia::end_painting()
{
VERIFY(m_surfaces.size() == 1);
VERIFY(m_raster_state->tile_rasters_in_progress.is_empty());
- VERIFY(m_raster_state->nested_display_lists_in_progress.is_empty());
+ VERIFY(m_raster_state->vector_images_in_progress.is_empty());
m_raster_state->tile_raster_for_next_command = nullptr;
m_surfaces.clear();
m_resource_storage = nullptr;
@@ -1392,22 +1392,23 @@ void DisplayListPlayerSkia::end_isolated_group()
canvas.restore();
}
-// Rasterize immutable nested lists (SVG images and masks) at list resolution and reuse their snapshots.
-// The first paint of a list rasterizes only the visible portion, so lists replaced every frame do not paint
-// clipped content. Later cache misses rasterize small lists whole, so scrolled or sliced lists hit one raster.
+// Rasterize the records of SVG images, which stay the same for as long as the image's id does, at the resolution they
+// were recorded at, and reuse the snapshots.
+// The first paint of an image rasterizes only the visible portion, so images replaced every frame do not paint
+// clipped content. Later cache misses rasterize small images whole, so scrolled or sliced images hit one raster.
// NB: Use this path from the first paint. Direct replay and a cached raster can produce different pixels,
// especially when a screenshot targets a CPU bitmap while the cached raster is rendered on the GPU.
-// The number of previous paints must not change how the list is rendered.
-// Lists with destination-reading blends or live content, or under rotated/skewed/mirrored transforms,
-// replay directly. Near-integer placements at list resolution avoid filtering; other placements resample.
-RustFFI::NestedDisplayListReplay DisplayListPlayerSkia::begin_nested_display_list(RustFFI::NestedDisplayListPlacement const& command, bool requires_direct_replay)
+// The number of previous paints must not change how the image is rendered.
+// Images with destination-reading blends or live content, or under rotated/skewed/mirrored transforms,
+// replay directly. Near-integer placements at the recorded resolution avoid filtering; other placements resample.
+RustFFI::VectorImageReplay DisplayListPlayerSkia::begin_vector_image(RustFFI::VectorImagePlacement const& command, bool requires_direct_replay)
{
auto& canvas = surface().canvas();
- DisplayListResourceId display_list_id { command.display_list_id };
+ DisplayListResourceId vector_image_id { command.vector_image_id };
auto total_matrix = canvas.getTotalMatrix();
- auto list_bounds = Gfx::IntRect { {}, command.list_size };
+ auto recorded_bounds = Gfx::IntRect { {}, command.recorded_size };
if (m_skia_backend_context && total_matrix.isScaleTranslate() && total_matrix.getScaleX() > 0 && total_matrix.getScaleY() > 0
- && !command.rect.is_empty() && !list_bounds.is_empty()) {
+ && !command.rect.is_empty() && !recorded_bounds.is_empty()) {
auto device_rect = total_matrix.mapRect(to_skia_rect(command.rect));
constexpr float pixel_exact_epsilon = 1.f / 64.f;
auto snapped_device_rect = SkRect::MakeLTRB(
@@ -1415,25 +1416,25 @@ RustFFI::NestedDisplayListReplay DisplayListPlayerSkia::begin_nested_display_lis
SkScalarRoundToScalar(device_rect.right()), SkScalarRoundToScalar(device_rect.bottom()));
bool draws_pixel_exact = fabsf(device_rect.left() - snapped_device_rect.left()) <= pixel_exact_epsilon
&& fabsf(device_rect.top() - snapped_device_rect.top()) <= pixel_exact_epsilon
- && fabsf(snapped_device_rect.width() - static_cast<float>(command.list_size.width())) <= pixel_exact_epsilon
- && fabsf(snapped_device_rect.height() - static_cast<float>(command.list_size.height())) <= pixel_exact_epsilon;
+ && fabsf(snapped_device_rect.width() - static_cast<float>(command.recorded_size.width())) <= pixel_exact_epsilon
+ && fabsf(snapped_device_rect.height() - static_cast<float>(command.recorded_size.height())) <= pixel_exact_epsilon;
auto placement_device_rect = draws_pixel_exact ? snapped_device_rect : device_rect;
- auto placement = SkMatrix::RectToRect(SkRect::MakeWH(command.list_size.width(), command.list_size.height()), placement_device_rect);
+ auto placement = SkMatrix::RectToRect(SkRect::MakeWH(command.recorded_size.width(), command.recorded_size.height()), placement_device_rect);
SkMatrix inverse_placement;
if (!placement_device_rect.isEmpty() && placement.invert(&inverse_placement)) {
auto visible_device_rect = SkRect::Make(canvas.getDeviceClipBounds());
if (!visible_device_rect.intersect(placement_device_rect))
- return RustFFI::NestedDisplayListReplay::Skipped;
- auto visible_in_list_space = inverse_placement.mapRect(visible_device_rect);
- auto visible_rect_in_list_space = Gfx::enclosing_int_rect(
- Gfx::FloatRect { visible_in_list_space.left(), visible_in_list_space.top(), visible_in_list_space.width(), visible_in_list_space.height() })
- .intersected(list_bounds);
- if (visible_rect_in_list_space.is_empty())
- return RustFFI::NestedDisplayListReplay::Skipped;
+ return RustFFI::VectorImageReplay::Skipped;
+ auto visible_in_recorded_space = inverse_placement.mapRect(visible_device_rect);
+ auto visible_rect_in_recorded_space = Gfx::enclosing_int_rect(
+ Gfx::FloatRect { visible_in_recorded_space.left(), visible_in_recorded_space.top(), visible_in_recorded_space.width(), visible_in_recorded_space.height() })
+ .intersected(recorded_bounds);
+ if (visible_rect_in_recorded_space.is_empty())
+ return RustFFI::VectorImageReplay::Skipped;
auto draw_raster = [&](SkImage& image, Gfx::IntRect raster_rect) {
- auto source_rect = visible_rect_in_list_space.translated(-raster_rect.location());
- auto destination_rect = placement.mapRect(to_skia_rect(visible_rect_in_list_space));
+ auto source_rect = visible_rect_in_recorded_space.translated(-raster_rect.location());
+ auto destination_rect = placement.mapRect(to_skia_rect(visible_rect_in_recorded_space));
auto sampling = draws_pixel_exact ? SkSamplingOptions() : SkSamplingOptions(SkFilterMode::kLinear);
canvas.save();
canvas.setMatrix(SkMatrix::I());
@@ -1442,41 +1443,41 @@ RustFFI::NestedDisplayListReplay DisplayListPlayerSkia::begin_nested_display_lis
};
Gfx::IntRect raster_rect;
- if (auto cached_image = raster_cache().nested_display_list_raster(display_list_id, m_skia_backend_context, visible_rect_in_list_space, raster_rect)) {
+ if (auto cached_image = raster_cache().vector_image_raster(vector_image_id, m_skia_backend_context, visible_rect_in_recorded_space, raster_rect)) {
draw_raster(*cached_image, raster_rect);
- return RustFFI::NestedDisplayListReplay::Skipped;
+ return RustFFI::VectorImageReplay::Skipped;
}
if (!requires_direct_replay) {
- constexpr size_t max_full_list_raster_bytes = 16 * MiB;
- constexpr int max_full_list_raster_dimension = 16384;
+ constexpr size_t max_full_image_raster_bytes = 16 * MiB;
+ constexpr int max_full_image_raster_dimension = 16384;
constexpr size_t max_raster_bytes = 128 * MiB;
auto byte_size = [](Gfx::IntRect const& rect) { return static_cast<size_t>(rect.width()) * rect.height() * 4; };
- bool rasterize_whole_list = raster_cache().has_rasterized_nested_display_list(display_list_id)
- && byte_size(list_bounds) <= max_full_list_raster_bytes
- && list_bounds.width() <= max_full_list_raster_dimension
- && list_bounds.height() <= max_full_list_raster_dimension;
- auto raster_candidate_rect = rasterize_whole_list ? list_bounds : visible_rect_in_list_space;
+ bool rasterize_whole_image = raster_cache().has_rasterized_vector_image(vector_image_id)
+ && byte_size(recorded_bounds) <= max_full_image_raster_bytes
+ && recorded_bounds.width() <= max_full_image_raster_dimension
+ && recorded_bounds.height() <= max_full_image_raster_dimension;
+ auto raster_candidate_rect = rasterize_whole_image ? recorded_bounds : visible_rect_in_recorded_space;
if (byte_size(raster_candidate_rect) <= max_raster_bytes
- && raster_cache().reserve_nested_display_list_raster(display_list_id, m_skia_backend_context, raster_candidate_rect)) {
- // NB: When the raster can't be allocated, the nested list is replayed directly instead.
+ && raster_cache().reserve_vector_image_raster(vector_image_id, m_skia_backend_context, raster_candidate_rect)) {
+ // NB: When the raster can't be allocated, the records are replayed directly instead.
auto offscreen_surface_or_error = Gfx::PaintingSurface::try_create_with_size(
raster_candidate_rect.size(), Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied, m_skia_backend_context);
if (offscreen_surface_or_error.is_error()) {
- raster_cache().finish_nested_display_list_raster(display_list_id, m_skia_backend_context, raster_candidate_rect, nullptr);
+ raster_cache().finish_vector_image_raster(vector_image_id, m_skia_backend_context, raster_candidate_rect, nullptr);
} else {
auto offscreen_surface = offscreen_surface_or_error.release_value();
offscreen_surface->canvas().clear(SK_ColorTRANSPARENT);
offscreen_surface->canvas().translate(-raster_candidate_rect.x(), -raster_candidate_rect.y());
m_surfaces.append(offscreen_surface);
- m_raster_state->nested_display_lists_in_progress.append({
- .replay = RustFFI::NestedDisplayListReplay::IntoRaster,
- .display_list_id = display_list_id,
- .raster_rect_in_list_space = raster_candidate_rect,
- .visible_rect_in_list_space = visible_rect_in_list_space,
+ m_raster_state->vector_images_in_progress.append({
+ .replay = RustFFI::VectorImageReplay::IntoRaster,
+ .vector_image_id = vector_image_id,
+ .raster_rect_in_recorded_space = raster_candidate_rect,
+ .visible_rect_in_recorded_space = visible_rect_in_recorded_space,
.placement = placement,
.draws_pixel_exact = draws_pixel_exact,
});
- return RustFFI::NestedDisplayListReplay::IntoRaster;
+ return RustFFI::VectorImageReplay::IntoRaster;
}
}
}
@@ -1489,39 +1490,39 @@ RustFFI::NestedDisplayListReplay DisplayListPlayerSkia::begin_nested_display_lis
// leaves single-pixel antialiasing slivers along edges meant to be pixel-exact. The snapped
// placement replaces the canvas matrix outright so no further float composition disturbs it.
if (auto device_rect = total_matrix.mapRect(to_skia_rect(command.rect));
- total_matrix.isScaleTranslate() && total_matrix.getScaleX() > 0 && total_matrix.getScaleY() > 0 && !list_bounds.is_empty()
+ total_matrix.isScaleTranslate() && total_matrix.getScaleX() > 0 && total_matrix.getScaleY() > 0 && !recorded_bounds.is_empty()
&& roundf(device_rect.right()) > roundf(device_rect.left()) && roundf(device_rect.bottom()) > roundf(device_rect.top())) {
auto snapped_device_rect = SkRect::MakeLTRB(
roundf(device_rect.left()), roundf(device_rect.top()), roundf(device_rect.right()), roundf(device_rect.bottom()));
- canvas.setMatrix(SkMatrix::RectToRect(SkRect::MakeWH(command.list_size.width(), command.list_size.height()), snapped_device_rect));
- canvas.clipRect(SkRect::MakeWH(command.list_size.width(), command.list_size.height()));
+ canvas.setMatrix(SkMatrix::RectToRect(SkRect::MakeWH(command.recorded_size.width(), command.recorded_size.height()), snapped_device_rect));
+ canvas.clipRect(SkRect::MakeWH(command.recorded_size.width(), command.recorded_size.height()));
} else {
canvas.clipRect(to_skia_rect(command.rect));
canvas.translate(command.rect.x(), command.rect.y());
- if (!list_bounds.is_empty() && !command.rect.is_empty())
- canvas.scale(command.rect.width() / command.list_size.width(), command.rect.height() / command.list_size.height());
+ if (!recorded_bounds.is_empty() && !command.rect.is_empty())
+ canvas.scale(command.rect.width() / command.recorded_size.width(), command.rect.height() / command.recorded_size.height());
}
- m_raster_state->nested_display_lists_in_progress.append({ .replay = RustFFI::NestedDisplayListReplay::Directly });
- return RustFFI::NestedDisplayListReplay::Directly;
+ m_raster_state->vector_images_in_progress.append({ .replay = RustFFI::VectorImageReplay::Directly });
+ return RustFFI::VectorImageReplay::Directly;
}
-void DisplayListPlayerSkia::end_nested_display_list()
+void DisplayListPlayerSkia::end_vector_image()
{
- auto nested = m_raster_state->nested_display_lists_in_progress.take_last();
- if (nested.replay == RustFFI::NestedDisplayListReplay::Directly) {
+ auto vector_image = m_raster_state->vector_images_in_progress.take_last();
+ if (vector_image.replay == RustFFI::VectorImageReplay::Directly) {
surface().canvas().restore();
return;
}
- VERIFY(nested.replay == RustFFI::NestedDisplayListReplay::IntoRaster);
+ VERIFY(vector_image.replay == RustFFI::VectorImageReplay::IntoRaster);
auto offscreen_surface = m_surfaces.take_last();
offscreen_surface->canvas().resetMatrix();
- auto image = raster_cache().finish_nested_display_list_raster(nested.display_list_id, m_skia_backend_context, nested.raster_rect_in_list_space, offscreen_surface->sk_surface().makeImageSnapshot());
+ auto image = raster_cache().finish_vector_image_raster(vector_image.vector_image_id, m_skia_backend_context, vector_image.raster_rect_in_recorded_space, offscreen_surface->sk_surface().makeImageSnapshot());
if (!image)
return;
auto& canvas = surface().canvas();
- auto source_rect = nested.visible_rect_in_list_space.translated(-nested.raster_rect_in_list_space.location());
- auto destination_rect = nested.placement.mapRect(to_skia_rect(nested.visible_rect_in_list_space));
- auto sampling = nested.draws_pixel_exact ? SkSamplingOptions() : SkSamplingOptions(SkFilterMode::kLinear);
+ auto source_rect = vector_image.visible_rect_in_recorded_space.translated(-vector_image.raster_rect_in_recorded_space.location());
+ auto destination_rect = vector_image.placement.mapRect(to_skia_rect(vector_image.visible_rect_in_recorded_space));
+ auto sampling = vector_image.draws_pixel_exact ? SkSamplingOptions() : SkSamplingOptions(SkFilterMode::kLinear);
canvas.save();
canvas.setMatrix(SkMatrix::I());
canvas.drawImageRect(image.get(), to_skia_rect(source_rect), destination_rect, sampling, nullptr, SkCanvas::kStrict_SrcRectConstraint);
diff --git a/Services/Compositor/DisplayListPlayerSkia.h b/Services/Compositor/DisplayListPlayerSkia.h
index ca6af75e2ee..90f461453e7 100644
--- a/Services/Compositor/DisplayListPlayerSkia.h
+++ b/Services/Compositor/DisplayListPlayerSkia.h
@@ -111,8 +111,8 @@ private:
void end_isolated_group();
bool begin_tile_raster(Compositing::RustFFI::TileRaster const&);
void end_tile_raster();
- Compositing::RustFFI::NestedDisplayListReplay begin_nested_display_list(Compositing::RustFFI::NestedDisplayListPlacement const&, bool requires_direct_replay);
- void end_nested_display_list();
+ Compositing::RustFFI::VectorImageReplay begin_vector_image(Compositing::RustFFI::VectorImagePlacement const&, bool requires_direct_replay);
+ void end_vector_image();
void clip_path(SkPath, Gfx::WindingRule, bool anti_aliased);
@@ -126,7 +126,7 @@ private:
RefPtr<Gfx::SkiaBackendContext> m_skia_backend_context;
- // The surface painted into last, which a tile or nested display list raster stacks on top of the target.
+ // The surface painted into last, which a tile or vector image raster stacks on top of the target.
Vector<NonnullRefPtr<Gfx::PaintingSurface>, 4> m_surfaces;
Compositing::DisplayListResourceStorage const* m_resource_storage { nullptr };
DisplayListRasterCache* m_raster_cache { nullptr };
@@ -134,7 +134,7 @@ private:
CurrentVideoFrame m_current_video_frame;
ReadonlyBytes m_current_command_payload;
- // The tile and nested display list rasters the painter replays into, which hold Skia objects.
+ // The tile and vector image rasters the painter replays into, which hold Skia objects.
struct RasterState;
NonnullOwnPtr<RasterState> m_raster_state;
};
diff --git a/Services/Compositor/DisplayListRasterCache.cpp b/Services/Compositor/DisplayListRasterCache.cpp
index 8b187509582..d9e3bb7c713 100644
--- a/Services/Compositor/DisplayListRasterCache.cpp
+++ b/Services/Compositor/DisplayListRasterCache.cpp
@@ -124,20 +124,20 @@ struct DisplayListRasterCache::RepeatedTileRaster {
sk_sp<SkImage> image;
};
-struct DisplayListRasterCache::NestedDisplayListRasters {
+struct DisplayListRasterCache::VectorImageRasters {
AK_ALLOC_WITH_KMALLOC;
- explicit NestedDisplayListRasters(RefPtr<Gfx::SkiaBackendContext> skia_backend_context)
+ explicit VectorImageRasters(RefPtr<Gfx::SkiaBackendContext> skia_backend_context)
: skia_backend_context(move(skia_backend_context))
{
}
struct Raster {
- Gfx::IntRect rect_in_list_space;
+ Gfx::IntRect rect_in_recorded_space;
sk_sp<SkImage> image;
MonotonicTime last_used { MonotonicTime::now() };
- size_t byte_size() const { return static_cast<size_t>(rect_in_list_space.width()) * rect_in_list_space.height() * 4; }
+ size_t byte_size() const { return static_cast<size_t>(rect_in_recorded_space.width()) * rect_in_recorded_space.height() * 4; }
};
size_t total_byte_size() const
@@ -150,8 +150,8 @@ struct DisplayListRasterCache::NestedDisplayListRasters {
RefPtr<Gfx::SkiaBackendContext> skia_backend_context;
- // The same display list can be painted at several places in one frame (repeated SVG images, atlas-style
- // lists painted in many small slices), each with its own visible sub-rectangle, so a single list keeps a
+ // The same image can be painted at several places in one frame (repeated SVG images, atlas-style images
+ // painted in many small slices), each with its own visible sub-rectangle, so a single image keeps a
// bounded set of rasters, most recently used first.
static constexpr size_t max_rasters = 32;
Vector<Raster> rasters;
@@ -195,8 +195,8 @@ void DisplayListRasterCache::evict(DisplayListResourceSet const& removed_resourc
m_layer_image_filter_cache = nullptr;
for (auto id : removed_resources.image_frames)
m_image_frame_images.remove(id.value());
- for (auto id : removed_resources.display_lists)
- m_nested_display_list_rasters.remove(id.value());
+ for (auto id : removed_resources.vector_images)
+ m_vector_image_rasters.remove(id.value());
if (!removed_resources.fonts.is_empty()) {
m_text_blobs.remove_all_matching([&](auto const& key, auto const& text_blob) {
if (!removed_resources.fonts.contains(FontResourceId { key.font_id }))
@@ -339,10 +339,10 @@ void DisplayListRasterCache::add_repeated_tile_raster(u64 tile_key, Gfx::IntSize
m_repeated_tile_rasters.set(tile_key, move(raster));
}
-sk_sp<SkImage> DisplayListRasterCache::nested_display_list_raster(DisplayListResourceId id, RefPtr<Gfx::SkiaBackendContext> const& skia_backend_context, Gfx::IntRect visible_rect_in_list_space, Gfx::IntRect& raster_rect_in_list_space)
+sk_sp<SkImage> DisplayListRasterCache::vector_image_raster(DisplayListResourceId id, RefPtr<Gfx::SkiaBackendContext> const& skia_backend_context, Gfx::IntRect visible_rect_in_recorded_space, Gfx::IntRect& raster_rect_in_recorded_space)
{
- auto cached_rasters = m_nested_display_list_rasters.find(id.value());
- if (cached_rasters == m_nested_display_list_rasters.end())
+ auto cached_rasters = m_vector_image_rasters.find(id.value());
+ if (cached_rasters == m_vector_image_rasters.end())
return nullptr;
auto& rasters = *cached_rasters->value;
@@ -350,7 +350,7 @@ sk_sp<SkImage> DisplayListRasterCache::nested_display_list_raster(DisplayListRes
return nullptr;
for (size_t i = 0; i < rasters.rasters.size(); ++i) {
- if (!rasters.rasters[i].rect_in_list_space.contains(visible_rect_in_list_space))
+ if (!rasters.rasters[i].rect_in_recorded_space.contains(visible_rect_in_recorded_space))
continue;
if (i != 0) {
auto raster = move(rasters.rasters[i]);
@@ -358,21 +358,21 @@ sk_sp<SkImage> DisplayListRasterCache::nested_display_list_raster(DisplayListRes
rasters.rasters.prepend(move(raster));
}
rasters.rasters.first().last_used = MonotonicTime::now();
- raster_rect_in_list_space = rasters.rasters.first().rect_in_list_space;
+ raster_rect_in_recorded_space = rasters.rasters.first().rect_in_recorded_space;
return rasters.rasters.first().image;
}
return {};
}
-bool DisplayListRasterCache::has_rasterized_nested_display_list(DisplayListResourceId id) const
+bool DisplayListRasterCache::has_rasterized_vector_image(DisplayListResourceId id) const
{
- return m_nested_display_list_rasters.contains(id.value());
+ return m_vector_image_rasters.contains(id.value());
}
-bool DisplayListRasterCache::reserve_nested_display_list_raster(DisplayListResourceId id, RefPtr<Gfx::SkiaBackendContext> const& skia_backend_context, Gfx::IntRect rect_in_list_space)
+bool DisplayListRasterCache::reserve_vector_image_raster(DisplayListResourceId id, RefPtr<Gfx::SkiaBackendContext> const& skia_backend_context, Gfx::IntRect rect_in_recorded_space)
{
- auto& rasters = *m_nested_display_list_rasters.ensure(id.value(), [&] {
- return make<NestedDisplayListRasters>(skia_backend_context);
+ auto& rasters = *m_vector_image_rasters.ensure(id.value(), [&] {
+ return make<VectorImageRasters>(skia_backend_context);
});
if (rasters.skia_backend_context.ptr() != skia_backend_context.ptr()) {
@@ -385,14 +385,14 @@ bool DisplayListRasterCache::reserve_nested_display_list_raster(DisplayListResou
// caching this raster instead of evicting hot entries, so an oversized page degrades to direct replay for
// the overflow instead of thrashing the whole cache. Additions are rare by design, so the total is simply
// recomputed here instead of being tracked incrementally.
- constexpr size_t max_nested_raster_cache_bytes = 512 * MiB;
- auto raster_bytes = static_cast<size_t>(rect_in_list_space.width()) * rect_in_list_space.height() * 4;
- auto total_bytes = raster_bytes + m_nested_raster_cache_reserved_bytes;
- for (auto const& it : m_nested_display_list_rasters)
+ constexpr size_t max_vector_image_raster_cache_bytes = 512 * MiB;
+ auto raster_bytes = static_cast<size_t>(rect_in_recorded_space.width()) * rect_in_recorded_space.height() * 4;
+ auto total_bytes = raster_bytes + m_vector_image_raster_cache_reserved_bytes;
+ for (auto const& it : m_vector_image_rasters)
total_bytes += it.value->total_byte_size();
- if (total_bytes > max_nested_raster_cache_bytes) {
+ if (total_bytes > max_vector_image_raster_cache_bytes) {
auto now = MonotonicTime::now();
- for (auto& it : m_nested_display_list_rasters) {
+ for (auto& it : m_vector_image_rasters) {
it.value->rasters.remove_all_matching([&](auto const& raster) {
if (now - raster.last_used < AK::Duration::from_milliseconds(250))
return false;
@@ -400,32 +400,32 @@ bool DisplayListRasterCache::reserve_nested_display_list_raster(DisplayListResou
return true;
});
}
- if (total_bytes > max_nested_raster_cache_bytes)
+ if (total_bytes > max_vector_image_raster_cache_bytes)
return false;
}
- // Reserve before rasterizing: a nested list can create other cached rasters while it is painted.
- m_nested_raster_cache_reserved_bytes += raster_bytes;
+ // Reserve before rasterizing: the records of an image can create other cached rasters while they are painted.
+ m_vector_image_raster_cache_reserved_bytes += raster_bytes;
return true;
}
-sk_sp<SkImage> DisplayListRasterCache::finish_nested_display_list_raster(DisplayListResourceId id, RefPtr<Gfx::SkiaBackendContext> const& skia_backend_context, Gfx::IntRect rect_in_list_space, sk_sp<SkImage> image)
+sk_sp<SkImage> DisplayListRasterCache::finish_vector_image_raster(DisplayListResourceId id, RefPtr<Gfx::SkiaBackendContext> const& skia_backend_context, Gfx::IntRect rect_in_recorded_space, sk_sp<SkImage> image)
{
- auto raster_bytes = static_cast<size_t>(rect_in_list_space.width()) * rect_in_list_space.height() * 4;
- m_nested_raster_cache_reserved_bytes -= raster_bytes;
+ auto raster_bytes = static_cast<size_t>(rect_in_recorded_space.width()) * rect_in_recorded_space.height() * 4;
+ m_vector_image_raster_cache_reserved_bytes -= raster_bytes;
if (!image)
return {};
- auto& rasters = *m_nested_display_list_rasters.ensure(id.value(), [&] {
- return make<NestedDisplayListRasters>(skia_backend_context);
+ auto& rasters = *m_vector_image_rasters.ensure(id.value(), [&] {
+ return make<VectorImageRasters>(skia_backend_context);
});
if (rasters.skia_backend_context.ptr() != skia_backend_context.ptr()) {
rasters.rasters.clear();
rasters.skia_backend_context = skia_backend_context;
}
- if (rasters.rasters.size() == NestedDisplayListRasters::max_rasters)
+ if (rasters.rasters.size() == VectorImageRasters::max_rasters)
rasters.rasters.take_last();
- rasters.rasters.prepend({ rect_in_list_space, image });
+ rasters.rasters.prepend({ rect_in_recorded_space, image });
return image;
}
diff --git a/Services/Compositor/DisplayListRasterCache.h b/Services/Compositor/DisplayListRasterCache.h
index 67a45ddf8e5..2f19e80bcc8 100644
--- a/Services/Compositor/DisplayListRasterCache.h
+++ b/Services/Compositor/DisplayListRasterCache.h
@@ -85,13 +85,13 @@ public:
sk_sp<SkImage> image_for_video_sink(Media::VideoSinkHandle, Media::VideoFrame const&, RefPtr<Gfx::SkiaBackendContext> const&, Gfx::IntSize& visible_size);
sk_sp<SkImage> repeated_tile_raster(u64 tile_key, Gfx::IntSize, RefPtr<Gfx::SkiaBackendContext> const&) const;
void add_repeated_tile_raster(u64 tile_key, Gfx::IntSize, RefPtr<Gfx::SkiaBackendContext> const&, sk_sp<SkImage>);
- sk_sp<SkImage> nested_display_list_raster(Compositing::DisplayListResourceId, RefPtr<Gfx::SkiaBackendContext> const&, Gfx::IntRect visible_rect_in_list_space, Gfx::IntRect& raster_rect_in_list_space);
- bool has_rasterized_nested_display_list(Compositing::DisplayListResourceId) const;
- // Makes room for a raster of the list, which then counts against the budget until it is finished, and answers false
+ sk_sp<SkImage> vector_image_raster(Compositing::DisplayListResourceId, RefPtr<Gfx::SkiaBackendContext> const&, Gfx::IntRect visible_rect_in_recorded_space, Gfx::IntRect& raster_rect_in_recorded_space);
+ bool has_rasterized_vector_image(Compositing::DisplayListResourceId) const;
+ // Makes room for a raster of the image, which then counts against the budget until it is finished, and answers false
// where the rasters in use leave no room for it.
- bool reserve_nested_display_list_raster(Compositing::DisplayListResourceId, RefPtr<Gfx::SkiaBackendContext> const&, Gfx::IntRect rect_in_list_space);
+ bool reserve_vector_image_raster(Compositing::DisplayListResourceId, RefPtr<Gfx::SkiaBackendContext> const&, Gfx::IntRect rect_in_recorded_space);
// Keeps the raster that was reserved, unless it could not be made.
- sk_sp<SkImage> finish_nested_display_list_raster(Compositing::DisplayListResourceId, RefPtr<Gfx::SkiaBackendContext> const&, Gfx::IntRect rect_in_list_space, sk_sp<SkImage>);
+ sk_sp<SkImage> finish_vector_image_raster(Compositing::DisplayListResourceId, RefPtr<Gfx::SkiaBackendContext> const&, Gfx::IntRect rect_in_recorded_space, sk_sp<SkImage>);
sk_sp<SkTextBlob> text_blob(Compositing::DisplayListResourceStorage const&, Compositing::FontResourceId, float scale, ReadonlySpan<Compositing::DisplayListGlyph>, u8 font_smoothing);
sk_sp<SkImageFilter> layer_image_filter(Compositing::ReplayLayer const&, Function<sk_sp<SkImageFilter>()> const& create);
@@ -107,7 +107,7 @@ private:
struct ImageFrameImage;
struct VideoSinkImage;
struct RepeatedTileRaster;
- struct NestedDisplayListRasters;
+ struct VectorImageRasters;
struct TextBlob;
struct ClipPath;
struct LayerImageFilterCache;
@@ -119,8 +119,8 @@ private:
HashMap<u64, NonnullOwnPtr<VideoSinkImage>> m_video_sink_images;
HashMap<u64, NonnullOwnPtr<RepeatedTileRaster>> m_repeated_tile_rasters;
size_t m_repeated_tile_raster_bytes { 0 };
- HashMap<u64, NonnullOwnPtr<NestedDisplayListRasters>> m_nested_display_list_rasters;
- size_t m_nested_raster_cache_reserved_bytes { 0 };
+ HashMap<u64, NonnullOwnPtr<VectorImageRasters>> m_vector_image_rasters;
+ size_t m_vector_image_raster_cache_reserved_bytes { 0 };
HashMap<TextBlobCacheKey, NonnullOwnPtr<TextBlob>> m_text_blobs;
size_t m_text_blob_cache_bytes { 0 };
MonotonicTime m_text_blob_cache_sweep_time { MonotonicTime::now() };
diff --git a/Services/Compositor/Rust/src/context_state/mod.rs b/Services/Compositor/Rust/src/context_state/mod.rs
index cda27ae4ea7..d7c93047ad6 100644
--- a/Services/Compositor/Rust/src/context_state/mod.rs
+++ b/Services/Compositor/Rust/src/context_state/mod.rs
@@ -19,7 +19,6 @@ use crate::frame_inputs::FrameInputs;
use crate::host::{ContextTimer, Host, PendingFrame, PresentationId, WebContentClientId};
use crate::input_event::is_keyboard_scroll_key;
use crate::keyboard_scroll_controller::{KeyRelease, KeyStep, KeyboardScrollController};
-use crate::nested_display_lists::NestedDisplayListStore;
use crate::overlays::{ContextOverlays, UIOverlays};
use crate::scroll_fling_controller::ScrollFlingController;
use crate::scroll_snap_controller::{ScrollSnapController, SnapScrollStart, StepDecision};
@@ -300,8 +299,6 @@ pub struct ContextState {
parent_context_id: Option<CompositorContextId>,
scene: ContextScene,
- // Shared with the frames painted with it, so a change makes a store of its own.
- nested_display_lists: Rc<NestedDisplayListStore>,
presents_to_client: bool,
viewport_size: IntSize,
device_pixel_ratio: f64,
@@ -402,7 +399,6 @@ impl ContextState {
bound_presentation: Default::default(),
parent_context_id: Default::default(),
scene: Default::default(),
- nested_display_lists: Default::default(),
presents_to_client: page_id.is_some(),
viewport_size: Default::default(),
device_pixel_ratio: 1.0,
@@ -463,18 +459,10 @@ impl ContextState {
pub fn display_list(&self) -> Option<Rc<DisplayList>> {
self.scene.display_list().clone()
}
- pub fn nested_display_lists(&self) -> Rc<NestedDisplayListStore> {
- self.nested_display_lists.clone()
- }
- pub fn nested_display_lists_mut(&mut self) -> &mut NestedDisplayListStore {
- Rc::make_mut(&mut self.nested_display_lists)
- }
- /// The handles of the video sinks that the display list and the lists it nests draw.
+ /// The handles of the video sinks that the display list draws.
pub fn video_sink_handles_drawn(&self) -> Vec<u64> {
match self.scene.display_list() {
- Some(display_list) => self
- .nested_display_lists
- .video_sink_handles_drawn_by(display_list.storage()),
+ Some(display_list) => display_list.storage().summary().video_sink_handles.clone(),
None => Vec::new(),
}
}
diff --git a/Services/Compositor/Rust/src/core/messages.rs b/Services/Compositor/Rust/src/core/messages.rs
index 750354becb1..616644af68e 100644
--- a/Services/Compositor/Rust/src/core/messages.rs
+++ b/Services/Compositor/Rust/src/core/messages.rs
@@ -9,7 +9,6 @@
use super::{CompositorCore, ContextOwnerCheckResult};
use crate::host::{PresentationId, WebContentClientId};
-use crate::nested_display_lists::{NestedDisplayListStore, ReferencedResources};
use libcompositing_rust::display_list::replay::{ReplayFrame, ReplaySelection, replay_display_list};
use libcompositing_rust::ipc_types::compositor_presentation_client::messages::DidNotDispatchInputEvent;
use libcompositing_rust::ipc_types::compositor_presentation_server::messages::{
@@ -50,7 +49,6 @@ fn display_list_timing_enabled() -> bool {
})
}
-const NESTED_DISPLAY_LISTS_THAT_NEST_THEMSELVES: &str = "WebContent published display lists that nest themselves";
const DISPLAY_LIST_WITH_UNUSABLE_SCROLLING_STATE: &str =
"WebContent published a display list with scrolling state the compositor cannot use";
@@ -235,37 +233,21 @@ impl MessagesFromWebContent<'_> {
));
}
};
- let transaction = message.nested_display_lists;
- if transaction.removes_anything() {
- return not_rasterized("Resource transaction holds more than the display lists it nests");
- }
- let mut nested_display_lists = NestedDisplayListStore::default();
- for display_list in transaction.display_lists {
- nested_display_lists.add(display_list);
- }
let tree = message.visual_context_tree;
if properties.compatible_visual_context_tree_structural_epoch != tree.structural_epoch
|| !tree.display_list_references_only_live_nodes(storage.command_runs())
{
return not_rasterized("Display list does not match its visual context tree");
}
- let mut resources = ReferencedResources::default();
- nested_display_lists.collect_referenced_resources(&storage, &tree, &mut resources);
- if !nested_display_lists.nested_display_lists_are_replayable(&resources) {
- return not_rasterized("Nested display list is missing or refers to itself");
- }
- let ids = |set: &std::collections::HashSet<u64>| set.iter().copied().collect::<Vec<u64>>();
- if !raster.staged_rasterization_has_resources(
- client,
- token,
- &ids(&resources.font_ids),
- &ids(&resources.image_frame_ids),
- ) {
+ let summary = storage.summary();
+ let mut image_frame_ids = summary.image_frame_ids.clone();
+ tree.for_each_effects_filter_image_frame_id(&mut |id| image_frame_ids.push(id));
+ if !raster.staged_rasterization_has_resources(client, token, &summary.font_ids, &image_frame_ids) {
return not_rasterized("Display list draws resources that were not staged for it");
}
let time_ns = self.now.nanoseconds();
let success = raster.rasterize_staged(client, token, |painter| {
- let frame = ReplayFrame::unscrolled(time_ns, &nested_display_lists);
+ let frame = ReplayFrame::unscrolled(time_ns);
replay_display_list(
&tree,
storage.bytes(),
@@ -346,12 +328,8 @@ impl compositor_web_content_server::Stub for MessagesFromWebContent<'_> {
) {
return Err(Misbehavior(DISPLAY_LIST_WITH_UNUSABLE_SCROLLING_STATE));
}
- if !self
- .core
- .apply_resource_transaction(message.context_id, message.resource_transaction)
- {
- return Err(Misbehavior(NESTED_DISPLAY_LISTS_THAT_NEST_THEMSELVES));
- }
+ self.core
+ .apply_resource_transaction(message.context_id, message.resource_transaction);
if display_list_timing_enabled() {
let _ = writeln!(
std::io::stderr(),
@@ -381,12 +359,9 @@ impl compositor_web_content_server::Stub for MessagesFromWebContent<'_> {
message.keyboard_scroll_state,
self.now,
);
- if tree_was_replaced
- && !self
- .core
- .apply_resource_transaction(message.context_id, message.resource_transaction)
- {
- return Err(Misbehavior(NESTED_DISPLAY_LISTS_THAT_NEST_THEMSELVES));
+ if tree_was_replaced {
+ self.core
+ .apply_resource_transaction(message.context_id, message.resource_transaction);
}
Ok(())
}
diff --git a/Services/Compositor/Rust/src/core/mod.rs b/Services/Compositor/Rust/src/core/mod.rs
index 2fb700224b9..fa0b25d213e 100644
--- a/Services/Compositor/Rust/src/core/mod.rs
+++ b/Services/Compositor/Rust/src/core/mod.rs
@@ -690,43 +690,30 @@ impl CompositorCore {
installed
}
- /// Adds and removes the resources that a display list or a visual context tree that the context took comes with,
- /// and tells the host which video sinks the context draws with them. Answers false, changing nothing, for display
- /// lists that would nest themselves.
+ /// Removes the resources that a display list or a visual context tree that the context took no longer draws, and
+ /// tells the host which video sinks the context draws with them.
pub fn apply_resource_transaction(
&self,
context_id: CompositorContextId,
transaction: Compositing_DisplayListResourceTransaction,
- ) -> bool {
+ ) {
let _entered = self.enter();
let Some(context) = self.context_if_present(context_id) else {
- return true;
+ return;
};
- let removes_resources_held_by_the_host = transaction.removes_anything();
- if !transaction.display_lists.is_empty() || !transaction.display_list_ids_to_remove.is_empty() {
- let mut context = context.borrow_mut();
- let nested_display_lists = context.nested_display_lists_mut();
- if !nested_display_lists.add_all(transaction.display_lists) {
- return false;
- }
- for &display_list_id in &transaction.display_list_ids_to_remove {
- nested_display_lists.remove(display_list_id);
- }
- }
- if removes_resources_held_by_the_host {
+ if transaction.removes_anything() {
self.raster.apply_resource_changes(
context_id,
&FfiResourceChanges {
font_ids_to_remove: ak::Span::new(&transaction.font_ids_to_remove),
image_frame_ids_to_remove: ak::Span::new(&transaction.image_frame_ids_to_remove),
- display_list_ids_to_remove: ak::Span::new(&transaction.display_list_ids_to_remove),
+ vector_image_ids_to_remove: ak::Span::new(&transaction.vector_image_ids_to_remove),
},
);
}
let video_sink_handles = context.borrow().video_sink_handles_drawn();
self.raster.set_drawn_video_sinks(context_id, &video_sink_handles);
- true
}
// Returns false for a tree that does not fit the installed display list, of which only the scroll state is taken.
diff --git a/Services/Compositor/Rust/src/core/presenting.rs b/Services/Compositor/Rust/src/core/presenting.rs
index dfaa5f7784a..6803b90cda0 100644
--- a/Services/Compositor/Rust/src/core/presenting.rs
+++ b/Services/Compositor/Rust/src/core/presenting.rs
@@ -385,13 +385,9 @@ impl CompositorCore {
let mut child_presenting = self.presenting_of(child_context_id)?.try_borrow_mut().ok()?;
child_presenting.update_composited_raster_transform(destination_rect, canvas_matrix);
if child_presenting.needs_rasterization() {
- let (display_list, nested_display_lists, frame_inputs) = {
+ let (display_list, frame_inputs) = {
let mut child_state = child_state.try_borrow_mut().ok()?;
- (
- child_state.display_list(),
- child_state.nested_display_lists(),
- child_state.frame_inputs(now),
- )
+ (child_state.display_list(), child_state.frame_inputs(now))
};
let nested_contexts = ContextsNestedIn {
core: self,
@@ -399,12 +395,7 @@ impl CompositorCore {
now,
};
let environment = self.environment(child_context_id, now, &nested_contexts);
- child_presenting.paint_frame_drawn_by_parent(
- &environment,
- display_list.as_ref(),
- &nested_display_lists,
- frame_inputs,
- );
+ child_presenting.paint_frame_drawn_by_parent(&environment, display_list.as_ref(), frame_inputs);
}
child_presenting.composited_surface()
}
@@ -421,11 +412,10 @@ impl CompositorCore {
let Some(presenting) = self.presenting_of(context_id) else {
return;
};
- let (display_list, nested_display_lists, frame_inputs, bound_presentation) = {
+ let (display_list, frame_inputs, bound_presentation) = {
let mut context = context.borrow_mut();
(
context.display_list(),
- context.nested_display_lists(),
context.frame_inputs(now),
context.bound_presentation(),
)
@@ -437,13 +427,9 @@ impl CompositorCore {
};
let environment = self.environment(context_id, now, &nested_contexts);
let mut presenting = presenting.borrow_mut();
- let Some(prepared_frame) = presenting.prepare_frame(
- &environment,
- pending_frame,
- display_list.as_ref(),
- &nested_display_lists,
- frame_inputs,
- ) else {
+ let Some(prepared_frame) =
+ presenting.prepare_frame(&environment, pending_frame, display_list.as_ref(), frame_inputs)
+ else {
return;
};
@@ -1140,7 +1126,6 @@ impl CompositorCore {
let Some(display_list) = context.borrow().display_list() else {
return false;
};
- let nested_display_lists = context.borrow().nested_display_lists();
let screenshot_inputs = context.borrow_mut().frame_inputs_for_screenshot(now);
let nested_contexts = ContextsNestedIn {
core: self,
@@ -1148,13 +1133,9 @@ impl CompositorCore {
now,
};
let environment = self.environment(context_id, now, &nested_contexts);
- presenting.borrow_mut().paint_screenshot(
- &environment,
- target,
- &display_list,
- &nested_display_lists,
- &screenshot_inputs.frame_inputs,
- );
+ presenting
+ .borrow_mut()
+ .paint_screenshot(&environment, target, &display_list, &screenshot_inputs.frame_inputs);
if !screenshot_inputs.scrollbar_fade_damage_rect.is_empty() {
let viewport_rect = presenting.borrow().viewport_rect_of_current_frame();
if let Some(viewport_rect) = viewport_rect {
diff --git a/Services/Compositor/Rust/src/lib.rs b/Services/Compositor/Rust/src/lib.rs
index bbba0f8a028..d90cb049e23 100644
--- a/Services/Compositor/Rust/src/lib.rs
+++ b/Services/Compositor/Rust/src/lib.rs
@@ -25,7 +25,6 @@ pub mod frame_inputs;
pub mod host;
pub mod input_event;
pub mod keyboard_scroll_controller;
-pub mod nested_display_lists;
pub mod overlays;
pub mod presenting;
pub mod raster_host;
diff --git a/Services/Compositor/Rust/src/nested_display_lists.rs b/Services/Compositor/Rust/src/nested_display_lists.rs
deleted file mode 100644
index 499588c6a0d..00000000000
--- a/Services/Compositor/Rust/src/nested_display_lists.rs
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-//! The display lists that the display lists of a context nest, such as those of its SVG images, which the replays of
-//! its frames draw.
-
-use libcompositing_rust::display_list::replay::{NestedDisplayList, NestedDisplayLists};
-use libcompositing_rust::display_list::storage::DisplayListStorage;
-use libcompositing_rust::display_list::summary::{DisplayListSummary, requires_direct_replay_without_nested_lists};
-use libcompositing_rust::ipc_types::NestedDisplayListResource;
-use libcompositing_rust::visual_context::VisualContextTree;
-use libgfx_rust::Color;
-use std::cell::RefCell;
-use std::collections::{HashMap, HashSet};
-use std::sync::Arc;
-
-#[derive(Clone)]
-struct StoredDisplayList {
- storage: Arc<DisplayListStorage>,
- tree: Arc<VisualContextTree>,
- root_group_color: Color,
-}
-
-/// The fonts and image frames that a display list draws, with those of the lists it nests, and the lists it nests.
-#[derive(Default)]
-pub struct ReferencedResources {
- pub font_ids: HashSet<u64>,
- pub image_frame_ids: HashSet<u64>,
- pub display_list_ids: HashSet<u64>,
-}
-
-#[derive(Clone, Default)]
-pub struct NestedDisplayListStore {
- display_lists: HashMap<u64, StoredDisplayList>,
- // Whether a raster of a list can differ from replaying it, which is intrinsic to the list and the lists it nests.
- requires_direct_replay: RefCell<HashMap<u64, bool>>,
-}
-
-impl NestedDisplayListStore {
- /// A list that the store holds already keeps the tape it was added with.
- pub fn add(&mut self, resource: NestedDisplayListResource) {
- if self.display_lists.contains_key(&resource.properties.id) {
- return;
- }
- self.display_lists.insert(
- resource.properties.id,
- StoredDisplayList {
- storage: resource.storage,
- tree: resource.tree,
- root_group_color: resource.properties.root_group_color,
- },
- );
- self.requires_direct_replay.get_mut().clear();
- }
-
- /// Adds the lists, answering false, with none of them added, where one of them would reach itself, as replay follows
- /// nested lists with no depth limit.
- pub fn add_all(&mut self, resources: Vec<NestedDisplayListResource>) -> bool {
- let mut added = Vec::new();
- for resource in resources {
- let display_list_id = resource.properties.id;
- if self.display_lists.contains_key(&display_list_id) {
- continue;
- }
- self.add(resource);
- added.push(display_list_id);
- }
- // NB: A list held already does not reach itself, so only a new list can close a loop.
- if !added
- .iter()
- .any(|&display_list_id| self.reaches_itself(display_list_id))
- {
- return true;
- }
- for display_list_id in added {
- self.remove(display_list_id);
- }
- false
- }
-
- fn reaches_itself(&self, display_list_id: u64) -> bool {
- let stored = &self.display_lists[&display_list_id];
- let mut reached = ReferencedResources::default();
- self.collect_referenced_resources(&stored.storage, &stored.tree, &mut reached);
- reached.display_list_ids.contains(&display_list_id)
- }
-
- pub fn remove(&mut self, display_list_id: u64) {
- if self.display_lists.remove(&display_list_id).is_some() {
- self.requires_direct_replay.get_mut().clear();
- }
- }
-
- pub fn contains(&self, display_list_id: u64) -> bool {
- self.display_lists.contains_key(&display_list_id)
- }
-
- /// Adds what the list draws, and what the lists it nests that the store holds draw.
- pub fn collect_referenced_resources(
- &self,
- storage: &DisplayListStorage,
- tree: &VisualContextTree,
- resources: &mut ReferencedResources,
- ) {
- let summary = storage.summary();
- resources.font_ids.extend(&summary.font_ids);
- resources.image_frame_ids.extend(&summary.image_frame_ids);
- tree.for_each_effects_filter_image_frame_id(&mut |id| {
- resources.image_frame_ids.insert(id);
- });
- for &display_list_id in &summary.display_list_ids {
- if !resources.display_list_ids.insert(display_list_id) {
- continue;
- }
- if let Some(nested) = self.display_lists.get(&display_list_id) {
- self.collect_referenced_resources(&nested.storage, &nested.tree, resources);
- }
- }
- }
-
- /// Whether the lists that a list nests are all held, and none of them reaches itself, as replay follows nested lists
- /// with no depth limit.
- pub fn nested_display_lists_are_replayable(&self, resources: &ReferencedResources) -> bool {
- resources.display_list_ids.iter().all(|&display_list_id| {
- self.display_lists.contains_key(&display_list_id) && !self.reaches_itself(display_list_id)
- })
- }
-
- fn for_each_summary_of_nested_display_lists(
- &self,
- storage: &DisplayListStorage,
- mut visit: impl FnMut(&DisplayListSummary),
- ) {
- let mut visited = HashSet::new();
- let mut pending: Vec<u64> = storage.summary().display_list_ids.clone();
- while let Some(display_list_id) = pending.pop() {
- if !visited.insert(display_list_id) {
- continue;
- }
- if let Some(nested) = self.display_lists.get(&display_list_id) {
- let summary = nested.storage.summary();
- visit(summary);
- pending.extend(&summary.display_list_ids);
- }
- }
- }
-
- /// The ids that the lists a list nests draw, at any depth, as `ids_of` reads them from the summary of each.
- pub fn ids_drawn_by_nested_display_lists(
- &self,
- storage: &DisplayListStorage,
- ids_of: impl Fn(&DisplayListSummary) -> &[u64],
- ) -> HashSet<u64> {
- let mut ids = HashSet::new();
- self.for_each_summary_of_nested_display_lists(storage, |summary| ids.extend(ids_of(summary)));
- ids
- }
-
- /// The handles of the video sinks that a list and the lists it nests draw, at any depth.
- pub fn video_sink_handles_drawn_by(&self, storage: &DisplayListStorage) -> Vec<u64> {
- let mut handles = storage.summary().video_sink_handles.clone();
- self.for_each_summary_of_nested_display_lists(storage, |summary| {
- handles.extend(&summary.video_sink_handles);
- });
- handles.sort_unstable();
- handles.dedup();
- handles
- }
-
- // A raster of a list can differ from replaying it in place when a destination-reading operation can see what was
- // painted before the list began, or when the list draws live content that changes under its immutable commands.
- // A nested list's live content matters at any depth, and its unisolated destination reads matter when its command
- // is not enclosed in a layer; recursing unconditionally is slightly conservative for the latter.
- fn list_requires_direct_replay(&self, display_list_id: u64, visited: &mut HashSet<u64>) -> bool {
- if let Some(&memoized) = self.requires_direct_replay.borrow().get(&display_list_id) {
- return memoized;
- }
- visited.insert(display_list_id);
- let stored = &self.display_lists[&display_list_id];
- let mut requires_direct_replay = requires_direct_replay_without_nested_lists(
- stored.storage.bytes(),
- stored.storage.command_runs(),
- &stored.tree,
- );
- for &nested_id in &stored.storage.summary().display_list_ids {
- if requires_direct_replay {
- break;
- }
- if !visited.insert(nested_id) {
- continue;
- }
- if self.display_lists.contains_key(&nested_id) {
- requires_direct_replay = self.list_requires_direct_replay(nested_id, visited);
- }
- }
- self.requires_direct_replay
- .borrow_mut()
- .insert(display_list_id, requires_direct_replay);
- requires_direct_replay
- }
-}
-
-impl NestedDisplayLists for NestedDisplayListStore {
- fn nested_display_list(&self, display_list_id: u64) -> Option<NestedDisplayList<'_>> {
- let stored = self.display_lists.get(&display_list_id)?;
- Some(NestedDisplayList {
- storage: &stored.storage,
- tree: &stored.tree,
- root_group_color: stored.root_group_color,
- requires_direct_replay: self.list_requires_direct_replay(display_list_id, &mut HashSet::new()),
- })
- }
-}
diff --git a/Services/Compositor/Rust/src/overlays.rs b/Services/Compositor/Rust/src/overlays.rs
index 595ca8e1982..c4295cbdd2a 100644
--- a/Services/Compositor/Rust/src/overlays.rs
+++ b/Services/Compositor/Rust/src/overlays.rs
@@ -15,7 +15,7 @@ use libcompositing_rust::display_list::commands::{
};
use libcompositing_rust::display_list::ffi_bytes::FfiBytes;
use libcompositing_rust::display_list::replay::{
- ListReplay, NoNestedDisplayLists, RecordsContext, ReplayFrame, ReplayPainter, replay_records,
+ ListReplay, RecordsContext, ReplayFrame, ReplayPainter, replay_records,
};
use libcompositing_rust::host::PresentedScrollbar;
use libcompositing_rust::overlays::{
@@ -290,7 +290,7 @@ impl OverlayPicture {
}
OVERLAY_TREE.with(|tree| {
let list = ListReplay::new(tree);
- let frame = ReplayFrame::unscrolled(0, &NoNestedDisplayLists);
+ let frame = ReplayFrame::unscrolled(0);
let context = RecordsContext {
list: &list,
frame: &frame,
diff --git a/Services/Compositor/Rust/src/presenting/damage.rs b/Services/Compositor/Rust/src/presenting/damage.rs
index da577cbad1d..54fe40ebd3f 100644
--- a/Services/Compositor/Rust/src/presenting/damage.rs
+++ b/Services/Compositor/Rust/src/presenting/damage.rs
@@ -10,13 +10,12 @@ use super::layers::{LayerUpdate, MediaUpdate};
use super::{ContextPresenting, FrameToPaint, PresentingEnvironment, rect_of_size};
use crate::frame_inputs::FrameInputs;
use crate::host::PendingFrame;
-use crate::nested_display_lists::NestedDisplayListStore;
use crate::raster_host::LiveContent;
use libcompositing_rust::display_list::commands::{
CanvasId, CompositorContextId, ImageFrameResourceId, VideoSinkHandle,
};
use libcompositing_rust::display_list::damage::{DisplayListDamage, LayerPlans, LiveContentChanges};
-use libcompositing_rust::display_list::summary::{DisplayListSummary, LiveContent as LiveMedia};
+use libcompositing_rust::display_list::summary::LiveContent as LiveMedia;
use libcompositing_rust::scrolling::DisplayList;
use libgfx_rust::{IntRect, IntSize};
use std::collections::{HashMap, HashSet};
@@ -26,7 +25,6 @@ use std::rc::Rc;
/// lists cannot see change.
pub struct PaintedFrame {
pub display_list: Rc<DisplayList>,
- pub nested_display_lists: Rc<NestedDisplayListStore>,
pub frame_inputs: FrameInputs,
pub viewport_size: IntSize,
canvas_content_generations: HashMap<u64, u64>,
@@ -105,43 +103,10 @@ pub struct FrameDamage {
pub live_media_changed: bool,
}
-// The ids that the list draws, and those that the lists it nests draw, as `ids_of` reads them from a summary.
-fn ids_drawn_by(
- display_list: &DisplayList,
- nested_display_lists: &NestedDisplayListStore,
- ids_of: impl Fn(&DisplayListSummary) -> &[u64],
-) -> Vec<u64> {
- let mut ids = ids_of(display_list.storage().summary()).to_vec();
- let ids_of_list: HashSet<u64> = ids.iter().copied().collect();
- ids.extend(
- nested_display_lists
- .ids_drawn_by_nested_display_lists(display_list.storage(), &ids_of)
- .into_iter()
- .filter(|id| !ids_of_list.contains(id)),
- );
- ids
-}
-
-fn canvases_drawn_by(display_list: &DisplayList, nested_display_lists: &NestedDisplayListStore) -> Vec<u64> {
- ids_drawn_by(display_list, nested_display_lists, |summary| &summary.canvas_ids)
-}
-
-fn nested_contexts_drawn_by(display_list: &DisplayList, nested_display_lists: &NestedDisplayListStore) -> Vec<u64> {
- ids_drawn_by(display_list, nested_display_lists, |summary| {
- &summary.composited_context_ids
- })
-}
-
impl ContextPresenting {
- /// The live content of the context as it is now, with the canvases that the list, the lists it nests and the frame
- /// painted last draw.
- pub(super) fn live_content(
- &self,
- env: &PresentingEnvironment<'_>,
- display_list: &DisplayList,
- nested_display_lists: &NestedDisplayListStore,
- ) -> LiveContent {
- let mut canvas_ids = canvases_drawn_by(display_list, nested_display_lists);
+ /// The live content of the context as it is now, with the canvases that the list and the frame painted last draw.
+ pub(super) fn live_content(&self, env: &PresentingEnvironment<'_>, display_list: &DisplayList) -> LiveContent {
+ let mut canvas_ids = display_list.storage().summary().canvas_ids.clone();
if let Some(painted_frame) = &self.painted_frame {
let canvas_ids_of_list: HashSet<u64> = canvas_ids.iter().copied().collect();
canvas_ids.extend(
@@ -159,7 +124,6 @@ impl ContextPresenting {
env: &PresentingEnvironment<'_>,
viewport_rect: IntRect,
display_list: &Rc<DisplayList>,
- nested_display_lists: &Rc<NestedDisplayListStore>,
frame_inputs: FrameInputs,
live_content: &LiveContent,
) {
@@ -169,24 +133,26 @@ impl ContextPresenting {
.get(&id)
.map_or(0, |canvas| canvas.content_generation)
};
- let canvas_content_generations = canvases_drawn_by(display_list, nested_display_lists)
- .into_iter()
- .map(|id| (id, canvas_generation(id)))
+ let summary = display_list.storage().summary();
+ let canvas_content_generations = summary
+ .canvas_ids
+ .iter()
+ .map(|&id| (id, canvas_generation(id)))
.collect();
- // The host reports the video sinks that the list and the display lists it nests draw.
+ // The host reports the video sinks that the list draws.
let video_frame_ids = live_content
.video_sinks
.values()
.map(|sink| (sink.handle, sink.has_frame.then_some(sink.frame_id)))
.collect();
let image_frame_pixel_generations = live_content.image_frames.clone();
- let nested_context_frame_generations = nested_contexts_drawn_by(display_list, nested_display_lists)
- .into_iter()
- .map(|id| (id, env.nested_contexts.frame_generation_of(CompositorContextId(id))))
+ let nested_context_frame_generations = summary
+ .composited_context_ids
+ .iter()
+ .map(|&id| (id, env.nested_contexts.frame_generation_of(CompositorContextId(id))))
.collect();
self.painted_frame = Some(PaintedFrame {
display_list: display_list.clone(),
- nested_display_lists: nested_display_lists.clone(),
frame_inputs,
viewport_size: IntSize {
width: viewport_rect.width,
@@ -226,7 +192,7 @@ impl ContextPresenting {
if current_content_generation == *content_generation {
continue;
}
- // A canvas drawn only by a nested display list has no command in this list to damage.
+ // A canvas that no command of this list draws has no command in this list to damage.
if !canvas_ids_of_list.contains(canvas_id) {
changes.repaints_everything = true;
}
@@ -251,8 +217,7 @@ impl ContextPresenting {
media: LiveMedia::VideoFrame(VideoSinkHandle(*video_sink_handle)),
content_version: current_frame_id.unwrap_or(0),
});
- // A video drawn only by a nested display list, such as an SVG image's, has no command in this list to
- // damage.
+ // A video that no command of this list draws has no command in this list to damage.
if !video_sink_handles_of_list.contains(video_sink_handle) {
changes.repaints_everything = true;
}
@@ -262,8 +227,8 @@ impl ContextPresenting {
if painted_frame.image_frame_pixel_generations.get(&image_frame_id) == Some(&pixel_generation) {
continue;
}
- // An image drawn only by a nested display list, such as an SVG image's, has no command in this list to
- // damage.
+ // An image that no command of this list draws, such as one that a filter of the visual context tree
+ // draws, has no command in this list to damage.
if !image_frame_ids_of_list.contains(&image_frame_id) {
changes.repaints_everything = true;
}
diff --git a/Services/Compositor/Rust/src/presenting/mod.rs b/Services/Compositor/Rust/src/presenting/mod.rs
index 56decad14ec..e9c6664c356 100644
--- a/Services/Compositor/Rust/src/presenting/mod.rs
+++ b/Services/Compositor/Rust/src/presenting/mod.rs
@@ -14,7 +14,6 @@ pub mod pacing;
use crate::frame_inputs::FrameInputs;
use crate::host::{ContextTimer, Host, PendingFrame};
-use crate::nested_display_lists::NestedDisplayListStore;
use crate::raster_host::{
FfiStoreResize, FfiSublayer, PaintingResources, RasterHost, StorePublication, StoreResizeOutcome, SurfaceBlend,
SurfaceHandle,
@@ -68,10 +67,9 @@ pub struct PreparedFrame {
pub sublayers: Vec<FfiSublayer>,
}
-// The display list, the display lists it nests and the frame inputs a frame is painted with.
+// The display list and the frame inputs a frame is painted with.
pub(crate) struct FrameToPaint<'a> {
pub display_list: &'a Rc<DisplayList>,
- pub nested_display_lists: &'a Rc<NestedDisplayListStore>,
pub frame_inputs: &'a FrameInputs,
}
@@ -546,7 +544,6 @@ impl ContextPresenting {
env: &PresentingEnvironment<'_>,
pending_frame: PendingFrame,
display_list: Option<&Rc<DisplayList>>,
- nested_display_lists: &Rc<NestedDisplayListStore>,
frame_inputs: Option<FrameInputs>,
) -> Option<PreparedFrame> {
if self.is_present_blocked(env.raster, env.context_id) {
@@ -559,10 +556,9 @@ impl ContextPresenting {
}
let display_list = display_list.expect("a frame that can render has a display list");
let frame_inputs = frame_inputs.expect("a context with a display list has frame inputs");
- let live_content = self.live_content(env, display_list, nested_display_lists);
+ let live_content = self.live_content(env, display_list);
let frame = FrameToPaint {
display_list,
- nested_display_lists,
frame_inputs: &frame_inputs,
};
let mut frame_damage = self.frame_damage_for(env, &pending_frame, &frame, &live_content);
@@ -576,7 +572,6 @@ impl ContextPresenting {
env,
pending_frame.viewport_rect,
display_list,
- nested_display_lists,
frame_inputs,
&live_content,
);
@@ -611,7 +606,6 @@ impl ContextPresenting {
env,
pending_frame.viewport_rect,
display_list,
- nested_display_lists,
frame_inputs,
&live_content,
);
@@ -629,7 +623,6 @@ impl ContextPresenting {
&mut self,
env: &PresentingEnvironment<'_>,
display_list: Option<&Rc<DisplayList>>,
- nested_display_lists: &Rc<NestedDisplayListStore>,
frame_inputs: Option<FrameInputs>,
) {
let Some(display_list) = display_list else {
@@ -643,10 +636,9 @@ impl ContextPresenting {
None => return,
},
};
- let live_content = self.live_content(env, display_list, nested_display_lists);
+ let live_content = self.live_content(env, display_list);
let frame = FrameToPaint {
display_list,
- nested_display_lists,
frame_inputs: &frame_inputs,
};
let mut frame_damage = self.frame_damage_for(env, &pending_frame, &frame, &live_content);
@@ -668,7 +660,6 @@ impl ContextPresenting {
env,
pending_frame.viewport_rect,
display_list,
- nested_display_lists,
frame_inputs,
&live_content,
);
@@ -685,12 +676,10 @@ impl ContextPresenting {
env: &PresentingEnvironment<'_>,
target: &SurfaceHandle,
display_list: &Rc<DisplayList>,
- nested_display_lists: &Rc<NestedDisplayListStore>,
frame_inputs: &FrameInputs,
) {
let frame = FrameToPaint {
display_list,
- nested_display_lists,
frame_inputs,
};
self.paint_current_display_list(env, target, &frame, None, false, false);
@@ -718,7 +707,6 @@ impl ContextPresenting {
.draw_surface(&composited, &source, source_rect, source_rect, SurfaceBlend::Source);
let frame = FrameToPaint {
display_list: &painted_frame.display_list,
- nested_display_lists: &painted_frame.nested_display_lists,
frame_inputs: &painted_frame.frame_inputs,
};
let snapshot_env = PresentingEnvironment {
@@ -868,7 +856,6 @@ pub(crate) fn replay_into(
scroll_offsets: frame_inputs.presented_scroll_state_snapshot.device_offsets(),
scrollbars: &scrollbars,
time_ns: frame_inputs.painted_at.nanoseconds(),
- nested_display_lists: frame.nested_display_lists.as_ref(),
composited_contexts: env.nested_contexts,
};
let storage = display_list.storage();
diff --git a/Services/Compositor/Rust/src/raster_host.rs b/Services/Compositor/Rust/src/raster_host.rs
index 9c02c50c06c..0f337b9d616 100644
--- a/Services/Compositor/Rust/src/raster_host.rs
+++ b/Services/Compositor/Rust/src/raster_host.rs
@@ -119,7 +119,7 @@ pub struct FfiVideoSinkContent {
pub struct FfiResourceChanges<'a> {
pub font_ids_to_remove: ak::Span<'a, u64>,
pub image_frame_ids_to_remove: ak::Span<'a, u64>,
- pub display_list_ids_to_remove: ak::Span<'a, u64>,
+ pub vector_image_ids_to_remove: ak::Span<'a, u64>,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
@@ -307,7 +307,7 @@ pub struct FfiRasterHost {
pub map_shared_memory: unsafe extern "C" fn(*mut c_void, i32, u64, *mut *const u8, *mut usize) -> *mut c_void,
pub unmap_shared_memory: unsafe extern "C" fn(*mut c_void),
pub apply_resource_changes: unsafe extern "C" fn(*mut c_void, u64, *const FfiResourceChanges<'_>),
- /// Arguments: the context, and the handles of the video sinks that its display list and the lists it nests draw.
+ /// Arguments: the context, and the handles of the video sinks that its display list draws.
pub set_drawn_video_sinks: unsafe extern "C" fn(*mut c_void, u64, ak::Span<'_, u64>),
/// Arguments: the client, the token it staged the rasterization under, and the fonts and image frames the display
/// list draws. Answers whether the rasterization is staged with all of them. A staged rasterization draws no video
diff --git a/Tests/LibWeb/Text/expected/display_list/repeated-svg-background-is-tile.txt b/Tests/LibWeb/Text/expected/display_list/repeated-svg-background-is-tile.txt
index ccea3b17217..3f494956d48 100644
--- a/Tests/LibWeb/Text/expected/display_list/repeated-svg-background-is-tile.txt
+++ b/Tests/LibWeb/Text/expected/display_list/repeated-svg-background-is-tile.txt
@@ -7,6 +7,7 @@ AccumulatedVisualContext Tree:
DisplayList:
DrawRepeatedTile@s1/e0 dst_rect=[8,8 20x20] clip_rect=[8,8 120x80] tile_size=[20x20] tile_step=[20x20] scaling_mode=NearestNeighbor inline_clips=[clip=[8,8 120x80], clip=[8,8 120x80]]
- PaintNestedDisplayList@s1/e0 rect=[0,0 20x20]
- FillPath@s2/e0 path_bounding_rect=[0,0 20x20]
- FillPath@s2/e0 path_bounding_rect=[5,5 10x10]
+ PaintVectorImage@s1/e0 rect=[0,0 20x20]
+ FillPath@s1/e0 path_bounding_rect=[0,0 20x20]
+ FillPath@s1/e0 path_bounding_rect=[5,5 10x10]
+
diff --git a/Tests/LibWeb/Text/expected/display_list/svg-in-img-is-nested.txt b/Tests/LibWeb/Text/expected/display_list/svg-in-img-is-nested.txt
deleted file mode 100644
index b627ef2ddbf..00000000000
--- a/Tests/LibWeb/Text/expected/display_list/svg-in-img-is-nested.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-AccumulatedVisualContext Tree:
- spatial:
- [s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
- [s1] scroll (Viewport<#document>)
- effects:
- [e0 in s0] effects=[]
-
-DisplayList:
-PaintNestedDisplayList@s1/e0 rect=[8,13 300x200]
- FillPath@s6/e0 path_bounding_rect=[0,0 100x100]
- FillPath@s6/e0 path_bounding_rect=[0,100 100x100]
- DeclareMaskContent@s7/e1 rect=[0,20 100x100] effect=e1
- FillPath@s7/e1 path_bounding_rect=[0,0 100x100] inline_transform=[1,0,0,1,0,20]
- FillPath@s7/e1 path_bounding_rect=[0,0 100x100]
- FillPath@s7/e1 path_bounding_rect=[0,100 100x100]
-
diff --git a/Tests/LibWeb/Text/expected/display_list/svg-in-img-is-recorded-without-visual-contexts.txt b/Tests/LibWeb/Text/expected/display_list/svg-in-img-is-recorded-without-visual-contexts.txt
new file mode 100644
index 00000000000..2ceab9218ac
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/display_list/svg-in-img-is-recorded-without-visual-contexts.txt
@@ -0,0 +1,17 @@
+AccumulatedVisualContext Tree:
+ spatial:
+ [s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
+ [s1] scroll (Viewport<#document>)
+ effects:
+ [e0 in s0] effects=[]
+
+DisplayList:
+PaintVectorImage@s1/e0 rect=[8,13 300x200]
+ FillPath@s1/e0 path_bounding_rect=[0,0 100x100] inline_transform=[0.49809736,0.043577872,-0.043577872,0.49809736,9.961947,0.8715575]
+ FillPath@s1/e0 path_bounding_rect=[0,100 100x100] inline_transform=[0.49809736,0.043577872,-0.043577872,0.49809736,9.961947,0.8715575]
+ DrawIsolatedGroup@s1/e0 clip_rect=[0,0 300x200] has_mask=alpha inline_clips=[clip_path=[bounds: [4,10 55x56], path: M9.0903902 10.833505L58.900124 15.191292L54.542339 65.00103L4.7326026 60.643242L9.0903902 10.833505Z]]
+ FillPath@s1/e0 path_bounding_rect=[0,0 100x100] inline_transform=[0.49809736,0.043577872,-0.043577872,0.49809736,9.961947,0.8715575]
+ FillPath@s1/e0 path_bounding_rect=[0,100 100x100] inline_transform=[0.49809736,0.043577872,-0.043577872,0.49809736,9.961947,0.8715575]
+ Mask:
+ FillPath@s1/e0 path_bounding_rect=[0,0 100x100] inline_transform=[0.49809736,0.043577872,-0.043577872,0.49809736,9.09039,10.833505]
+
diff --git a/Tests/LibWeb/Text/input/display_list/clipped-svg-background-stays-vector.html b/Tests/LibWeb/Text/input/display_list/clipped-svg-background-stays-vector.html
index 31c37426035..b8ae13a1298 100644
--- a/Tests/LibWeb/Text/input/display_list/clipped-svg-background-stays-vector.html
+++ b/Tests/LibWeb/Text/input/display_list/clipped-svg-background-stays-vector.html
@@ -25,7 +25,7 @@
function check(label) {
const lines = internals.dumpDisplayList().split("\n");
const tiles = lines.filter(line => line.trimStart().startsWith("DrawRepeatedTile@"));
- const images = lines.filter(line => line.trimStart().startsWith("PaintNestedDisplayList@"));
+ const images = lines.filter(line => line.trimStart().startsWith("PaintVectorImage@"));
println(`${label}: ${tiles.length} raster tiles, ${images.length} vector images`);
}
diff --git a/Tests/LibWeb/Text/input/display_list/svg-in-img-is-nested.html b/Tests/LibWeb/Text/input/display_list/svg-in-img-is-recorded-without-visual-contexts.html
similarity index 100%
rename from Tests/LibWeb/Text/input/display_list/svg-in-img-is-nested.html
rename to Tests/LibWeb/Text/input/display_list/svg-in-img-is-recorded-without-visual-contexts.html