Skip to main content

PaintList

Struct PaintList 

Source
pub struct PaintList {
    pub commands: Vec<PaintCommand>,
    pub pending_textures: Vec<PendingTexture>,
}
Expand description

一帧的绘制指令列表。 保留式:跨帧复用,只有脏的 RenderObject 会重建自己那部分。

Fields§

§commands: Vec<PaintCommand>§pending_textures: Vec<PendingTexture>

侧通道:本帧 RenderObject 声明的新增待注册纹理 renderer render 开始前 drain,调 register_image(幂等) 不走 PaintCommand 避免大数据 clone 污染绘制协议

Implementations§

Source§

impl PaintList

Source

pub fn new() -> Self

Source

pub fn clear(&mut self)

Source

pub fn push(&mut self, cmd: PaintCommand)

Source

pub fn push_texture(&mut self, texture_id: u32, data: Rc<ImageData>)

声明一条待注册纹理(renderer render 开始前 drain)。静态图片 / SVG 走这里。

Source

pub fn push_texture_with_meta( &mut self, texture_id: u32, data: Rc<ImageData>, meta: TextureFrameMeta, )

声明一条带视频帧元数据的待注册纹理。 元数据必须一路带到 Renderer::register_image,否则帧年龄没有落点。

Source

pub fn extend(&mut self, other: &PaintList)

追加另一个 list 的所有 commands(多 layer 合成用)

Source

pub fn rect(&mut self, rect: Rect, color: Color)

直角矩形

Source

pub fn rounded_rect(&mut self, rect: Rect, color: Color, radius: f32)

圆角矩形

Source

pub fn text( &mut self, text: impl Into<Rc<str>>, font_size: f32, color: Color, position: Point, )

高层文字命令(runtime 层展开成 glyph quads)

Source

pub fn text_wrapped( &mut self, text: impl Into<Rc<str>>, font_size: f32, color: Color, position: Point, max_width: Option<f32>, )

带可选 soft wrap 的高层文字命令

Source

pub fn text_span( &mut self, text: &Rc<str>, range: (usize, usize), font_size: f32, color: Color, position: Point, )

共享整串 + 字节区间的高层文字命令

编辑器等“一行文本切多个语法 span“的场景使用:整行 Rc<str> 被所有 span 命令共享,只携带区间,shaping 缓存命中时零字符串分配。

Source

pub fn box_shadow( &mut self, rect: Rect, offset: Point, blur_radius: f32, spread: f32, color: Color, corner_radius: f32, )

T0-2:GPU SDF BoxShadow — 单 pass shader blur(无需多 render pass)

旧 N 层半透明近似已被替代。现在发 1 个 BoxShadow 命令, renderer 复用 Rect pipeline,shader 里 smoothstep 过渡区从 1px 扩展到 blur_radius, 实现真正的 Gaussian-like blur。

  • rect:子元素 bounding box(阴影的“中心形状“)
  • offset:阴影相对 rect 的偏移(dx, dy)
  • blur_radius:模糊半径(逻辑像素);shader smoothstep 区间 = ±blur_radius
  • spread:阴影扩张(+外扩/-内缩)
  • color:阴影颜色(通常带 alpha,如 Color::rgba(0,0,0,0.25))
  • corner_radius:子元素圆角(阴影同形状)
Source

pub fn linear_gradient( &mut self, rect: Rect, start: Point, end: Point, from: Color, to: Color, corner_radius: f32, )

两色线性渐变(可带圆角)。

Source

pub fn radial_gradient( &mut self, rect: Rect, center: Point, radial_radius: f32, from: Color, to: Color, corner_radius: f32, )

两色径向渐变(可带圆角)。

Source

pub fn mask(&mut self, rect: Rect, texture_id: u32, uv: [f32; 4], alpha: f32)

纹理 alpha mask(destination-in):裁掉此前已绘制内容的透明度。

Source

pub fn inset_shadow( &mut self, rect: Rect, color: Color, radius: f32, blur_radius: f32, )

内阴影(绘制在 rect 内部边缘)

Source

pub fn backdrop_blur( &mut self, rect: Rect, radius: f32, blur_radius: f32, tint: Color, )

背景模糊(对 rect 内已绘制内容做 13-tap blur;tint.a 可加磨砂色调)

Source

pub fn push_blend_mode(&mut self, mode: BlendMode)

压入混合模式(作用于后续矩形族命令)

Source

pub fn pop_blend_mode(&mut self)

恢复上一个混合模式

Source

pub fn push_clip(&mut self, rect: Rect)

压入裁剪矩形(之后的绘制被裁在该矩形内,直到 pop_clip)

Source

pub fn push_clip_rrect(&mut self, rect: Rect, radius: f32)

压入圆角矩形裁剪(之后的绘制被裁在该圆角矩形内,直到 pop_clip)

Source

pub fn pop_clip(&mut self)

弹出最近一次 push_clip

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Trait Implementations§

Source§

impl Clone for PaintList

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PaintList

Source§

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

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

impl Default for PaintList

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.