Open
Description
Currently, every display item looks like this:
pub struct DisplayItem {
pub item: SpecificDisplayItem,
pub clip_and_scroll: ClipAndScrollInfo,
pub info: PrimitiveInfo<LayoutPixel>,
}
pub struct ClipAndScrollInfo {
pub scroll_node_id: ClipId,
pub clip_node_id: Option<ClipId>,
}
pub struct PrimitiveInfo<T> {
pub rect: TypedRect<f32, T>,
pub clip_rect: TypedRect<f32, T>,
pub is_backface_visible: bool,
pub tag: Option<ItemTag>,
}
The SpecificDisplayItem
is a giant enum of all possible things we may need, including stuff that only describes the metadata, or context for other items:
- the reference & sticky frames don't need any clip information, like clip_rect or clip_node_id
- the pop* variants don't need any accompanying information at all
- setting gradient stops don't need any "standard" primitive info
- etc
This RFC is for making a top-level enum like this:
enum DisplayItem {
// stacking context and shadows
Push/PopStackingContext,
Push/PopShadow,
// reference frames, sticky and scroll frames
DefineReference/Sticky/ScrollFrame
// clips, clip chains, and gradient stops
DefineClip/ClipChain,
SetGradientStops,
Primitive {
primitive: SpecificPrimitive,
clip_and_scroll: ClipAndScrollInfo,
info: PrimitiveInfo<LayoutPixel>,
}
}
enum SpecificPrimitive {
Rectangle,
Image,
Text,
Line,
/// etc
}
The result I expect from these changes would be:
- cleaner API that matches the internal logic. The clients don't need to guess if a
clip_node_id
is used for a particular item, ignored, or asserted upon, for example. - reduced overhead for serializing, sending over, and deserializing DL data.