Skip to content

Truly independent web browser

LibCompositing+Compositor: Look up mask content by its effect node

Aliaksandr Kalenik5e5197ab48f4
diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers.rs b/Libraries/LibCompositing/Rust/src/display_list/layers.rs
index da853eba03c..ee178c49060 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/layers.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/layers.rs
@@ -37,7 +37,7 @@ use crate::display_list::window_server_placement::{
WhyWindowServerCannotCompositeEffect, WhyWindowServerCannotShowMedia, WindowServerPlacement,
WindowServerPlacementOfEffect, window_server_placement_of_effect,
};
-use crate::visual_context::queries::{NestingOfLiveEffects, backdrop_reader_by_reading_effect_index};
+use crate::visual_context::queries::backdrop_reader_by_reading_effect_index;
use crate::visual_context::{VisualContextTree, WorldTransforms, device_offset_for_index};
use libgfx_rust::{AffineTransform, CornerRadii, FloatMatrix4x4, FloatPoint, IntPoint, IntRect};
use std::hash::{BuildHasher, Hash, Hasher};
@@ -116,7 +116,6 @@ pub enum WhyListIsOneLayer {
EmptyDisplayList,
SortingContext3D,
RootIsolationEffectIsNotPlainGroup,
- MaskDeclaredUnderEffectsItsMaskIsNotUnder,
RecordsBlendWithWhatOtherLayersHoldBelowThem,
EffectTheCompositorCannotCompositeIsComposited(WhyCompositorCannotCompositeEffect),
CompositedEffectsNestTooDeep,
@@ -137,9 +136,6 @@ impl std::fmt::Display for WhyListIsOneLayer {
WhyListIsOneLayer::EmptyDisplayList => "empty display list",
WhyListIsOneLayer::SortingContext3D => "3D sorting context holding an effect that reads or is composited",
WhyListIsOneLayer::RootIsolationEffectIsNotPlainGroup => "root isolation effect is not a plain group",
- WhyListIsOneLayer::MaskDeclaredUnderEffectsItsMaskIsNotUnder => {
- "mask content declared under effects its mask is not under"
- }
WhyListIsOneLayer::RecordsBlendWithWhatOtherLayersHoldBelowThem => {
"records blend with what other layers hold below them"
}
@@ -1682,48 +1678,14 @@ impl LayerStack {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct LayeringObstacles {
pub sorts_planes_by_depth: bool,
- pub mask_declared_under_effects_its_mask_is_not_under: bool,
}
impl LayeringObstacles {
- pub fn of(list: &DisplayListStorage, tree: &VisualContextTree) -> Self {
- Self::of_with_nesting_of_live_effects(list, tree, &NestingOfLiveEffects::of(tree))
- }
-
- pub(crate) fn of_with_nesting_of_live_effects(
- list: &DisplayListStorage,
- tree: &VisualContextTree,
- nesting_of_live_effects: &NestingOfLiveEffects<'_>,
- ) -> Self {
+ pub fn of(tree: &VisualContextTree) -> Self {
Self {
sorts_planes_by_depth: tree.may_sort_planes_by_depth(),
- mask_declared_under_effects_its_mask_is_not_under: !mask_declarations_are_on_effect_chains_of_their_masks(
- list,
- nesting_of_live_effects,
- ),
}
}
-
- /// Whether every tile replays every record of its band, as which records can show in a tile cannot be told.
- pub fn every_tile_replays_every_record(&self) -> bool {
- self.mask_declared_under_effects_its_mask_is_not_under
- }
-}
-
-// A tile replays the declaration of a mask's content along with what the mask holds, and so opens the effects the
-// declaration is under there, which draw nothing only when they are the mask's own or those around it. A list from
-// another process can name a mask that the tree does not hold as a live node. No effect is inside such a mask.
-fn mask_declarations_are_on_effect_chains_of_their_masks(
- list: &DisplayListStorage,
- nesting_of_live_effects: &NestingOfLiveEffects<'_>,
-) -> bool {
- list.summary().mask_declarations.iter().all(|declaration| {
- let mask_effect = declaration.mask_effect;
- let declaration_effect = list.run(declaration.record.run_index as usize).context.effect;
- declaration_effect.is_none()
- || nesting_of_live_effects.is_or_is_inside(declaration_effect, mask_effect)
- || nesting_of_live_effects.is_or_is_inside(mask_effect, declaration_effect)
- })
}
fn anchors_of_layer_plans(tree: &VisualContextTree) -> Vec<SpatialNodeIndex> {
diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs
index 3b8cee0f73d..8e2aba252af 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/planning.rs
@@ -217,10 +217,7 @@ fn root_isolation_effect_is_plain_group(tree: &VisualContextTree) -> bool {
}
/// Why a list cannot be layered at all.
-fn why_list_cannot_be_layered(
- inputs: &LayerStackInputs<'_>,
- layering_obstacles: &LayeringObstacles,
-) -> Option<WhyListIsOneLayer> {
+fn why_list_cannot_be_layered(inputs: &LayerStackInputs<'_>) -> Option<WhyListIsOneLayer> {
if inputs.viewport_rect.is_empty() {
return Some(WhyListIsOneLayer::EmptyViewport);
}
@@ -230,9 +227,6 @@ fn why_list_cannot_be_layered(
if !root_isolation_effect_is_plain_group(inputs.tree) {
return Some(WhyListIsOneLayer::RootIsolationEffectIsNotPlainGroup);
}
- if layering_obstacles.mask_declared_under_effects_its_mask_is_not_under {
- return Some(WhyListIsOneLayer::MaskDeclaredUnderEffectsItsMaskIsNotUnder);
- }
None
}
@@ -2760,9 +2754,8 @@ fn plan_layer_stack_at_anchors(
anchors_of_tree: &RasterSpaceAnchorsOfTree,
) -> PlannedLayers {
let nesting_of_live_effects = NestingOfLiveEffects::of(inputs.tree);
- let layering_obstacles =
- LayeringObstacles::of_with_nesting_of_live_effects(inputs.list, inputs.tree, &nesting_of_live_effects);
- if let Some(why) = why_list_cannot_be_layered(inputs, &layering_obstacles) {
+ let layering_obstacles = LayeringObstacles::of(inputs.tree);
+ if let Some(why) = why_list_cannot_be_layered(inputs) {
return one_layer(inputs, why, layering_obstacles, ListPlacement::default());
}
let (spaces, geometries) = spaces_with_geometries(
diff --git a/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs b/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs
index d9e6b9e6a0c..f1b55bb7ee1 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/layers/wire.rs
@@ -338,7 +338,6 @@ impl Encode for WhyListIsOneLayer {
WhyListIsOneLayer::EmptyDisplayList => 1,
WhyListIsOneLayer::SortingContext3D => 2,
WhyListIsOneLayer::RootIsolationEffectIsNotPlainGroup => 3,
- WhyListIsOneLayer::MaskDeclaredUnderEffectsItsMaskIsNotUnder => 4,
WhyListIsOneLayer::RecordsBlendWithWhatOtherLayersHoldBelowThem => 5,
WhyListIsOneLayer::EffectTheCompositorCannotCompositeIsComposited(_) => 6,
WhyListIsOneLayer::FrameIsNotDrawnAsPlanned => 7,
@@ -364,7 +363,6 @@ impl Decode for WhyListIsOneLayer {
1 => WhyListIsOneLayer::EmptyDisplayList,
2 => WhyListIsOneLayer::SortingContext3D,
3 => WhyListIsOneLayer::RootIsolationEffectIsNotPlainGroup,
- 4 => WhyListIsOneLayer::MaskDeclaredUnderEffectsItsMaskIsNotUnder,
5 => WhyListIsOneLayer::RecordsBlendWithWhatOtherLayersHoldBelowThem,
6 => WhyListIsOneLayer::EffectTheCompositorCannotCompositeIsComposited(decoder.decode()?),
7 => WhyListIsOneLayer::FrameIsNotDrawnAsPlanned,
@@ -872,7 +870,7 @@ fn validated_stack(
viewport_rect: IntRect,
) -> Result<LayerStack, &'static str> {
let nesting_of_live_effects = NestingOfLiveEffects::of(tree);
- let layering_obstacles = LayeringObstacles::of_with_nesting_of_live_effects(list, tree, &nesting_of_live_effects);
+ let layering_obstacles = LayeringObstacles::of(tree);
match stack {
StackOnWire::OneLayer(why_list_is_one_layer) => {
check_viewport_rect(viewport_rect)?;
@@ -931,9 +929,7 @@ pub fn compositor_takes_plans_within(viewport_rect: IntRect) -> bool {
mod tests {
use super::*;
use crate::display_list::builder::DisplayListBuilder;
- use crate::display_list::commands::{
- ClipNodeIndex, ContextRef, DeclareMaskContent, SpatialNodeIndex, VISUAL_VIEWPORT_NODE_INDEX,
- };
+ use crate::display_list::commands::{ClipNodeIndex, ContextRef, SpatialNodeIndex, VISUAL_VIEWPORT_NODE_INDEX};
use crate::display_list::layers::planning::{LayerStackInputs, PlannedLayers, plan_layer_stack};
use crate::display_list::layers::{
BandIndex, CutsOfCell, LARGEST_SUMMED_READ_REACH_OF_COMPOSITED_FILTERS_IN_DEVICE_PIXELS, LayerIndex,
@@ -1762,7 +1758,6 @@ mod tests {
WhyListIsOneLayer::EmptyDisplayList,
WhyListIsOneLayer::SortingContext3D,
WhyListIsOneLayer::RootIsolationEffectIsNotPlainGroup,
- WhyListIsOneLayer::MaskDeclaredUnderEffectsItsMaskIsNotUnder,
WhyListIsOneLayer::RecordsBlendWithWhatOtherLayersHoldBelowThem,
WhyListIsOneLayer::CompositedEffectsNestTooDeep,
WhyListIsOneLayer::FrameIsNotDrawnAsPlanned,
@@ -2496,65 +2491,6 @@ mod tests {
bytes
}
- // Decoding a tree checks the parent of no dead node, and a mask declaration can name any node.
- #[test]
- fn a_mask_declared_for_a_dead_effect_node_lets_no_record_replay_alone_in_its_tiles() {
- let (mut tree, _, contexts) = tree_with_document_scroller(&[]);
- let document = contexts[0];
- let effect_to_kill = tree.append_effect(
- effects(0.5, CompositingAndBlendingOperator::Normal),
- EffectNodeIndex::NONE,
- VISUAL_VIEWPORT_NODE_INDEX,
- ClipNodeIndex::NONE,
- );
- let list_declaring_content_of_mask = |mask_effect: EffectNodeIndex| {
- let mut builder = DisplayListBuilder::new();
- builder.append(&fill(IntRect::new(0, 0, 800, 2600), GREEN), &[], document);
- builder.append(&canvas(IntRect::new(100, 100, 200, 100), 1), &[], document);
- let declaration = builder.begin_group::<DeclareMaskContent>(Vec::new());
- builder.append(&fill(IntRect::new(0, 0, 10, 10), GREEN), &[], document);
- let content = builder.group_content_span(&declaration);
- builder.finish_group(
- declaration,
- &DeclareMaskContent {
- rect: IntRect::new(0, 0, 10, 10),
- effect: mask_effect,
- content,
- },
- document,
- );
- DisplayListStorage::of_builder(&builder)
- };
- let page_with_live_mask = Page {
- tree: tree.clone(),
- list: list_declaring_content_of_mask(document.effect),
- };
- assert!(!page_with_live_mask.planned().stack.replays_whole_list());
- for parent_of_dead_node in [effect_to_kill, EffectNodeIndex(1000)] {
- let mut tree_with_dead_node = tree.clone();
- tree_with_dead_node.effect_nodes[effect_to_kill.0 as usize].data = EffectNodeData::Dead;
- tree_with_dead_node.effect_nodes[effect_to_kill.0 as usize].parent = parent_of_dead_node;
- let page_with_dead_mask = Page {
- tree: VisualContextTree::from_bytes(&tree_with_dead_node.to_bytes())
- .expect("a dead node may have any parent"),
- list: list_declaring_content_of_mask(effect_to_kill),
- };
- let one_layer = LayerStack::one_layer_replaying_whole_list(
- VIEWPORT,
- page_with_dead_mask.list.whole_span(),
- Some(WhyListIsOneLayer::EmptyViewport),
- LayeringObstacles::default(),
- );
- for stack in [
- page_with_dead_mask.validated(one_layer),
- page_with_dead_mask.validated_plan(page_with_live_mask.planned_plan()),
- ] {
- let stack = stack.expect("the stack passes its checks");
- assert!(stack.layering_obstacles.every_tile_replays_every_record());
- }
- }
- }
-
// A candidate turned away takes no space, so candidates after it still get one, however many are turned away.
#[test]
fn anchors_are_chosen_past_candidates_that_are_turned_away() {
diff --git a/Libraries/LibCompositing/Rust/src/display_list/nested_records.rs b/Libraries/LibCompositing/Rust/src/display_list/nested_records.rs
index 350b9c07fdc..9bd8e2b63e5 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/nested_records.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/nested_records.rs
@@ -17,18 +17,10 @@ pub enum NestedRecordsRole {
VectorImage,
}
-impl NestedRecordsRole {
- pub fn is_replayed_where_its_record_plays(self) -> bool {
- self != Self::MaskContent
- }
-}
-
-pub fn replays_nested_records_where_it_plays(command_type: DisplayListCommandType, payload: &[u8]) -> bool {
- let mut replays_nested_records = false;
- for_each_nested_record_span(command_type, payload, |role, _| {
- replays_nested_records |= role.is_replayed_where_its_record_plays();
- });
- replays_nested_records
+pub fn holds_nested_records(command_type: DisplayListCommandType, payload: &[u8]) -> bool {
+ let mut holds_nested_records = false;
+ for_each_nested_record_span(command_type, payload, |_, _| holds_nested_records = true);
+ holds_nested_records
}
pub fn for_each_nested_record_span(
diff --git a/Libraries/LibCompositing/Rust/src/display_list/replay.rs b/Libraries/LibCompositing/Rust/src/display_list/replay.rs
index eb320e29119..318f9672754 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/replay.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/replay.rs
@@ -9,17 +9,17 @@ use crate::display_list::builder::{
inline_transform_of, read_command,
};
use crate::display_list::commands::{
- ClipMode, ClipNodeIndex, DeclareMaskContent, DisplayListCommandHeader, DisplayListCommandRun,
- DisplayListCommandType, DisplayListPaintStyleType, DrawCompositedContext, DrawIsolatedGroup, DrawRepeatedTile,
- EffectNodeIndex, FillPath, FillRect, FillRectWithRoundedCorners, InlineClipKind, OptionalFloatRect, PaintCaret,
- PaintScrollBar, PaintVectorImage, PathPaintKind, ReplayClip, ReplayLayer, ReplayMask, SpatialNodeIndex, StrokePath,
+ ClipMode, ClipNodeIndex, DisplayListCommandHeader, DisplayListCommandRun, DisplayListCommandType,
+ DisplayListPaintStyleType, DrawCompositedContext, DrawIsolatedGroup, DrawRepeatedTile, EffectNodeIndex, FillPath,
+ FillRect, FillRectWithRoundedCorners, InlineClipKind, OptionalFloatRect, PaintCaret, 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, nearest_effects_at_or_above_where,
};
-use crate::display_list::nested_records::{replays_nested_records_where_it_plays, span_bytes};
+use crate::display_list::nested_records::{holds_nested_records, span_bytes};
use crate::display_list::storage::{ChunkIndexInList, DisplayListStorage, ListSpan};
use crate::host::{
CompositedContextDraw, IsolatedGroup, PresentedScrollbar, ResolvedFillRect, ResolvedFillRectWithRoundedCorners,
@@ -37,7 +37,6 @@ use libgfx_rust::{
FloatVector3, IntRect, IntSize, MaskKind, WindingRule, enclosing_int_rect, multiply_affine,
};
use std::cell::RefCell;
-use std::collections::HashMap;
use std::hash::Hasher;
/// The raster primitives a replay draws through. Everything a painter is handed is resolved for the frame: it never
@@ -179,35 +178,10 @@ impl ReplayFrame<'_> {
}
}
-/// What one display list holds for the streams of records it plays: the tree it was recorded against, and the
-/// content that each of its masks declared.
-pub struct ListReplay<'t> {
- pub tree: &'t VisualContextTree,
- declared_mask_content_by_effect: RefCell<HashMap<EffectNodeIndex, &'t [u8]>>,
-}
-
-impl<'t> ListReplay<'t> {
- pub fn new(tree: &'t VisualContextTree) -> Self {
- Self {
- tree,
- declared_mask_content_by_effect: RefCell::new(HashMap::new()),
- }
- }
-
- fn declare_mask_content(&self, effect: EffectNodeIndex, content: &'t [u8]) {
- self.declared_mask_content_by_effect
- .borrow_mut()
- .insert(effect, content);
- }
-
- fn declared_mask_content(&self, effect: EffectNodeIndex) -> Option<&'t [u8]> {
- self.declared_mask_content_by_effect.borrow().get(&effect).copied()
- }
-}
-
/// What playing a stream of records needs besides the records.
pub struct RecordsContext<'c, 't> {
- pub list_replay: &'c ListReplay<'t>,
+ /// The tree the records were recorded against.
+ pub tree: &'t VisualContextTree,
pub frame: &'c ReplayFrame<'c>,
pub to_root_matrix_of_inline_clip_space: &'c dyn Fn(SpatialNodeIndex) -> Option<FloatMatrix4x4>,
}
@@ -339,7 +313,7 @@ fn rasterize_tile_if_pattern<'t, Painter: ReplayPainter + ?Sized>(
replay_records(
span_bytes(payload, paint_style.pattern_tile),
&RecordsContext {
- list_replay: context.list_replay,
+ tree: context.tree,
frame: &tile_frame,
to_root_matrix_of_inline_clip_space: &|_| None,
},
@@ -355,7 +329,7 @@ fn play_record_resolving_frame_state<'t, Painter: ReplayPainter + ?Sized>(
context: &RecordsContext<'_, 't>,
painter: &mut Painter,
) {
- let tree = context.list_replay.tree;
+ let tree = context.tree;
match header.command_type {
DisplayListCommandType::FillRect => {
let command = read_command::<FillRect>(payload);
@@ -460,12 +434,6 @@ fn play_record_resolving_frame_state<'t, Painter: ReplayPainter + ?Sized>(
scaling_mode: command.scaling_mode,
});
}
- DisplayListCommandType::DeclareMaskContent => {
- let command = read_command::<DeclareMaskContent>(payload);
- context
- .list_replay
- .declare_mask_content(command.effect, span_bytes(payload, command.content));
- }
DisplayListCommandType::DrawIsolatedGroup => {
let command = read_command::<DrawIsolatedGroup>(payload);
let filter = span_bytes(payload, command.filter);
@@ -477,7 +445,7 @@ fn play_record_resolving_frame_state<'t, Painter: ReplayPainter + ?Sized>(
filter_bytes_size: filter.len(),
});
let nested_records_context = RecordsContext {
- list_replay: context.list_replay,
+ tree: context.tree,
frame: context.frame,
to_root_matrix_of_inline_clip_space: &|_| None,
};
@@ -505,7 +473,7 @@ fn play_record_resolving_frame_state<'t, Painter: ReplayPainter + ?Sized>(
replay_records(
tile_records,
&RecordsContext {
- list_replay: context.list_replay,
+ tree: context.tree,
frame: &tile_frame,
to_root_matrix_of_inline_clip_space: &|_| None,
},
@@ -539,7 +507,7 @@ fn play_record_resolving_frame_state<'t, Painter: ReplayPainter + ?Sized>(
replay_records(
span_bytes(payload, command.records),
&RecordsContext {
- list_replay: context.list_replay,
+ tree: context.tree,
frame: &vector_image_frame,
to_root_matrix_of_inline_clip_space: &|_| None,
},
@@ -562,10 +530,13 @@ pub fn replay_records<'t, Painter: ReplayPainter + ?Sized>(
) {
let to_root_matrix_of_inline_clip_space = context.to_root_matrix_of_inline_clip_space;
for_each_command(records, |header, _, payload| {
- if header.command_type.is_compositor_metadata() {
+ // NB: A mask composites the content it declares where the mask is, whatever the declaration is recorded under.
+ if header.command_type.is_compositor_metadata()
+ || header.command_type == DisplayListCommandType::DeclareMaskContent
+ {
return;
}
- if replays_nested_records_where_it_plays(header.command_type, payload) {
+ if holds_nested_records(header.command_type, payload) {
let bounding_rect = bounding_rect_computed_from_payload(header, payload).unwrap_or_default();
if bounding_rect.is_empty() || painter.would_be_fully_clipped_by_painter(bounding_rect) {
return;
@@ -713,7 +684,6 @@ enum SwitchResult {
struct ReplayDriver<'a, Painter: ReplayPainter + ?Sized> {
tree: &'a VisualContextTree,
display_list: &'a DisplayListStorage,
- list_replay: ListReplay<'a>,
frame: &'a ReplayFrame<'a>,
effect_clips: &'a EffectClipPlan,
root_group_color: Color,
@@ -1223,9 +1193,9 @@ impl<Painter: ReplayPainter + ?Sized> ReplayDriver<'_, Painter> {
EffectNodeData::Mask(mask) => {
self.ensure_canvas_matrix_in_draw_space_of(node.spatial);
self.painter.begin_mask_content(&replay_mask_of(mask));
- if let Some(content) = self.list_replay.declared_mask_content(effect) {
+ if let Some(content) = self.display_list.records_of_mask_content(effect) {
let records_context = RecordsContext {
- list_replay: &self.list_replay,
+ tree,
frame: self.frame,
to_root_matrix_of_inline_clip_space: &|_| None,
};
@@ -1404,7 +1374,7 @@ impl<Painter: ReplayPainter + ?Sized> ReplayDriver<'_, Painter> {
let world = &self.world;
let to_root_matrix_of_inline_clip_space = |space: SpatialNodeIndex| world.draw_matrix_if_known(space);
let records_context = RecordsContext {
- list_replay: &self.list_replay,
+ tree: self.tree,
frame: self.frame,
to_root_matrix_of_inline_clip_space: &to_root_matrix_of_inline_clip_space,
};
@@ -1560,7 +1530,6 @@ impl<'a, Painter: ReplayPainter + ?Sized> ReplayDriver<'a, Painter> {
let mut driver = ReplayDriver {
tree,
display_list,
- list_replay: ListReplay::new(tree),
frame,
effect_clips,
root_group_color,
@@ -1601,17 +1570,6 @@ impl<'a, Painter: ReplayPainter + ?Sized> ReplayDriver<'a, Painter> {
effect_geometry_by_effect_index: std::mem::take(&mut self.effect_geometry_by_effect_index),
});
}
-
- // Compositing enters masks without replaying the declarations of their content ahead of them.
- fn declare_every_mask_content_of_list(&mut self) {
- let display_list = self.display_list;
- for declaration in &display_list.summary().mask_declarations {
- let (_, payload) = display_list.record_at(declaration.record.position);
- let command = read_command::<DeclareMaskContent>(payload);
- self.list_replay
- .declare_mask_content(command.effect, span_bytes(payload, command.content));
- }
- }
}
/// The compositing of rasters of a frame inside the effects the compositor applies to them as it composites them,
@@ -1766,7 +1724,6 @@ pub fn composite_inside_effects<Painter: ReplayPainter + ?Sized>(
},
painter,
);
- driver.declare_every_mask_content_of_list();
let mut compositing = CompositingInsideEffects {
driver: &mut driver,
canvas_matrix_of_raster_pixels,
@@ -2092,12 +2049,11 @@ mod tests {
painter: &mut RecordingPainter,
) {
let tree = identity_tree();
- let list = ListReplay::new(&tree);
let frame = ReplayFrame::unscrolled(0);
replay_records(
records,
&RecordsContext {
- list_replay: &list,
+ tree: &tree,
frame: &frame,
to_root_matrix_of_inline_clip_space,
},
diff --git a/Libraries/LibCompositing/Rust/src/display_list/storage.rs b/Libraries/LibCompositing/Rust/src/display_list/storage.rs
index e9ff1bb6d03..0db99838bb0 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/storage.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/storage.rs
@@ -7,19 +7,26 @@
//! A display list as the chunks it is cut into, in paint order: chunks another process sent that passed validation, or
//! the chunks of a recording this process made, with the visual context tree it was recorded against.
-use super::builder::{COMMAND_ALIGNMENT, HEADER_SIZE, RecordedDisplayList, for_each_command, read_header};
+use super::builder::{
+ COMMAND_ALIGNMENT, HEADER_SIZE, RecordedDisplayList, for_each_command, read_command, read_header,
+};
use super::chunks::{
Chunk, ChunkId, DisplayListChunk, TopLevelRecordReachingOutsideRunContext, chunk_id, chunks_of,
top_level_records_reaching_outside_run_context,
};
-use super::commands::{ContextRef, DisplayListCommandHeader, DisplayListCommandRun, DisplayListCommandType};
+use super::commands::{
+ ContextRef, DeclareMaskContent, DisplayListCommandHeader, DisplayListCommandRun, DisplayListCommandType,
+ EffectNodeIndex,
+};
use super::effect_clip_plan::EffectClipPlan;
+use super::nested_records::span_bytes;
use super::placement::RunGroups;
use super::summary::{DisplayListSummary, summarize, summary_of_pieces};
use super::tile_keys::{ChunkPlacedInRasterSpace, ContentHash, RecordTable};
use super::validate::validate_tape;
use crate::visual_context::VisualContextTree;
use libipc_rust::wire::{Decode, Encode};
+use std::collections::HashMap;
use std::sync::{Arc, Mutex, OnceLock, PoisonError};
// Room for the spaces a chunk shows in and those of a moment before, which a scroll that comes back needs again.
@@ -257,6 +264,7 @@ pub struct DisplayListStorage {
// they were found to hold for, and found to hold again only for the samples of such an animation.
cached_run_groups: Mutex<Option<(u64, Arc<RunGroups>)>>,
summary: OnceLock<DisplayListSummary>,
+ declaration_of_mask_content_by_mask_effect: OnceLock<HashMap<EffectNodeIndex, ListPosition>>,
}
impl DisplayListStorage {
@@ -278,6 +286,7 @@ impl DisplayListStorage {
effect_clip_plan: OnceLock::new(),
cached_run_groups: Mutex::new(None),
summary: OnceLock::new(),
+ declaration_of_mask_content_by_mask_effect: OnceLock::new(),
})
}
@@ -447,6 +456,27 @@ impl DisplayListStorage {
})
}
+ /// Where the list declares the content of the mask `mask_effect`, if it does. A mask composites the content of
+ /// its last declaration, wherever in the list that is.
+ pub fn declaration_of_mask_content(&self, mask_effect: EffectNodeIndex) -> Option<ListPosition> {
+ self.declaration_of_mask_content_by_mask_effect
+ .get_or_init(|| {
+ self.summary()
+ .mask_declarations
+ .iter()
+ .map(|declaration| (declaration.mask_effect, declaration.record.position))
+ .collect()
+ })
+ .get(&mask_effect)
+ .copied()
+ }
+
+ /// The records the mask `mask_effect` composites as its content, if the list declares any.
+ pub fn records_of_mask_content(&self, mask_effect: EffectNodeIndex) -> Option<&[u8]> {
+ let (_, payload) = self.record_at(self.declaration_of_mask_content(mask_effect)?);
+ Some(span_bytes(payload, read_command::<DeclareMaskContent>(payload).content))
+ }
+
pub fn effect_clip_plan(&self, tree: &VisualContextTree) -> &EffectClipPlan {
self.effect_clip_plan.get_or_init(|| {
EffectClipPlan::new(tree, self.runs()).expect("a display list's runs name live nodes of its tree")
diff --git a/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs b/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs
index 8bfb136a3c5..b52cbe0d58b 100644
--- a/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs
+++ b/Libraries/LibCompositing/Rust/src/display_list/tile_keys.rs
@@ -41,7 +41,7 @@ use crate::visual_context::{
use foldhash::fast::{FixedState, FoldHasher};
use libgfx_rust::{Color, CornerRadii, FloatMatrix4x4, FloatPoint, FloatRect, IntRect};
use std::cell::{Cell, OnceCell, RefCell};
-use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
+use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::hash::{BuildHasher, Hasher};
use std::sync::Arc;
@@ -208,6 +208,9 @@ pub struct TileKeyingOfList<'a> {
/// Per effect, the nearest effect at or around it that the compositor composites or whose blend mode can lower the
/// alpha of what is below it, once the coverage of a tile asks.
nearest_composited_or_alpha_lowering_effect_by_effect_index: OnceCell<Vec<EffectNodeIndex>>,
+ /// Per effect, the nearest mask at or around it whose content reads frame state hashed for the list, once the
+ /// binding of a band asks.
+ nearest_mask_with_content_reading_frame_state_hashed_for_the_list_by_effect_index: OnceCell<Vec<EffectNodeIndex>>,
}
impl<'a> TileKeyingOfList<'a> {
@@ -233,16 +236,58 @@ impl<'a> TileKeyingOfList<'a> {
run_groups: OnceCell::new(),
filters_of_effects: OnceCell::new(),
filters_inside_composited_effects: OnceCell::new(),
- replays_every_record_into_every_tile: layering_obstacles.every_tile_replays_every_record()
- || stack.one_layer_list_cannot_tell_which_records_show_in_tile(),
+ replays_every_record_into_every_tile: stack.one_layer_list_cannot_tell_which_records_show_in_tile(),
tree_sorts_planes_by_depth: layering_obstacles.sorts_planes_by_depth,
frame_state_hash: frame_state_hash_of(display_list, stack, &frame_state),
innermost_composited_effect_by_effect_index,
nearest_composited_or_not_plain_effect_by_effect_index: OnceCell::new(),
nearest_composited_or_alpha_lowering_effect_by_effect_index: OnceCell::new(),
+ nearest_mask_with_content_reading_frame_state_hashed_for_the_list_by_effect_index: OnceCell::new(),
}
}
+ /// The record that declares the content the mask `mask_effect` composites, with its chunk, if the list holds one.
+ fn record_declaring_content_of_mask(
+ &self,
+ mask_effect: EffectNodeIndex,
+ ) -> Option<(&'a ListChunk, &'a ChunkRecord)> {
+ let position = self.display_list.declaration_of_mask_content(mask_effect)?;
+ let chunk = self.display_list.chunk(position.chunk_index);
+ let table = chunk.record_table();
+ let record_index = table
+ .record_indices_between_offsets(position.offset, position.offset + 1)
+ .start;
+ Some((chunk, table.record(record_index)))
+ }
+
+ /// Whether replaying the run reads frame state hashed for the list: in its own records, or in the content of a mask
+ /// it is inside, which is composited with it.
+ fn run_reads_frame_state_hashed_for_the_list(&self, chunk: &ListChunk, run_index: RunIndexInChunk) -> bool {
+ if chunk
+ .record_table()
+ .run_reads_frame_state_hashed_for_the_list(run_index)
+ {
+ return true;
+ }
+ if self.display_list.summary().mask_declarations.is_empty() {
+ return false;
+ }
+ let nearest_mask_by_effect_index = self
+ .nearest_mask_with_content_reading_frame_state_hashed_for_the_list_by_effect_index
+ .get_or_init(|| {
+ nearest_effects_at_or_above_where(self.tree, |effect, node| {
+ matches!(node.data, EffectNodeData::Mask(_))
+ && self
+ .record_declaring_content_of_mask(effect)
+ .is_some_and(|(_, record)| record.reads_frame_state_hashed_for_the_list())
+ })
+ });
+ let effect = chunk.runs()[run_index.0 as usize].context.effect;
+ nearest_mask_by_effect_index
+ .get(effect.0 as usize)
+ .is_some_and(|mask| !mask.is_none())
+ }
+
fn run_groups(&self) -> &RunGroups {
self.run_groups.get_or_init(|| self.display_list.run_groups(self.tree))
}
@@ -589,8 +634,7 @@ enum TileReplayItem {
chunk_index: ChunkIndexInList,
range_index: PlacedRecordRangeIndex,
},
- // The records of a span of a chunk: one that every tile replays, or a record that no placed record range of the band
- // holds, replayed for the mask content it declares.
+ // The records of a span of a chunk, which every tile replays.
RecordSpan {
chunk_index: ChunkIndexInList,
begin_offset: u32,
@@ -633,41 +677,14 @@ struct ChunkHeldByBand {
struct RunReplayedWholeWhereverRunGroupShows {
reach: Reach<IntRect>,
- /// The innermost mask around the run with declared content, whose declarations, and those of the declared masks
- /// around it, replay with the run, or `EffectNodeIndex::NONE`.
- innermost_declared_mask_around: EffectNodeIndex,
-}
-
-/// A mask with declared content around a run that a band replays whole.
-struct DeclaredMaskAroundRunReplayedWhole {
- /// The items that replay its declarations, each with where it is painted and how far it reaches.
- declarations: Vec<(ListPosition, TileReplayItem, Reach<IntRect>)>,
- next_declared_mask_around: EffectNodeIndex,
}
type RunsReplayedWhole = HashMap<(ChunkIndexInList, RunIndexInChunk), RunReplayedWholeWhereverRunGroupShows>;
-/// The masks with declared content, for a band that replays runs whole: where the list declares the content of each, and
-/// per effect the nearest such mask at or around it.
-struct MasksWithDeclaredContent {
- declaration_positions_by_mask: HashMap<EffectNodeIndex, Vec<ListPosition>>,
- nearest_declared_mask_by_effect_index: Vec<EffectNodeIndex>,
-}
-
-impl MasksWithDeclaredContent {
- fn nearest_declared_mask_at_or_above(&self, effect: EffectNodeIndex) -> EffectNodeIndex {
- self.nearest_declared_mask_by_effect_index
- .get(effect.0 as usize)
- .copied()
- .unwrap_or(EffectNodeIndex::NONE)
- }
-}
-
struct BandBoundToListAndGeometry {
/// In the order of their chunks, as the spans of a band are in paint order.
held_chunks: Vec<ChunkHeldByBand>,
runs_replayed_whole: RunsReplayedWhole,
- declared_masks_around_runs_replayed_whole: HashMap<EffectNodeIndex, DeclaredMaskAroundRunReplayedWhole>,
backdrop_reads: BackdropReadsOfBand,
items_replayed_in_every_tile: Option<Vec<(ListPosition, TileReplayItem)>>,
replays_records_reading_frame_state_hashed_for_the_list: bool,
@@ -737,7 +754,7 @@ impl BandBoundToListAndGeometry {
fn for_each_held_item(
&self,
held_chunk: &ChunkHeldByBand,
- mut visit: impl FnMut(ListPosition, TileReplayItem, Reach<IntRect>, EffectNodeIndex),
+ mut visit: impl FnMut(ListPosition, TileReplayItem, Reach<IntRect>),
) {
for &run_index in &held_chunk.held_run_indices {
let ranges_of_run = &held_chunk.placement.ranges_of_each_run[run_index.0 as usize];
@@ -751,7 +768,6 @@ impl BandBoundToListAndGeometry {
range_index: ranges_of_run.whole_run_range_index,
},
run_replayed_whole.reach,
- run_replayed_whole.innermost_declared_mask_around,
);
continue;
}
@@ -768,7 +784,6 @@ impl BandBoundToListAndGeometry {
},
self.backdrop_reads
.reach_extended_through_reads(range.reach, paint_position),
- EffectNodeIndex::NONE,
);
}
}
@@ -922,12 +937,6 @@ fn runs_within_held_offset_ranges(
held_runs
}
-/// Whether `held_offset_ranges`, which are in order and apart, hold the record at `offset`.
-fn offset_is_held(held_offset_ranges: &[(u32, u32)], offset: u32) -> bool {
- let index = held_offset_ranges.partition_point(|&(_, end)| end <= offset);
- held_offset_ranges.get(index).is_some_and(|&(begin, _)| begin <= offset)
-}
-
/// The cells of `shown_rect` that a band keys in a frame: those where it can hold something and holds no tiles yet.
/// The band can hold the base layer and items replayed into every tile at every cell, and the records of a held chunk
/// where the chunk reaches. Where those are more than `MAXIMUM_CELLS_ONE_BAND_KEYS_IN_A_FRAME` cells, the band keys
@@ -1469,6 +1478,16 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
hasher.write_u32(mask.kind as u32);
hasher.write_u32(mask.origin as u32);
hasher.write_bool(mask.masks_backdrop);
+ // NB: A mask composites its content where the mask is, so the content places nothing.
+ match self.list.record_declaring_content_of_mask(effect) {
+ Some((chunk, record)) if scope != EffectHashScope::WhatPlacingReads => {
+ hasher.write_content_hash(record.content_hash_of_bytes);
+ if record.frame_state_read_flags != 0 {
+ self.write_frame_state_read_by_record(&mut hasher, chunk, record);
+ }
+ }
+ _ => hasher.write_u64(u64::MAX),
+ }
}
EffectNodeData::BackgroundColorAnimation => hasher.write_u32(3),
EffectNodeData::Dead => hasher.write_u32(4),
@@ -1740,32 +1759,21 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
}
let held_chunks = self.held_chunks_with_their_placements(held_offset_ranges_by_chunk);
let backdrop_reads = self.backdrop_reads_of_held_runs(stack, band_index, &held_chunks);
- let (runs_replayed_whole, masks_with_declared_content) =
- self.runs_replayed_whole(&held_chunks, &backdrop_reads);
+ let runs_replayed_whole = self.runs_replayed_whole(&held_chunks, &backdrop_reads);
let held_runs_read_frame_state_hashed_for_the_list = held_chunks.iter().any(|held_chunk| {
- let table = display_list.chunk(held_chunk.chunk_index).record_table();
+ let chunk = display_list.chunk(held_chunk.chunk_index);
held_chunk
.held_run_indices
.iter()
- .any(|&run_index| table.run_reads_frame_state_hashed_for_the_list(run_index))
+ .any(|&run_index| self.list.run_reads_frame_state_hashed_for_the_list(chunk, run_index))
});
let mut bound_band = BandBoundToListAndGeometry {
held_chunks,
runs_replayed_whole,
- declared_masks_around_runs_replayed_whole: HashMap::new(),
backdrop_reads,
items_replayed_in_every_tile: None,
replays_records_reading_frame_state_hashed_for_the_list: held_runs_read_frame_state_hashed_for_the_list,
};
-
- if !masks_with_declared_content.declaration_positions_by_mask.is_empty() {
- let (declared_masks, declarations_read_frame_state_hashed_for_the_list) =
- self.declared_masks_around_runs_replayed_whole(&bound_band, &masks_with_declared_content);
- bound_band.declared_masks_around_runs_replayed_whole = declared_masks;
- bound_band.replays_records_reading_frame_state_hashed_for_the_list |=
- declarations_read_frame_state_hashed_for_the_list;
- }
-
bound_band.work_out_reach_of_held_records(display_list);
bound_band
}
@@ -1776,7 +1784,7 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
) -> BandBoundToListAndGeometry {
let list = self.list;
let display_list = list.display_list;
- let mut items_replayed_in_every_tile: Vec<(ListPosition, TileReplayItem)> = held_offset_ranges_by_chunk
+ let items_replayed_in_every_tile: Vec<(ListPosition, TileReplayItem)> = held_offset_ranges_by_chunk
.iter()
.flat_map(|(chunk_index, held_offset_ranges)| {
held_offset_ranges.iter().map(|&(begin_offset, end_offset)| {
@@ -1791,55 +1799,18 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
})
})
.collect();
- let tree = list.tree;
- let mut effect_is_around_held_run = vec![false; tree.effect_nodes.len()];
- let mut replays_records_reading_frame_state_hashed_for_the_list = false;
- for (chunk_index, held_offset_ranges) in held_offset_ranges_by_chunk {
- let chunk = display_list.chunk(*chunk_index);
- let runs = chunk.runs();
- for run_index in runs_within_held_offset_ranges(runs, held_offset_ranges) {
- replays_records_reading_frame_state_hashed_for_the_list |= chunk
- .record_table()
- .run_reads_frame_state_hashed_for_the_list(run_index);
- let mut effect = runs[run_index.0 as usize].context.effect;
- while !effect.is_none() && !effect_is_around_held_run[effect.0 as usize] {
- effect_is_around_held_run[effect.0 as usize] = true;
- effect = tree.effect_nodes[effect.0 as usize].parent;
- }
- }
- }
- for declaration in &display_list.summary().mask_declarations {
- let (mask_effect, declaration_position) = (declaration.mask_effect, declaration.record.position);
- // A declaration can name any effect node.
- let mask_is_around_held_run = effect_is_around_held_run.get(mask_effect.0 as usize) == Some(&true)
- && matches!(tree.effect_nodes[mask_effect.0 as usize].data, EffectNodeData::Mask(_));
- let declaration_is_held = held_offset_ranges_by_chunk
- .binary_search_by_key(&declaration_position.chunk_index, |(chunk_index, _)| *chunk_index)
- .is_ok_and(|position| {
- offset_is_held(&held_offset_ranges_by_chunk[position].1, declaration_position.offset)
+ let replays_records_reading_frame_state_hashed_for_the_list =
+ held_offset_ranges_by_chunk
+ .iter()
+ .any(|(chunk_index, held_offset_ranges)| {
+ let chunk = display_list.chunk(*chunk_index);
+ runs_within_held_offset_ranges(chunk.runs(), held_offset_ranges)
+ .into_iter()
+ .any(|run_index| list.run_reads_frame_state_hashed_for_the_list(chunk, run_index))
});
- if !mask_is_around_held_run || declaration_is_held {
- continue;
- }
- let table = display_list.chunk(declaration_position.chunk_index).record_table();
- let record_index = table
- .record_indices_between_offsets(declaration_position.offset, declaration_position.offset + 1)
- .start;
- replays_records_reading_frame_state_hashed_for_the_list |=
- table.record(record_index).reads_frame_state_hashed_for_the_list();
- items_replayed_in_every_tile.push((
- declaration_position,
- TileReplayItem::RecordSpan {
- chunk_index: declaration_position.chunk_index,
- begin_offset: declaration_position.offset,
- end_offset: table.record(record_index).end_offset,
- },
- ));
- }
BandBoundToListAndGeometry {
held_chunks: Vec::new(),
runs_replayed_whole: HashMap::new(),
- declared_masks_around_runs_replayed_whole: HashMap::new(),
backdrop_reads: BackdropReadsOfBand::new(Vec::new()),
items_replayed_in_every_tile: Some(items_replayed_in_every_tile),
replays_records_reading_frame_state_hashed_for_the_list,
@@ -1908,16 +1879,14 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
BackdropReadsOfBand::new(backdrop_reads_in_paint_order)
}
- /// The held runs that replay whole wherever any run of their run group shows, and the masks with declared content
- /// around them.
+ /// The held runs that replay whole wherever any run of their run group shows.
fn runs_replayed_whole(
&self,
held_chunks: &[ChunkHeldByBand],
backdrop_reads: &BackdropReadsOfBand,
- ) -> (RunsReplayedWhole, MasksWithDeclaredContent) {
+ ) -> RunsReplayedWhole {
let list = self.list;
let display_list = list.display_list;
- let tree = list.tree;
// A mask or a depth sort reads every run of its run group, so those runs replay whole wherever any of them
// shows.
let run_groups = list.run_groups();
@@ -1950,100 +1919,17 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
held_runs_replayed_whole.push((held_chunk.chunk_index, run_index, run_group_index));
}
}
- let mut declaration_positions_by_mask: HashMap<EffectNodeIndex, Vec<ListPosition>> = HashMap::new();
- if !held_runs_replayed_whole.is_empty() {
- for declaration in &display_list.summary().mask_declarations {
- declaration_positions_by_mask
- .entry(declaration.mask_effect)
- .or_default()
- .push(declaration.record.position);
- }
- }
- let nearest_declared_mask_by_effect_index = if declaration_positions_by_mask.is_empty() {
- Vec::new()
- } else {
- nearest_effects_at_or_above_where(tree, |effect, node| {
- matches!(node.data, EffectNodeData::Mask(_)) && declaration_positions_by_mask.contains_key(&effect)
- })
- };
- let masks_with_declared_content = MasksWithDeclaredContent {
- declaration_positions_by_mask,
- nearest_declared_mask_by_effect_index,
- };
- let runs_replayed_whole = held_runs_replayed_whole
+ held_runs_replayed_whole
.into_iter()
.map(|(chunk_index, run_index, run_group_index)| {
let (run_group_reach, first_position) =
reach_and_first_position_of_run_groups_replayed_whole[&run_group_index];
let run_replayed_whole = RunReplayedWholeWhereverRunGroupShows {
reach: backdrop_reads.reach_extended_through_reads(run_group_reach, first_position),
- innermost_declared_mask_around: masks_with_declared_content.nearest_declared_mask_at_or_above(
- display_list.chunk(chunk_index).runs()[run_index.0 as usize]
- .context
- .effect,
- ),
};
((chunk_index, run_index), run_replayed_whole)
})
- .collect();
- (runs_replayed_whole, masks_with_declared_content)
- }
-
- fn declared_masks_around_runs_replayed_whole(
- &self,
- bound_band: &BandBoundToListAndGeometry,
- masks_with_declared_content: &MasksWithDeclaredContent,
- ) -> (HashMap<EffectNodeIndex, DeclaredMaskAroundRunReplayedWhole>, bool) {
- let display_list = self.list.display_list;
- let tree = self.list.tree;
- // Each declared mask is looked at once, and every run inside it shares the chain of declared masks from it
- // out.
- let mut declared_masks: HashMap<EffectNodeIndex, DeclaredMaskAroundRunReplayedWhole> = HashMap::new();
- let mut declared_masks_not_looked_at = Vec::new();
- let mut declared_items_of_mask = HashSet::new();
- let mut declarations_read_frame_state_hashed_for_the_list = false;
- for run_replayed_whole in bound_band.runs_replayed_whole.values() {
- declared_masks_not_looked_at.clear();
- let mut mask = run_replayed_whole.innermost_declared_mask_around;
- while !mask.is_none() && !declared_masks.contains_key(&mask) {
- declared_masks_not_looked_at.push(mask);
- mask = masks_with_declared_content
- .nearest_declared_mask_at_or_above(tree.effect_nodes[mask.0 as usize].parent);
- }
- for &mask in &declared_masks_not_looked_at {
- let next_declared_mask_around = masks_with_declared_content
- .nearest_declared_mask_at_or_above(tree.effect_nodes[mask.0 as usize].parent);
- let mut declarations: Vec<(ListPosition, TileReplayItem, Reach<IntRect>)> = Vec::new();
- declared_items_of_mask.clear();
- for &declaration_position in &masks_with_declared_content.declaration_positions_by_mask[&mask] {
- let table = display_list.chunk(declaration_position.chunk_index).record_table();
- let record_index = table
- .record_indices_between_offsets(declaration_position.offset, declaration_position.offset + 1)
- .start;
- let record = table.record(record_index);
- declarations_read_frame_state_hashed_for_the_list |= record.reads_frame_state_hashed_for_the_list();
- // A declaration replays alone, as every layer of the band that holds records inside the mask
- // replays it, while the records painted with it in its run go into the layer they are painted in.
- let item = TileReplayItem::RecordSpan {
- chunk_index: declaration_position.chunk_index,
- begin_offset: record.offset,
- end_offset: record.end_offset,
- };
- if !declared_items_of_mask.insert(item) {
- continue;
- }
- declarations.push((bound_band.span_of(item).begin, item, bound_band.reach_of_item(item)));
- }
- declared_masks.insert(
- mask,
- DeclaredMaskAroundRunReplayedWhole {
- declarations,
- next_declared_mask_around,
- },
- );
- }
- }
- (declared_masks, declarations_read_frame_state_hashed_for_the_list)
+ .collect()
}
/// The tiles of `band_index` bound to the list and the geometry of the frame and to the band in `stack`, with no
@@ -2150,12 +2036,8 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
let new_cells_area = new_coords
.iter()
.fold(IntRect::default(), |cells, coord| cells.united(coord.cell_rect()));
- // Per layer that items go into in the cell, the items, and the declared masks whose declarations those items hold.
- type ItemsOfLayerInCell = (
- LayerIndex,
- Vec<(ListPosition, TileReplayItem, Reach<IntRect>)>,
- HashSet<EffectNodeIndex>,
- );
+ // Per layer that items go into in the cell, the items.
+ type ItemsOfLayerInCell = (LayerIndex, Vec<(ListPosition, TileReplayItem, Reach<IntRect>)>);
struct BinOfCell<'a> {
cuts: CutsOfCell<'a>,
position_of_layer_by_count_of_cuts_below: Vec<Option<usize>>,
@@ -2176,10 +2058,7 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
)
})
.collect();
- let mut add_to_bins = |paint_position: ListPosition,
- item: TileReplayItem,
- reach: Reach<IntRect>,
- innermost_declared_mask_around_item: EffectNodeIndex| {
+ let mut add_to_bins = |paint_position: ListPosition, item: TileReplayItem, reach: Reach<IntRect>| {
let reach_in_new_cells = reach.part_of(new_cells_area);
if reach_in_new_cells.is_empty() {
return;
@@ -2198,27 +2077,21 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
let position_of_layer = match bin.position_of_layer_by_count_of_cuts_below[count_of_cuts_below] {
Some(position) => position,
None => {
- bin.items_by_layer.push((layer_index, Vec::new(), HashSet::new()));
+ bin.items_by_layer.push((layer_index, Vec::new()));
let position = bin.items_by_layer.len() - 1;
bin.position_of_layer_by_count_of_cuts_below[count_of_cuts_below] = Some(position);
position
}
};
- let (_, items_of_layer, declared_masks_of_layer) = &mut bin.items_by_layer[position_of_layer];
- items_of_layer.push((paint_position, item, reach));
- // Where the layer holds the declarations of a mask, it holds those of the masks around it too.
- let mut mask = innermost_declared_mask_around_item;
- while !mask.is_none() && declared_masks_of_layer.insert(mask) {
- let declared_mask = &bound_band.declared_masks_around_runs_replayed_whole[&mask];
- items_of_layer.extend_from_slice(&declared_mask.declarations);
- mask = declared_mask.next_declared_mask_around;
- }
+ bin.items_by_layer[position_of_layer]
+ .1
+ .push((paint_position, item, reach));
});
};
match &bound_band.items_replayed_in_every_tile {
Some(items_replayed_in_every_tile) => {
for &(paint_position, item) in items_replayed_in_every_tile {
- add_to_bins(paint_position, item, Reach::Anywhere, EffectNodeIndex::NONE);
+ add_to_bins(paint_position, item, Reach::Anywhere);
}
}
None => {
@@ -2240,16 +2113,16 @@ impl<'a> TileKeyingOfRasterSpace<'a> {
} = bin;
// The base layer is the band's layer below all cuts.
if let Some(base_layer) = base_layer
- && !bin.iter().any(|(layer_index, _, _)| *layer_index == base_layer)
+ && !bin.iter().any(|(layer_index, _)| *layer_index == base_layer)
{
- bin.push((base_layer, Vec::new(), HashSet::new()));
+ bin.push((base_layer, Vec::new()));
}
let cell = coord.cell_rect();
let raster_margin_in_device_pixels = bound_band.backdrop_reads.raster_margin_of_cell(cell);
let cuts = cuts_of_cell.barrier_cuts();
let tiles = bin
.into_iter()
- .map(|(layer_index, mut items_of_layer, _)| {
+ .map(|(layer_index, mut items_of_layer)| {
items_of_layer.sort_unstable_by_key(|(paint_position, item, _)| (*paint_position, *item));
items_of_layer.dedup_by_key(|(_, item, _)| *item);
let content_bounds =
@@ -2340,78 +2213,11 @@ mod tests {
const RED: Color = Color::from_rgb(255, 0, 0);
const BLUE: Color = Color::from_rgb(0, 0, 255);
- // The recorder declares a mask's content under the effects of what the mask holds, so no page has a declaration made
- // around the mask.
- #[test]
- fn a_mask_declared_around_its_mask_is_replayed_with_what_it_masks() {
- use crate::visual_context::{MaskData, MaskLayerOrigin};
- let (mut tree, root) = tree_with_root_isolation_effect(1.0);
- let masked = tree.append_effect_node_under(
- root,
- EffectNodeData::Mask(MaskData {
- rect: IntRect::new(0, 0, 100, 100),
- kind: libgfx_rust::MaskKind::Alpha,
- origin: MaskLayerOrigin::CssMaskLayers,
- masks_backdrop: false,
- }),
- );
- let mut list = ListOfOneChunk::default().with(fill(VIEWPORT, GREEN), root);
- let declaration_position = ListPosition::new(ChunkIndexInList(0), list.builder.byte_size() as u32);
- let declaration = list.builder.begin_group::<DeclareMaskContent>(Vec::new());
- list.builder.append(&fill(IntRect::new(0, 0, 50, 50), RED), &[], root);
- let content = list.builder.group_content_span(&declaration);
- list.builder.finish_group(
- declaration,
- &DeclareMaskContent {
- rect: IntRect::new(0, 0, 100, 100),
- effect: masked.effect,
- content,
- },
- root,
- );
- let masked_position = ListPosition::new(ChunkIndexInList(0), list.builder.byte_size() as u32);
- list = list.with(fill(IntRect::new(10, 10, 80, 80), BLUE), masked);
-
- let display_list = DisplayListStorage::of_builder(&list.builder);
- let stack = plan_layer_stack(&LayerStackInputs {
- list: &display_list,
- tree: &tree,
- scroll_offsets: &[],
- viewport_rect: VIEWPORT,
- })
- .stack;
- assert_eq!(stack.why_list_is_one_layer, None);
- let band = BandIndex(
- stack
- .bands
- .iter()
- .position(|band| band.record_spans.iter().any(|span| span.contains(masked_position)))
- .unwrap(),
- );
- let (band_tile_keys, _) = band_tile_keys_after_frames_showing(
- (&display_list, &tree, &stack),
- RasterSpaceIndex::VIEWPORT,
- band,
- &[VIEWPORT],
- );
- let tile_with_masked_content = band_tile_keys
- .tiles_within(TileCoord::new(0, 0).cell_rect())
- .find(|tile| {
- band_tile_keys
- .record_spans_of_tiles([*tile])
- .iter()
- .any(|span| span.contains(masked_position))
- })
- .unwrap();
- let spans = band_tile_keys.record_spans_of_tiles([tile_with_masked_content]);
- assert!(spans.iter().any(|span| span.contains(declaration_position)));
- assert!(spans.windows(2).all(|pair| pair[0].end <= pair[1].begin));
- }
-
- // The recorder declares a mask's content in the run of the masked box's own background. A layer above a cut inside
- // the mask replays the declaration, but the background stays in the layer below the cut, as it was painted there.
+ // The recorder declares a mask's content in the run of the masked box's own background. The compositor composites
+ // a mask around a layer of its own, so no tile inside the mask replays the declaration or the records painted with
+ // it, and the mask itself is keyed with the content.
#[test]
- fn a_layer_above_a_cut_inside_a_mask_replays_its_declaration_without_the_rest_of_its_run() {
+ fn a_mask_the_compositor_composites_is_keyed_with_the_content_it_declares_which_no_tile_inside_it_replays() {
use crate::visual_context::{MaskData, MaskLayerOrigin};
let (mut tree, root) = tree_with_root_isolation_effect(1.0);
let masked = tree.append_effect_node_under(
@@ -2426,53 +2232,69 @@ mod tests {
let faded = tree.append_effect_node_under(masked, effects(1.0, CompositingAndBlendingOperator::Normal));
tree.set_visual_animations(vec![opacity_animation_of(faded.effect, 0.0, 1.0)]);
- let mut list = ListOfOneChunk::default();
- let declaration_position = ListPosition::new(ChunkIndexInList(0), list.builder.byte_size() as u32);
- let declaration = list.builder.begin_group::<DeclareMaskContent>(Vec::new());
- list.builder
- .append(&fill(IntRect::new(0, 0, 100, 400), GREEN), &[], masked);
- let content = list.builder.group_content_span(&declaration);
- list.builder.finish_group(
- declaration,
- &DeclareMaskContent {
- rect: IntRect::new(0, 0, 100, 400),
- effect: masked.effect,
- content,
- },
- masked,
- );
- let background_position = ListPosition::new(ChunkIndexInList(0), list.builder.byte_size() as u32);
- list = list
- .with(fill(IntRect::new(0, 0, 100, 400), BLUE), masked)
- .with(fill(IntRect::new(0, 110, 10, 30), GREEN), faded);
- let box_after_cut_position = ListPosition::new(ChunkIndexInList(0), list.builder.byte_size() as u32);
- list = list.with(fill(IntRect::new(10, 210, 80, 80), RED), masked);
-
- let display_list = list.storage();
- let stack = stack_of(&display_list, &tree.with_visual_animation_samples(0));
- let band = stack
- .bands
- .iter()
- .position(|band| {
- band.record_spans
+ let content_hash_of_mask_declaring_content_of = |color_of_mask_content: Color| {
+ let mut list = ListOfOneChunk::default();
+ let declaration_position = ListPosition::new(ChunkIndexInList(0), list.builder.byte_size() as u32);
+ let declaration = list.builder.begin_group::<DeclareMaskContent>(Vec::new());
+ list.builder
+ .append(&fill(IntRect::new(0, 0, 100, 400), color_of_mask_content), &[], masked);
+ let content = list.builder.group_content_span(&declaration);
+ list.builder.finish_group(
+ declaration,
+ &DeclareMaskContent {
+ rect: IntRect::new(0, 0, 100, 400),
+ effect: masked.effect,
+ content,
+ },
+ masked,
+ );
+ let background_position = ListPosition::new(ChunkIndexInList(0), list.builder.byte_size() as u32);
+ list = list
+ .with(fill(IntRect::new(0, 0, 100, 400), BLUE), masked)
+ .with(fill(IntRect::new(0, 110, 10, 30), GREEN), faded);
+ let box_after_cut_position = ListPosition::new(ChunkIndexInList(0), list.builder.byte_size() as u32);
+ list = list.with(fill(IntRect::new(10, 210, 80, 80), RED), masked);
+
+ let display_list = list.storage();
+ let stack = stack_of(&display_list, &tree.with_visual_animation_samples(0));
+ assert!(
+ stack
+ .composited_effects
.iter()
- .any(|span| span.contains(box_after_cut_position))
- })
- .unwrap();
- let (band_tile_keys, _) = band_tile_keys_after_frames_showing(
- (&display_list, &tree, &stack),
- RasterSpaceIndex::VIEWPORT,
- BandIndex(band),
- &[VIEWPORT],
+ .any(|composited| composited.effect == masked.effect)
+ );
+ let band = stack
+ .bands
+ .iter()
+ .position(|band| {
+ band.record_spans
+ .iter()
+ .any(|span| span.contains(box_after_cut_position))
+ })
+ .unwrap();
+ let list_keying = TileKeyingOfList::new(&display_list, &tree, &stack, NO_FRAME_STATE);
+ let geometry = geometry_of_space(&tree, &stack, RasterSpaceIndex::VIEWPORT);
+ let raster_space = TileKeyingOfRasterSpace::new(&list_keying, &geometry);
+ let mut band_tile_keys = raster_space.bind_band(&stack, BandIndex(band));
+ key_band(&raster_space, &mut band_tile_keys, &stack, BandIndex(band), VIEWPORT);
+ let spans = band_tile_keys.record_spans_of_tiles(
+ band_tile_keys
+ .tiles_within(TileCoord::new(0, 0).cell_rect())
+ .filter(|tile| tile.layer_index != stack.bands[band].layer_below_all_cuts),
+ );
+ assert!(spans.iter().any(|span| span.contains(box_after_cut_position)));
+ assert!(!spans.iter().any(|span| span.contains(declaration_position)));
+ assert!(!spans.iter().any(|span| span.contains(background_position)));
+ raster_space.content_hash_of_composited_effect(masked.effect)
+ };
+ assert_eq!(
+ content_hash_of_mask_declaring_content_of(GREEN),
+ content_hash_of_mask_declaring_content_of(GREEN)
);
- let spans = band_tile_keys.record_spans_of_tiles(
- band_tile_keys
- .tiles_within(TileCoord::new(0, 0).cell_rect())
- .filter(|tile| tile.layer_index != stack.bands[band].layer_below_all_cuts),
+ assert_ne!(
+ content_hash_of_mask_declaring_content_of(GREEN),
+ content_hash_of_mask_declaring_content_of(RED)
);
- assert!(spans.iter().any(|span| span.contains(box_after_cut_position)));
- assert!(spans.iter().any(|span| span.contains(declaration_position)));
- assert!(!spans.iter().any(|span| span.contains(background_position)));
}
fn stack_of(display_list: &DisplayListStorage, tree: &VisualContextTree) -> LayerStack {
@@ -3181,7 +3003,7 @@ mod tests {
VIEWPORT,
display_list.whole_span(),
Some(WhyListIsOneLayer::FrameIsNotDrawnAsPlanned),
- LayeringObstacles::of(&display_list, &tree),
+ LayeringObstacles::of(&tree),
);
assert!(stack.one_layer_list_cannot_tell_which_records_show_in_tile());
let list_keying = TileKeyingOfList::new(&display_list, &tree, &stack, NO_FRAME_STATE);
@@ -3309,15 +3131,6 @@ mod tests {
runs_within_held_offset_ranges(&runs, &held_offset_ranges),
held_runs_one_by_one
);
- let held_offset_ranges = [(8, 24), (40, 56), (80, 112)];
- for offset in 0..120 {
- assert_eq!(
- offset_is_held(&held_offset_ranges, offset),
- held_offset_ranges
- .iter()
- .any(|&(begin, end)| begin <= offset && offset < end)
- );
- }
}
// A tree from another process can chain clips and effects as deep as it holds nodes.
@@ -3609,18 +3422,9 @@ mod tests {
}
}
- fn span_from_run_to_end_of_list(display_list: &DisplayListStorage, chunk_index: u32, run_index: usize) -> ListSpan {
- let chunk_index = ChunkIndexInList(chunk_index);
- ListSpan {
- begin: ListPosition::new(chunk_index, display_list.chunk(chunk_index).runs()[run_index].offset),
- end: display_list.whole_span().end,
- }
- }
-
- // A band of what a mask holds can hold the declaration of the mask's content, leave it out, or also hold other runs
- // of the chunk of the declaration, which draw away from the cells the masked content reaches.
+ // A band of what a mask holds can leave out the declaration of the mask's content, which another band holds.
#[test]
- fn a_tile_of_masked_content_replays_the_declaration_of_its_mask_and_no_other_run_of_its_chunk() {
+ fn a_tile_of_masked_content_is_keyed_with_the_content_its_mask_declares_in_a_chunk_its_band_does_not_hold() {
use crate::visual_context::{MaskData, MaskLayerOrigin};
let (mut tree, root) = tree_with_root_isolation_effect(1.0);
let masked = tree.append_effect_node_under(
@@ -3632,77 +3436,59 @@ mod tests {
masks_backdrop: false,
}),
);
- let isolated = tree.append_effect_node_under(
- root,
- EffectNodeData::Effects(EffectsData {
- isolation: true,
- opacity: 1.0,
- blend_mode: CompositingAndBlendingOperator::Normal,
- filter: None,
- backdrop_filter: None,
- }),
- );
- // The first run of the first chunk is a box, and the second the declaration, which both draw in the cell to the
- // right of the cell of the masked box.
- let mut builder = DisplayListBuilder::new();
- builder.append(&fill(IntRect::new(700, 300, 50, 50), GREEN), &[], isolated);
- let declaration = builder.begin_group::<DeclareMaskContent>(Vec::new());
- builder.append(&fill(IntRect::new(600, 0, 50, 50), RED), &[], root);
- let content = builder.group_content_span(&declaration);
- builder.finish_group(
- declaration,
- &DeclareMaskContent {
- rect: IntRect::new(600, 0, 100, 100),
- effect: masked.effect,
- content,
- },
- root,
- );
- let display_list = DisplayListStorage::of_chunks(vec![
- Arc::new(ListChunk::copied(builder.bytes(), builder.command_runs(), 0)),
- chunk_of(fill(IntRect::new(10, 10, 80, 80), BLUE), masked),
- ])
- .unwrap();
- let declaration_and_masked_box = {
- let mut stack = LayerStack::one_layer_replaying_whole_list(
+ let content_hash_of_tile_of_masked_box_with_mask_content_of = |color_of_mask_content: Color| {
+ let mut builder = DisplayListBuilder::new();
+ let declaration = builder.begin_group::<DeclareMaskContent>(Vec::new());
+ builder.append(&fill(IntRect::new(0, 0, 50, 50), color_of_mask_content), &[], root);
+ let content = builder.group_content_span(&declaration);
+ builder.finish_group(
+ declaration,
+ &DeclareMaskContent {
+ rect: IntRect::new(0, 0, 100, 100),
+ effect: masked.effect,
+ content,
+ },
+ root,
+ );
+ let display_list = DisplayListStorage::of_chunks(vec![
+ Arc::new(ListChunk::copied(builder.bytes(), builder.command_runs(), 0)),
+ chunk_of(fill(IntRect::new(10, 10, 80, 80), BLUE), masked),
+ ])
+ .unwrap();
+ let mut masked_box_alone = LayerStack::one_layer_replaying_whole_list(
VIEWPORT,
display_list.whole_span(),
None,
LayeringObstacles::default(),
);
- stack.bands[0].record_spans = vec![span_from_run_to_end_of_list(&display_list, 0, 1)];
- stack
- };
- let mut masked_box_alone = declaration_and_masked_box.clone();
- masked_box_alone.bands[0].record_spans = vec![span_from_run_to_end_of_list(&display_list, 1, 0)];
- let mut both_runs_and_masked_box = declaration_and_masked_box.clone();
- both_runs_and_masked_box.bands[0].record_spans = vec![display_list.whole_span()];
-
- let cell_of_masked_box = TileCoord::new(0, 0);
- for stack in [
- &declaration_and_masked_box,
- &masked_box_alone,
- &both_runs_and_masked_box,
- ] {
+ let chunk_of_masked_box = ChunkIndexInList(1);
+ masked_box_alone.bands[0].record_spans = vec![ListSpan {
+ begin: ListPosition::new(chunk_of_masked_box, 0),
+ end: display_list.whole_span().end,
+ }];
let (band_tile_keys, _) = band_tile_keys_after_frames_showing(
- (&display_list, &tree, stack),
+ (&display_list, &tree, &masked_box_alone),
RasterSpaceIndex::VIEWPORT,
BandIndex(0),
&[VIEWPORT],
);
- let spans_of_masked_box =
- band_tile_keys.record_spans_of_tiles(band_tile_keys.tile(cell_of_masked_box, LayerIndex(0)));
- let declaration_position = ListPosition::new(
- ChunkIndexInList(0),
- display_list.chunk(ChunkIndexInList(0)).runs()[1].offset,
- );
- let first_box_position = ListPosition::new(ChunkIndexInList(0), 0);
+ let tile_of_masked_box = band_tile_keys.tile(TileCoord::new(0, 0), LayerIndex(0)).unwrap();
+ let declaration_position = ListPosition::new(ChunkIndexInList(0), 0);
assert!(
- spans_of_masked_box
+ !band_tile_keys
+ .record_spans_of_tiles([tile_of_masked_box])
.iter()
.any(|span| span.contains(declaration_position))
);
- assert!(!spans_of_masked_box.iter().any(|span| span.contains(first_box_position)));
- }
+ tile_of_masked_box.content_hash
+ };
+ assert_eq!(
+ content_hash_of_tile_of_masked_box_with_mask_content_of(GREEN),
+ content_hash_of_tile_of_masked_box_with_mask_content_of(GREEN)
+ );
+ assert_ne!(
+ content_hash_of_tile_of_masked_box_with_mask_content_of(GREEN),
+ content_hash_of_tile_of_masked_box_with_mask_content_of(RED)
+ );
}
}
diff --git a/Services/Compositor/Rust/src/overlays.rs b/Services/Compositor/Rust/src/overlays.rs
index f4d90a15c4d..232853b94f8 100644
--- a/Services/Compositor/Rust/src/overlays.rs
+++ b/Services/Compositor/Rust/src/overlays.rs
@@ -13,9 +13,7 @@ use libcompositing_rust::display_list::commands::{
FillPath, FillRect, FontResourceId, OptionalFloatRect, PathPaintKind, ReplayLayer, StrokePath,
};
use libcompositing_rust::display_list::ffi_bytes::FfiBytes;
-use libcompositing_rust::display_list::replay::{
- ListReplay, RecordsContext, ReplayFrame, ReplayPainter, replay_records,
-};
+use libcompositing_rust::display_list::replay::{RecordsContext, ReplayFrame, ReplayPainter, replay_records};
use libcompositing_rust::overlays::{
PausedDebuggerOverlayGeometry, paused_debugger_overlay_geometry, picture_in_picture_controls_geometry,
scaled_overlay_length,
@@ -335,10 +333,9 @@ impl OverlayRecords {
fn replay_overlay_records(records: &AlignedRecords, painter: &mut impl ReplayPainter) {
OVERLAY_TREE.with(|tree| {
- let list = ListReplay::new(tree);
let frame = ReplayFrame::unscrolled(0);
let context = RecordsContext {
- list_replay: &list,
+ tree,
frame: &frame,
to_root_matrix_of_inline_clip_space: &|_| None,
};
diff --git a/Services/Compositor/Rust/src/presenting/layers.rs b/Services/Compositor/Rust/src/presenting/layers.rs
index b5009da40ed..d5cd39aad32 100644
--- a/Services/Compositor/Rust/src/presenting/layers.rs
+++ b/Services/Compositor/Rust/src/presenting/layers.rs
@@ -510,7 +510,7 @@ impl ContextLayers {
of_list_and_tree.obstacles
}
_ => {
- let obstacles = LayeringObstacles::of(display_list.storage(), tree);
+ let obstacles = LayeringObstacles::of(tree);
self.layering_obstacles_of_frames_not_drawn_as_planned = Some(LayeringObstaclesOfListAndTree {
display_list: Rc::downgrade(display_list),
tree_copy_number: tree.copy.number(),
@@ -2200,13 +2200,9 @@ mod tests {
.as_mut()
.expect("the obstacles of the list and the tree are kept")
.obstacles
- .mask_declared_under_effects_its_mask_is_not_under = true;
+ .sorts_planes_by_depth = false;
let stack_of_next_frame = layers.one_layer_stack_of_frame(&display_list, &tree, VIEWPORT, not_as_planned);
- assert!(
- stack_of_next_frame
- .layering_obstacles
- .mask_declared_under_effects_its_mask_is_not_under
- );
+ assert!(!stack_of_next_frame.layering_obstacles.sorts_planes_by_depth);
let another_tree = Arc::new((*tree).clone());
let stack_of_another_tree =
layers.one_layer_stack_of_frame(&display_list, &another_tree, VIEWPORT, not_as_planned);
diff --git a/Tests/LibWeb/Ref/expected/visual-context/abspos-escaping-overflow-clip-that-hides-its-masked-ancestor-ref.html b/Tests/LibWeb/Ref/expected/visual-context/abspos-escaping-overflow-clip-that-hides-its-masked-ancestor-ref.html
new file mode 100644
index 00000000000..02d40343298
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/visual-context/abspos-escaping-overflow-clip-that-hides-its-masked-ancestor-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+body {
+ margin: 0;
+ background: white;
+}
+.child {
+ position: absolute;
+ left: 0;
+ top: 200px;
+ width: 100px;
+ height: 100px;
+ background: green;
+}
+</style>
+<div class="child"></div>
diff --git a/Tests/LibWeb/Ref/input/visual-context/abspos-escaping-overflow-clip-that-hides-its-masked-ancestor.html b/Tests/LibWeb/Ref/input/visual-context/abspos-escaping-overflow-clip-that-hides-its-masked-ancestor.html
new file mode 100644
index 00000000000..2dda31755fc
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/visual-context/abspos-escaping-overflow-clip-that-hides-its-masked-ancestor.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<link rel="match" href="../../expected/visual-context/abspos-escaping-overflow-clip-that-hides-its-masked-ancestor-ref.html">
+<style>
+body {
+ margin: 0;
+ background: white;
+}
+.containing-block {
+ position: relative;
+ width: 100px;
+ height: 300px;
+}
+.clip {
+ overflow: hidden;
+ width: 100px;
+ height: 100px;
+}
+.spacer {
+ height: 200px;
+}
+.masked {
+ mask-image: linear-gradient(black, black);
+ width: 100px;
+ height: 100px;
+ background: red;
+}
+.escaping {
+ position: absolute;
+ left: 0;
+ top: 200px;
+ width: 100px;
+ height: 100px;
+ background: green;
+}
+</style>
+<!-- The overflow clip hides the masked box, which sits below it. The absolute child skips the clip and shows
+ where the masked box is, so the mask still has to composite its content for the child. -->
+<div class="containing-block">
+ <div class="clip">
+ <div class="spacer"></div>
+ <div class="masked">
+ <div class="escaping"></div>
+ </div>
+ </div>
+</div>