Skip to content

Commit bd1322e

Browse files
committed
Explicitly optional ClipID for stacking contexts
1 parent ad1fd58 commit bd1322e

16 files changed

+60
-45
lines changed

examples/alpha_perf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ impl Example for App {
3535

3636
builder.push_stacking_context(
3737
&info,
38-
&space_and_clip,
38+
space_and_clip.spatial_id,
39+
None,
3940
TransformStyle::Flat,
4041
MixBlendMode::Normal,
4142
&[],

examples/animation.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ impl App {
6363
None,
6464
);
6565

66-
let space_and_clip = SpaceAndClipInfo {
67-
spatial_id,
68-
clip_id: ClipId::root(pipeline_id),
69-
};
70-
7166
builder.push_stacking_context(
7267
&LayoutPrimitiveInfo::new(LayoutRect::zero()),
73-
&space_and_clip,
68+
spatial_id,
69+
None,
7470
TransformStyle::Flat,
7571
MixBlendMode::Normal,
7672
&filters,
7773
RasterSpace::Screen,
7874
);
7975

76+
let space_and_clip = SpaceAndClipInfo {
77+
spatial_id,
78+
clip_id: ClipId::root(pipeline_id),
79+
};
8080
let clip_bounds = LayoutRect::new(LayoutPoint::zero(), bounds.size);
8181
let complex_clip = ComplexClipRegion {
8282
rect: clip_bounds,

examples/basic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ impl Example for App {
196196

197197
builder.push_stacking_context(
198198
&info,
199-
&root_space_and_clip,
199+
spatial_id,
200+
None,
200201
TransformStyle::Flat,
201202
MixBlendMode::Normal,
202203
&[],

examples/blob.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ impl Example for App {
224224

225225
builder.push_stacking_context(
226226
&api::LayoutPrimitiveInfo::new(bounds),
227-
&space_and_clip,
227+
space_and_clip.spatial_id,
228+
None,
228229
api::TransformStyle::Flat,
229230
api::MixBlendMode::Normal,
230231
&[],

examples/document.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ impl Example for App {
114114

115115
builder.push_stacking_context(
116116
&LayoutPrimitiveInfo::new(doc.content_rect),
117-
&space_and_clip,
117+
space_and_clip.spatial_id,
118+
None,
118119
TransformStyle::Flat,
119120
MixBlendMode::Normal,
120121
&[],

examples/frame_output.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ impl App {
115115

116116
builder.push_stacking_context(
117117
&info,
118-
&space_and_clip,
118+
space_and_clip.spatial_id,
119+
None,
119120
TransformStyle::Flat,
120121
MixBlendMode::Normal,
121122
&[],
@@ -160,7 +161,8 @@ impl Example for App {
160161

161162
builder.push_stacking_context(
162163
&info,
163-
&space_and_clip,
164+
space_and_clip.spatial_id,
165+
None,
164166
TransformStyle::Flat,
165167
MixBlendMode::Normal,
166168
&[],

examples/iframe.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ impl Example for App {
4040
let info = LayoutPrimitiveInfo::new(sub_bounds);
4141
sub_builder.push_stacking_context(
4242
&info,
43-
&space_and_clip,
43+
space_and_clip.spatial_id,
44+
None,
4445
TransformStyle::Flat,
4546
MixBlendMode::Normal,
4647
&[],
@@ -73,7 +74,8 @@ impl Example for App {
7374
let info = LayoutPrimitiveInfo::new(sub_bounds);
7475
builder.push_stacking_context(
7576
&info,
76-
&space_and_clip,
77+
space_and_clip.spatial_id,
78+
None,
7779
TransformStyle::Flat,
7880
MixBlendMode::Normal,
7981
&[],

examples/image_resize.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ impl Example for App {
4343

4444
builder.push_stacking_context(
4545
&info,
46-
&space_and_clip,
46+
space_and_clip.spatial_id,
47+
None,
4748
TransformStyle::Flat,
4849
MixBlendMode::Normal,
4950
&[],

examples/multiwindow.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ impl Window {
193193
let info = LayoutPrimitiveInfo::new(bounds);
194194
builder.push_stacking_context(
195195
&info,
196-
&space_and_clip,
196+
space_and_clip.spatial_id,
197+
None,
197198
TransformStyle::Flat,
198199
MixBlendMode::Normal,
199200
&[],

examples/scrolling.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ impl Example for App {
3636
let root_space_and_clip = SpaceAndClipInfo::root_scroll(pipeline_id);
3737
builder.push_stacking_context(
3838
&info,
39-
&root_space_and_clip,
39+
root_space_and_clip.spatial_id,
40+
None,
4041
TransformStyle::Flat,
4142
MixBlendMode::Normal,
4243
&[],
@@ -49,7 +50,8 @@ impl Example for App {
4950
let scrollbox = (0, 0).to(300, 400);
5051
builder.push_stacking_context(
5152
&LayoutPrimitiveInfo::new((10, 10).by(0, 0)),
52-
&root_space_and_clip,
53+
root_space_and_clip.spatial_id,
54+
None,
5355
TransformStyle::Flat,
5456
MixBlendMode::Normal,
5557
&[],

examples/texture_cache_stress.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ impl Example for App {
100100

101101
builder.push_stacking_context(
102102
&info,
103-
&space_and_clip,
103+
space_and_clip.spatial_id,
104+
None,
104105
TransformStyle::Flat,
105106
MixBlendMode::Normal,
106107
&[],

examples/yuv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ impl Example for App {
9797

9898
builder.push_stacking_context(
9999
&info,
100-
&space_and_clip,
100+
space_and_clip.spatial_id,
101+
None,
101102
TransformStyle::Flat,
102103
MixBlendMode::Normal,
103104
&[],

webrender/src/display_list_flattener.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ impl<'a> DisplayListFlattener<'a> {
432432
TransformStyle::Flat,
433433
true,
434434
true,
435-
&ScrollNodeAndClipChain::new(ROOT_SPATIAL_NODE_INDEX, ClipChainId::NONE),
435+
ROOT_SPATIAL_NODE_INDEX,
436+
ClipChainId::NONE,
436437
RasterSpace::Screen,
437438
);
438439

@@ -589,9 +590,9 @@ impl<'a> DisplayListFlattener<'a> {
589590
traversal: &mut BuiltDisplayListIter<'a>,
590591
pipeline_id: PipelineId,
591592
stacking_context: &StackingContext,
593+
spatial_node_index: SpatialNodeIndex,
592594
origin: LayoutPoint,
593595
filters: ItemRange<FilterOp>,
594-
clip_and_scroll: &ScrollNodeAndClipChain,
595596
reference_frame_relative_offset: &LayoutVector2D,
596597
is_backface_visible: bool,
597598
) {
@@ -610,13 +611,19 @@ impl<'a> DisplayListFlattener<'a> {
610611
)
611612
};
612613

614+
let clip_chain_id = match stacking_context.clip_id {
615+
Some(clip_id) => self.id_to_index_mapper.get_clip_chain_id(clip_id),
616+
None => ClipChainId::NONE,
617+
};
618+
613619
self.push_stacking_context(
614620
pipeline_id,
615621
composition_operations,
616622
stacking_context.transform_style,
617623
is_backface_visible,
618624
false,
619-
clip_and_scroll,
625+
spatial_node_index,
626+
clip_chain_id,
620627
stacking_context.raster_space,
621628
);
622629

@@ -831,24 +838,14 @@ impl<'a> DisplayListFlattener<'a> {
831838
);
832839
}
833840
SpecificDisplayItem::PushStackingContext(ref info) => {
834-
// Special handling of clip ids here: for Stacking Context it means
835-
// forcing the intermediate surface and applying the clips on top.
836-
// We only do this if the `ClipId` is non-root, otherwise we assume
837-
// all the items to inherit the clips anyway.
838-
let mut clip_and_scroll = clip_and_scroll;
839-
if space_and_clip.clip_id.is_root() {
840-
debug_assert_eq!(space_and_clip.clip_id, ClipId::root(pipeline_id));
841-
clip_and_scroll.clip_chain_id = ClipChainId::NONE;
842-
}
843-
844841
let mut subtraversal = item.sub_iter();
845842
self.flatten_stacking_context(
846843
&mut subtraversal,
847844
pipeline_id,
848845
&info.stacking_context,
846+
clip_and_scroll.spatial_node_index,
849847
item.rect().origin,
850848
item.filters(),
851-
&clip_and_scroll,
852849
&reference_frame_relative_offset,
853850
prim_info.is_backface_visible,
854851
);
@@ -1210,7 +1207,8 @@ impl<'a> DisplayListFlattener<'a> {
12101207
transform_style: TransformStyle,
12111208
is_backface_visible: bool,
12121209
is_pipeline_root: bool,
1213-
clip_and_scroll: &ScrollNodeAndClipChain,
1210+
spatial_node_index: SpatialNodeIndex,
1211+
clip_chain_id: ClipChainId,
12141212
requested_raster_space: RasterSpace,
12151213
) {
12161214
// Check if this stacking context is the root of a pipeline, and the caller
@@ -1279,7 +1277,7 @@ impl<'a> DisplayListFlattener<'a> {
12791277
// has a clip node. In the future, we may decide during
12801278
// prepare step to skip the intermediate surface if the
12811279
// clip node doesn't affect the stacking context rect.
1282-
let should_isolate = clip_and_scroll.clip_chain_id != ClipChainId::NONE;
1280+
let should_isolate = clip_chain_id != ClipChainId::NONE;
12831281

12841282
// Push the SC onto the stack, so we know how to handle things in
12851283
// pop_stacking_context.
@@ -1288,8 +1286,8 @@ impl<'a> DisplayListFlattener<'a> {
12881286
pipeline_id,
12891287
is_backface_visible,
12901288
requested_raster_space,
1291-
spatial_node_index: clip_and_scroll.spatial_node_index,
1292-
clip_chain_id: clip_and_scroll.clip_chain_id,
1289+
spatial_node_index,
1290+
clip_chain_id,
12931291
frame_output_pipeline_id,
12941292
composite_ops,
12951293
should_isolate,

webrender_api/src/display_item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ pub struct PushStackingContextDisplayItem {
541541
pub struct StackingContext {
542542
pub transform_style: TransformStyle,
543543
pub mix_blend_mode: MixBlendMode,
544+
pub clip_id: Option<ClipId>,
544545
pub raster_space: RasterSpace,
545546
} // IMPLICIT: filters: Vec<FilterOp>
546547

webrender_api/src/display_list.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,8 @@ impl DisplayListBuilder {
12981298
pub fn push_stacking_context(
12991299
&mut self,
13001300
layout: &LayoutPrimitiveInfo,
1301-
space_and_clip: &SpaceAndClipInfo,
1301+
spatial_id: SpatialId,
1302+
clip_id: Option<ClipId>,
13021303
transform_style: TransformStyle,
13031304
mix_blend_mode: MixBlendMode,
13041305
filters: &[FilterOp],
@@ -1308,11 +1309,15 @@ impl DisplayListBuilder {
13081309
stacking_context: StackingContext {
13091310
transform_style,
13101311
mix_blend_mode,
1312+
clip_id,
13111313
raster_space,
13121314
},
13131315
});
13141316

1315-
self.push_item(&item, layout, space_and_clip);
1317+
self.push_item(&item, layout, &SpaceAndClipInfo {
1318+
spatial_id,
1319+
clip_id: ClipId::invalid(),
1320+
});
13161321
self.push_iter(filters);
13171322
}
13181323

wrench/src/yaml_frame_reader.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,17 +1754,14 @@ impl YamlFrameReader {
17541754
}
17551755

17561756
let filters = yaml["filters"].as_vec_filter_op().unwrap_or(vec![]);
1757-
let root_clip_id = ClipId::root(dl.pipeline_id);
17581757

17591758
info.rect = bounds;
17601759
info.clip_rect = bounds;
17611760

17621761
dl.push_stacking_context(
17631762
&info,
1764-
&SpaceAndClipInfo {
1765-
spatial_id: *self.spatial_id_stack.last().unwrap(),
1766-
clip_id: clip_node_id.unwrap_or(root_clip_id),
1767-
},
1763+
*self.spatial_id_stack.last().unwrap(),
1764+
clip_node_id,
17681765
transform_style,
17691766
mix_blend_mode,
17701767
&filters,

0 commit comments

Comments
 (0)