Bug 1778036 - Switch public primitive API to be clip-chain based r=gfx-reviewers,lsalzman

This is mostly just changing a small number of structs and function
params (most of the work has been done in previous patches).

Differential Revision: https://phabricator.services.mozilla.com/D150987
This commit is contained in:
Glenn Watson 2022-07-05 20:52:31 +00:00
Родитель 5c3d556f14
Коммит 5bd787a0ba
8 изменённых файлов: 70 добавлений и 67 удалений

Просмотреть файл

@ -107,11 +107,11 @@ type WrColorDepth = ColorDepth;
type WrColorRange = ColorRange;
#[inline]
fn clip_chain_id_to_webrender(id: u64, pipeline_id: WrPipelineId) -> ClipId {
fn clip_chain_id_to_webrender(id: u64, pipeline_id: WrPipelineId) -> ClipChainId {
if id == ROOT_CLIP_CHAIN {
ClipId::root(pipeline_id)
ClipChainId::INVALID
} else {
ClipId::ClipChain(ClipChainId(id, pipeline_id))
ClipChainId(id, pipeline_id)
}
}
@ -126,7 +126,7 @@ impl WrSpaceAndClipChain {
//Warning: special case here to support dummy clip chain
SpaceAndClipInfo {
spatial_id: self.space.to_webrender(pipeline_id),
clip_id: clip_chain_id_to_webrender(self.clip_chain, pipeline_id),
clip_chain_id: clip_chain_id_to_webrender(self.clip_chain, pipeline_id),
}
}
}
@ -2831,7 +2831,7 @@ fn common_item_properties_for_rect(
// early-return here for empty rects. I couldn't figure out why, but
// it's pretty harmless to feed these through, so, uh, we do?
clip_rect,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
}
@ -2930,7 +2930,7 @@ pub extern "C" fn wr_dp_push_backdrop_filter(
let prim_info = CommonItemProperties {
clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -2954,7 +2954,7 @@ pub extern "C" fn wr_dp_push_clear_rect(
let prim_info = CommonItemProperties {
clip_rect,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(true, /* prefer_compositor_surface */ false),
};
@ -3028,7 +3028,7 @@ pub extern "C" fn wr_dp_push_image(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags,
};
@ -3065,7 +3065,7 @@ pub extern "C" fn wr_dp_push_repeating_image(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3112,7 +3112,7 @@ pub extern "C" fn wr_dp_push_yuv_planar_image(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags2(
is_backface_visible,
@ -3155,7 +3155,7 @@ pub extern "C" fn wr_dp_push_yuv_NV12_image(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags2(
is_backface_visible,
@ -3198,7 +3198,7 @@ pub extern "C" fn wr_dp_push_yuv_P010_image(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags2(
is_backface_visible,
@ -3240,7 +3240,7 @@ pub extern "C" fn wr_dp_push_yuv_interleaved_image(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags2(
is_backface_visible,
@ -3282,7 +3282,7 @@ pub extern "C" fn wr_dp_push_text(
let prim_info = CommonItemProperties {
clip_rect: clip,
spatial_id: space_and_clip.spatial_id,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3337,7 +3337,7 @@ pub extern "C" fn wr_dp_push_line(
let prim_info = CommonItemProperties {
clip_rect: *clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3378,7 +3378,7 @@ pub extern "C" fn wr_dp_push_border(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3427,7 +3427,7 @@ pub extern "C" fn wr_dp_push_border_image(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3482,7 +3482,7 @@ pub extern "C" fn wr_dp_push_border_gradient(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3541,7 +3541,7 @@ pub extern "C" fn wr_dp_push_border_radial_gradient(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3600,7 +3600,7 @@ pub extern "C" fn wr_dp_push_border_conic_gradient(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3640,7 +3640,7 @@ pub extern "C" fn wr_dp_push_linear_gradient(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3680,7 +3680,7 @@ pub extern "C" fn wr_dp_push_radial_gradient(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3720,7 +3720,7 @@ pub extern "C" fn wr_dp_push_conic_gradient(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};
@ -3752,7 +3752,7 @@ pub extern "C" fn wr_dp_push_box_shadow(
let prim_info = CommonItemProperties {
clip_rect: clip,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: prim_flags(is_backface_visible, /* prefer_compositor_surface */ false),
};

Просмотреть файл

@ -82,7 +82,7 @@ impl App {
let space_and_clip = SpaceAndClipInfo {
spatial_id,
clip_id: ClipId::root(pipeline_id),
clip_chain_id: ClipChainId::INVALID,
};
let clip_bounds = LayoutRect::from_size(bounds.size());
let complex_clip = ComplexClipRegion {
@ -94,6 +94,7 @@ impl App {
space_and_clip.spatial_id,
complex_clip,
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
// Fill it with a white rect
builder.push_rect(
@ -101,7 +102,7 @@ impl App {
LayoutRect::from_size(bounds.size()),
SpaceAndClipInfo {
spatial_id,
clip_id,
clip_chain_id,
}
),
LayoutRect::from_size(bounds.size()),

Просмотреть файл

@ -59,11 +59,12 @@ impl Example for App {
root_space_and_clip.spatial_id,
complex,
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
builder.push_rect(
&CommonItemProperties::new(
(100, 100).to(200, 200),
SpaceAndClipInfo { spatial_id, clip_id },
SpaceAndClipInfo { spatial_id, clip_chain_id },
),
(100, 100).to(200, 200),
ColorF::new(0.0, 1.0, 0.0, 1.0),
@ -72,7 +73,7 @@ impl Example for App {
builder.push_rect(
&CommonItemProperties::new(
(250, 100).to(350, 200),
SpaceAndClipInfo { spatial_id, clip_id },
SpaceAndClipInfo { spatial_id, clip_chain_id },
),
(250, 100).to(350, 200),
ColorF::new(0.0, 1.0, 0.0, 1.0),
@ -95,7 +96,7 @@ impl Example for App {
builder.push_border(
&CommonItemProperties::new(
bounds,
SpaceAndClipInfo { spatial_id, clip_id },
SpaceAndClipInfo { spatial_id, clip_chain_id },
),
bounds,
border_widths,

Просмотреть файл

@ -66,7 +66,7 @@ impl Example for App {
);
let space_and_clip1 = SpaceAndClipInfo {
spatial_id: space1,
clip_id: root_space_and_clip.clip_id,
clip_chain_id: root_space_and_clip.clip_chain_id,
};
// now put some content into it.
@ -122,7 +122,7 @@ impl Example for App {
);
let space_and_clip2 = SpaceAndClipInfo {
spatial_id: space2,
clip_id: root_space_and_clip.clip_id,
clip_chain_id: root_space_and_clip.clip_chain_id,
};
// give it a giant gray background just to distinguish it and to easily
@ -170,7 +170,7 @@ impl Example for App {
(50, 350).by(50, 50),
SpaceAndClipInfo {
spatial_id: sticky_id,
clip_id: space_and_clip2.clip_id,
clip_chain_id: space_and_clip2.clip_chain_id,
},
);
builder.push_hit_test(

Просмотреть файл

@ -1088,7 +1088,7 @@ impl<'a> SceneBuilder<'a> {
self.add_rect_clip_node(
ClipId::root(iframe_pipeline_id),
info.space_and_clip.spatial_id,
Some(info.space_and_clip.clip_id),
Some(info.space_and_clip.clip_chain_id),
&info.clip_rect,
);
@ -1187,8 +1187,7 @@ impl<'a> SceneBuilder<'a> {
bounds: Option<&LayoutRect>,
) -> (LayoutPrimitiveInfo, LayoutRect, SpatialNodeIndex, ClipChainId) {
let spatial_node_index = self.get_space(common.spatial_id);
let clip_chain_id = self.get_clip_chain(common.clip_id);
let clip_chain_id = self.get_clip_chain(ClipId::ClipChain(common.clip_chain_id));
let current_offset = self.current_offset(spatial_node_index);
let unsnapped_clip_rect = common.clip_rect.translate(current_offset);
@ -1736,7 +1735,7 @@ impl<'a> SceneBuilder<'a> {
self.add_backdrop_filter(
spatial_node_index,
info.common.clip_id,
ClipId::ClipChain(info.common.clip_chain_id),
clip_chain_id,
&layout,
filters,
@ -1770,9 +1769,7 @@ impl<'a> SceneBuilder<'a> {
profile_scope!("push_shadow");
let spatial_node_index = self.get_space(info.space_and_clip.spatial_id);
let clip_chain_id = self.get_clip_chain(
info.space_and_clip.clip_id,
);
let clip_chain_id = self.get_clip_chain(ClipId::ClipChain(info.space_and_clip.clip_chain_id));
self.push_shadow(
info.shadow,
@ -2739,10 +2736,11 @@ impl<'a> SceneBuilder<'a> {
&mut self,
new_node_id: ClipId,
spatial_id: SpatialId,
parent: Option<ClipId>,
parent: Option<api::ClipChainId>,
clip_rect: &LayoutRect,
) {
let spatial_node_index = self.get_space(spatial_id);
let parent = parent.map(|id| ClipId::ClipChain(id));
let snapped_clip_rect = self.snap_rect(
clip_rect,

Просмотреть файл

@ -72,7 +72,7 @@ pub struct CommonItemProperties {
/// (solid colors, background-images, gradients, etc).
pub clip_rect: LayoutRect,
/// Additional clips
pub clip_id: ClipId,
pub clip_chain_id: ClipChainId,
/// The coordinate-space the item is in (yes, it can be really granular)
pub spatial_id: SpatialId,
/// Various flags describing properties of this primitive.
@ -88,7 +88,7 @@ impl CommonItemProperties {
Self {
clip_rect,
spatial_id: space_and_clip.spatial_id,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
flags: PrimitiveFlags::default(),
}
}
@ -103,7 +103,7 @@ impl CommonItemProperties {
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
pub struct SpaceAndClipInfo {
pub spatial_id: SpatialId,
pub clip_id: ClipId,
pub clip_chain_id: ClipChainId,
}
impl SpaceAndClipInfo {
@ -112,7 +112,7 @@ impl SpaceAndClipInfo {
pub fn root_scroll(pipeline_id: PipelineId) -> Self {
SpaceAndClipInfo {
spatial_id: SpatialId::root_scroll_node(pipeline_id),
clip_id: ClipId::root(pipeline_id),
clip_chain_id: ClipChainId::INVALID,
}
}
}

Просмотреть файл

@ -109,7 +109,7 @@ impl<'a> RawtestHarness<'a> {
let space_and_clip = SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id);
CommonItemProperties {
clip_rect,
clip_id: space_and_clip.clip_id,
clip_chain_id: space_and_clip.clip_chain_id,
spatial_id: space_and_clip.spatial_id,
flags: PrimitiveFlags::default(),
}
@ -118,12 +118,12 @@ impl<'a> RawtestHarness<'a> {
fn make_common_properties_with_clip_and_spatial(
&self,
clip_rect: LayoutRect,
clip_id: ClipId,
clip_chain_id: ClipChainId,
spatial_id: SpatialId
) -> CommonItemProperties {
CommonItemProperties {
clip_rect,
clip_id,
clip_chain_id,
spatial_id,
flags: PrimitiveFlags::default(),
}
@ -310,10 +310,11 @@ impl<'a> RawtestHarness<'a> {
root_space_and_clip.spatial_id,
rect(40., 41., 200., 201.).to_box2d(),
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
let info = CommonItemProperties {
clip_rect: rect(0.0, 0.0, 800.0, 800.0).to_box2d(),
clip_id,
clip_chain_id,
spatial_id: root_space_and_clip.spatial_id,
flags: PrimitiveFlags::default(),
};
@ -394,10 +395,11 @@ impl<'a> RawtestHarness<'a> {
root_space_and_clip.spatial_id,
rect(-1000.0, -1000.0, 2000.0, 2000.0).to_box2d(),
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
let info = CommonItemProperties {
clip_rect: rect(10.0, 10.0, 400.0, 400.0).to_box2d(),
clip_id,
clip_chain_id,
spatial_id: root_space_and_clip.spatial_id,
flags: PrimitiveFlags::default(),
};
@ -487,10 +489,11 @@ impl<'a> RawtestHarness<'a> {
root_space_and_clip.spatial_id,
rect(-1000.0, -1000.0, 2000.0, 2000.0).to_box2d(),
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
let info = CommonItemProperties {
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0).to_box2d(),
clip_id,
clip_chain_id,
spatial_id: root_space_and_clip.spatial_id,
flags: PrimitiveFlags::default(),
};
@ -532,10 +535,11 @@ impl<'a> RawtestHarness<'a> {
root_space_and_clip.spatial_id,
rect(-1000.0, -1000.0, 2000.0, 2000.0).to_box2d(),
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
let info = CommonItemProperties {
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0).to_box2d(),
clip_id,
clip_chain_id,
spatial_id: root_space_and_clip.spatial_id,
flags: PrimitiveFlags::default(),
};
@ -579,10 +583,11 @@ impl<'a> RawtestHarness<'a> {
root_space_and_clip.spatial_id,
rect(-1000.0, -1000.0, 2000.0, 2000.0).to_box2d(),
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
let info = CommonItemProperties {
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0).to_box2d(),
clip_id,
clip_chain_id,
spatial_id: root_space_and_clip.spatial_id,
flags: PrimitiveFlags::default(),
};
@ -1070,10 +1075,11 @@ impl<'a> RawtestHarness<'a> {
SpatialId::root_scroll_node(self.wrench.root_pipeline_id),
rect(110., 120., 200., 200.).to_box2d(),
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
builder.push_rect(
&self.make_common_properties_with_clip_and_spatial(
rect(100., 100., 100., 100.).to_box2d(),
clip_id,
clip_chain_id,
spatial_id),
rect(100., 100., 100., 100.).to_box2d(),
ColorF::new(0.0, 0.0, 1.0, 1.0),
@ -1085,14 +1091,15 @@ impl<'a> RawtestHarness<'a> {
spatial_id,
rect(80., 80., 90., 90.).to_box2d(),
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
let space_and_clip = SpaceAndClipInfo {
spatial_id,
clip_id
clip_chain_id,
};
builder.push_rect(
&self.make_common_properties_with_clip_and_spatial(
rect(110., 110., 50., 50.).to_box2d(),
clip_id,
clip_chain_id,
spatial_id),
rect(110., 110., 50., 50.).to_box2d(),
ColorF::new(0.0, 1.0, 0.0, 1.0),
@ -1108,7 +1115,7 @@ impl<'a> RawtestHarness<'a> {
);
let info = CommonItemProperties {
clip_rect: rect(110., 110., 50., 2.).to_box2d(),
clip_id,
clip_chain_id,
spatial_id,
flags: PrimitiveFlags::default(),
};
@ -1128,10 +1135,11 @@ impl<'a> RawtestHarness<'a> {
spatial_id,
rect(80., 80., 100., 100.).to_box2d(),
);
let clip_chain_id = builder.define_clip_chain(None, [clip_id]);
builder.push_rect(
&self.make_common_properties_with_clip_and_spatial(
rect(150., 150., 100., 100.).to_box2d(),
clip_id,
clip_chain_id,
spatial_id),
rect(150., 150., 100., 100.).to_box2d(),
ColorF::new(0.0, 0.0, 1.0, 1.0),

Просмотреть файл

@ -469,7 +469,7 @@ impl YamlFrameReader {
builder.begin();
let mut info = CommonItemProperties {
clip_rect: LayoutRect::zero(),
clip_id: ClipId::invalid(),
clip_chain_id: ClipChainId::INVALID,
spatial_id: SpatialId::new(0, PipelineId::dummy()),
flags: PrimitiveFlags::default(),
};
@ -839,15 +839,10 @@ impl YamlFrameReader {
&info.clip_rect
);
let clip_chain_id = match info.clip_id {
ClipId::Clip(..) => panic!("bug: must be a clip-chain"),
ClipId::ClipChain(id) => id,
};
if let Some(tag) = self.to_hit_testing_tag(&item["hit-testing-tag"]) {
dl.push_hit_test(
info.clip_rect,
clip_chain_id,
info.clip_chain_id,
info.spatial_id,
info.flags,
tag,
@ -1494,7 +1489,7 @@ impl YamlFrameReader {
info.clip_rect,
&SpaceAndClipInfo {
spatial_id: info.spatial_id,
clip_id: info.clip_id
clip_chain_id: info.clip_chain_id
},
pipeline_id,
ignore
@ -1561,7 +1556,7 @@ impl YamlFrameReader {
let mut info = CommonItemProperties {
clip_rect,
clip_id: ClipId::ClipChain(clip_chain_id),
clip_chain_id,
spatial_id: self.top_space(),
flags,
};
@ -1774,7 +1769,7 @@ impl YamlFrameReader {
let color = yaml["color"].as_colorf().unwrap_or(ColorF::BLACK);
dl.push_shadow(
&SpaceAndClipInfo { spatial_id: info.spatial_id, clip_id: info.clip_id },
&SpaceAndClipInfo { spatial_id: info.spatial_id, clip_chain_id: info.clip_chain_id },
Shadow {
blur_radius,
offset,