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
impl PaintList
pub fn new() -> Self
pub fn clear(&mut self)
pub fn push(&mut self, cmd: PaintCommand)
Sourcepub fn push_texture(&mut self, texture_id: u32, data: Rc<ImageData>)
pub fn push_texture(&mut self, texture_id: u32, data: Rc<ImageData>)
声明一条待注册纹理(renderer render 开始前 drain)。静态图片 / SVG 走这里。
Sourcepub fn push_texture_with_meta(
&mut self,
texture_id: u32,
data: Rc<ImageData>,
meta: TextureFrameMeta,
)
pub fn push_texture_with_meta( &mut self, texture_id: u32, data: Rc<ImageData>, meta: TextureFrameMeta, )
声明一条带视频帧元数据的待注册纹理。
元数据必须一路带到 Renderer::register_image,否则帧年龄没有落点。
Sourcepub fn rounded_rect(&mut self, rect: Rect, color: Color, radius: f32)
pub fn rounded_rect(&mut self, rect: Rect, color: Color, radius: f32)
圆角矩形
Sourcepub fn text(
&mut self,
text: impl Into<Rc<str>>,
font_size: f32,
color: Color,
position: Point,
)
pub fn text( &mut self, text: impl Into<Rc<str>>, font_size: f32, color: Color, position: Point, )
高层文字命令(runtime 层展开成 glyph quads)
Sourcepub fn text_wrapped(
&mut self,
text: impl Into<Rc<str>>,
font_size: f32,
color: Color,
position: Point,
max_width: Option<f32>,
)
pub fn text_wrapped( &mut self, text: impl Into<Rc<str>>, font_size: f32, color: Color, position: Point, max_width: Option<f32>, )
带可选 soft wrap 的高层文字命令
Sourcepub fn text_span(
&mut self,
text: &Rc<str>,
range: (usize, usize),
font_size: f32,
color: Color,
position: Point,
)
pub fn text_span( &mut self, text: &Rc<str>, range: (usize, usize), font_size: f32, color: Color, position: Point, )
共享整串 + 字节区间的高层文字命令
编辑器等“一行文本切多个语法 span“的场景使用:整行 Rc<str> 被所有
span 命令共享,只携带区间,shaping 缓存命中时零字符串分配。
Sourcepub fn box_shadow(
&mut self,
rect: Rect,
offset: Point,
blur_radius: f32,
spread: f32,
color: Color,
corner_radius: f32,
)
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_radiusspread:阴影扩张(+外扩/-内缩)color:阴影颜色(通常带 alpha,如 Color::rgba(0,0,0,0.25))corner_radius:子元素圆角(阴影同形状)
Sourcepub fn linear_gradient(
&mut self,
rect: Rect,
start: Point,
end: Point,
from: Color,
to: Color,
corner_radius: f32,
)
pub fn linear_gradient( &mut self, rect: Rect, start: Point, end: Point, from: Color, to: Color, corner_radius: f32, )
两色线性渐变(可带圆角)。
Sourcepub fn radial_gradient(
&mut self,
rect: Rect,
center: Point,
radial_radius: f32,
from: Color,
to: Color,
corner_radius: f32,
)
pub fn radial_gradient( &mut self, rect: Rect, center: Point, radial_radius: f32, from: Color, to: Color, corner_radius: f32, )
两色径向渐变(可带圆角)。
Sourcepub fn mask(&mut self, rect: Rect, texture_id: u32, uv: [f32; 4], alpha: f32)
pub fn mask(&mut self, rect: Rect, texture_id: u32, uv: [f32; 4], alpha: f32)
纹理 alpha mask(destination-in):裁掉此前已绘制内容的透明度。
Sourcepub fn inset_shadow(
&mut self,
rect: Rect,
color: Color,
radius: f32,
blur_radius: f32,
)
pub fn inset_shadow( &mut self, rect: Rect, color: Color, radius: f32, blur_radius: f32, )
内阴影(绘制在 rect 内部边缘)
Sourcepub fn backdrop_blur(
&mut self,
rect: Rect,
radius: f32,
blur_radius: f32,
tint: Color,
)
pub fn backdrop_blur( &mut self, rect: Rect, radius: f32, blur_radius: f32, tint: Color, )
背景模糊(对 rect 内已绘制内容做 13-tap blur;tint.a 可加磨砂色调)
Sourcepub fn push_blend_mode(&mut self, mode: BlendMode)
pub fn push_blend_mode(&mut self, mode: BlendMode)
压入混合模式(作用于后续矩形族命令)
Sourcepub fn pop_blend_mode(&mut self)
pub fn pop_blend_mode(&mut self)
恢复上一个混合模式
Sourcepub fn push_clip_rrect(&mut self, rect: Rect, radius: f32)
pub fn push_clip_rrect(&mut self, rect: Rect, radius: f32)
压入圆角矩形裁剪(之后的绘制被裁在该圆角矩形内,直到 pop_clip)