pub enum DisplayOp {
Show 13 variants
Save,
Restore,
ClipRect(LayoutRect),
ClipRoundedRect {
rect: LayoutRect,
radius: LayoutUnit,
},
Translate(LayoutPoint),
Transform([LayoutUnit; 16]),
DrawRect {
rect: LayoutRect,
fill: Option<Fill>,
stroke: Option<Stroke>,
corner_radius: LayoutUnit,
shadow: Option<BoxShadow>,
bounds: LayoutRect,
node_id: Option<NodeId>,
},
DrawText {
text: String,
position: LayoutPoint,
size: LayoutUnit,
color: Color,
bounds: LayoutRect,
node_id: Option<NodeId>,
underline: bool,
caret_index: Option<usize>,
},
DrawRichText {
runs: Vec<TextRun>,
position: LayoutPoint,
bounds: LayoutRect,
node_id: Option<NodeId>,
caret_index: Option<usize>,
},
DrawImage {
rect: LayoutRect,
source: String,
fit: ImageFit,
bounds: LayoutRect,
node_id: Option<NodeId>,
},
DrawPath {
path: String,
fill: Option<Fill>,
stroke: Option<Stroke>,
bounds: LayoutRect,
node_id: Option<NodeId>,
},
DrawSvg {
content: String,
fill: Option<Fill>,
stroke: Option<Stroke>,
bounds: LayoutRect,
node_id: Option<NodeId>,
},
DrawSurface {
rect: LayoutRect,
surface_id: u64,
position: u64,
bounds: LayoutRect,
node_id: Option<NodeId>,
},
}Expand description
A single rendering command in a DisplayList.
Display ops are executed in order by a Renderer backend. The save/restore
stack model means that clip and transform ops affect all subsequent draw ops
until the matching Restore.
Most draw ops carry a bounds field (the layout rectangle of the owning node)
and an optional node_id for hit-testing and debugging.
Variants§
Save
Pushes the current graphics state (clip region, transform) onto the stack.
Restore
Pops the graphics state, reverting clip and transform to the last Save.
ClipRect(LayoutRect)
Sets a rectangular clip region. Drawing outside this rectangle is discarded.
ClipRoundedRect
Sets a rounded-rectangle clip region.
Fields
rect: LayoutRectThe clip rectangle.
radius: LayoutUnitThe corner radius for the rounded clip.
Translate(LayoutPoint)
Translates the coordinate origin by the given offset.
Transform([LayoutUnit; 16])
Applies a 4x4 column-major transform matrix to the coordinate space.
DrawRect
Draws a filled and/or stroked rectangle with optional rounded corners and shadow.
Fields
rect: LayoutRectThe rectangle to draw.
corner_radius: LayoutUnitCorner radius (0.0 for sharp corners).
bounds: LayoutRectThe layout bounds of the owning node (used for hit-testing).
DrawText
Draws a single-style text string.
Fields
position: LayoutPointThe top-left position of the text.
size: LayoutUnitFont size in logical pixels.
bounds: LayoutRectThe layout bounds of the owning node.
DrawRichText
Draws multi-style (rich) text.
Fields
position: LayoutPointThe top-left position of the text block.
bounds: LayoutRectThe layout bounds of the owning node.
DrawImage
Draws a raster image.
Fields
rect: LayoutRectThe rectangle to draw the image into.
bounds: LayoutRectThe layout bounds of the owning node.
DrawPath
Draws an SVG-style path string.
Fields
bounds: LayoutRectThe layout bounds of the owning node.
DrawSvg
Draws inline SVG content.
Fields
bounds: LayoutRectThe layout bounds of the owning node.
DrawSurface
Blits an external surface (video frame, embedded web view, etc.).
Fields
rect: LayoutRectThe rectangle to draw the surface into.
bounds: LayoutRectThe layout bounds of the owning node.