Skip to main content

DisplayOp

Enum DisplayOp 

Source
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: LayoutRect

The clip rectangle.

§radius: LayoutUnit

The 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: LayoutRect

The rectangle to draw.

§fill: Option<Fill>

Optional interior fill.

§stroke: Option<Stroke>

Optional border stroke.

§corner_radius: LayoutUnit

Corner radius (0.0 for sharp corners).

§shadow: Option<BoxShadow>

Optional drop shadow.

§bounds: LayoutRect

The layout bounds of the owning node (used for hit-testing).

§node_id: Option<NodeId>

The IR node that produced this draw call (for debugging).

§

DrawText

Draws a single-style text string.

Fields

§text: String

The text to render.

§position: LayoutPoint

The top-left position of the text.

§size: LayoutUnit

Font size in logical pixels.

§color: Color

Text foreground color.

§bounds: LayoutRect

The layout bounds of the owning node.

§node_id: Option<NodeId>

The IR node that produced this draw call.

§underline: bool

Whether to underline the text.

§caret_index: Option<usize>

If set, a text cursor is drawn at this byte index.

§

DrawRichText

Draws multi-style (rich) text.

Fields

§runs: Vec<TextRun>

The styled text runs, in order.

§position: LayoutPoint

The top-left position of the text block.

§bounds: LayoutRect

The layout bounds of the owning node.

§node_id: Option<NodeId>

The IR node that produced this draw call.

§caret_index: Option<usize>

If set, a text cursor is drawn at this byte index.

§

DrawImage

Draws a raster image.

Fields

§rect: LayoutRect

The rectangle to draw the image into.

§source: String

Image source: file path, URL, or asset identifier.

§fit: ImageFit

How the image scales to fit rect.

§bounds: LayoutRect

The layout bounds of the owning node.

§node_id: Option<NodeId>

The IR node that produced this draw call.

§

DrawPath

Draws an SVG-style path string.

Fields

§path: String

SVG path data (e.g., "M 0 0 L 10 10 Z").

§fill: Option<Fill>

Optional fill for the path interior.

§stroke: Option<Stroke>

Optional stroke for the path outline.

§bounds: LayoutRect

The layout bounds of the owning node.

§node_id: Option<NodeId>

The IR node that produced this draw call.

§

DrawSvg

Draws inline SVG content.

Fields

§content: String

The raw SVG markup.

§fill: Option<Fill>

Optional fill color override.

§stroke: Option<Stroke>

Optional stroke color override.

§bounds: LayoutRect

The layout bounds of the owning node.

§node_id: Option<NodeId>

The IR node that produced this draw call.

§

DrawSurface

Blits an external surface (video frame, embedded web view, etc.).

Fields

§rect: LayoutRect

The rectangle to draw the surface into.

§surface_id: u64

Platform-specific surface identifier.

§position: u64

Position/frame index within the surface (e.g., video frame number).

§bounds: LayoutRect

The layout bounds of the owning node.

§node_id: Option<NodeId>

The IR node that produced this draw call.

Trait Implementations§

Source§

impl Clone for DisplayOp

Source§

fn clone(&self) -> DisplayOp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DisplayOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DisplayOp

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for DisplayOp

Source§

fn eq(&self, other: &DisplayOp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for DisplayOp

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DisplayOp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,