Expand description
图片基础设施(阶段 6:图片渲染)
架构:
- core 只持有 解码后的 RGBA 数据(
ImageData)与texture_id(全局原子分配,0 保留给 glyph atlas)。文件 IO 与 PNG/JPEG/WebP 解码在mgui-components::image_loader(image-decodefeature)完成, core 不碰文件系统与图像解码器。 - paint 输出复用 B2 的
PaintCommand::TexturedRect(uv 全图[0,0,1,1], texture_id = 图片纹理)。runtime 端按 texture_id 分段 set bind group。 BoxFit::Fill拉伸铺满 widget;BoxFit::Contain等比缩放居中 (letterbox,绘制矩形在 layout 时算好存dst_rect)。
ImageWidget 已迁移到 mgui-components crate。
Structs§
- Image
Data - 解码后的位图(直排 RGBA8,每像素 4 字节)。
- Image
Render Object - 图片 RO:paint 输出一条
TexturedRect(uv 全图,texture_id 非 0)
Enums§
- BoxFit
- 图片填充模式
- Texture
Update - 一张图片纹理在“同一个
texture_id又来了一次 register“时该怎么处理。
Functions§
- image_
identity Rc<ImageData>的身份。存进缓存的同时必须把Rc本身留住, 否则释放后地址被复用,会把“另一张图“误判成“同一帧“。- next_
image_ id - 分配一个全局唯一的图片 texture id
- plan_
texture_ update - 该不该更新纹理。无 GPU、无分配,纯函数,所以两端与单测看的是同一条规则。