docs: clarify graphics resource and Block validation call paths
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
//! Endor 源程序调用这些函数创建模型资源/绘图命令;source_paint 解码图片命令时调用 decode_image。
|
||||
//! PointerDispatch 由 UiBridge::dispatch 包装成临时 callable,用同一 VM 分发原始指针事件。
|
||||
//! 这里不定义应用剧情或按钮业务。像素资源经 Arc 共享,托管资源身份与引用边仍由 Aster 管理。
|
||||
//! graphics.readText 是初始化用的同步 UTF-8 小文件读取(16 KiB);ui.readText 的后台任务接口另由 io_tasks 实现。
|
||||
//! 图片命令经托管 image 属性拥有资源;source_paint 解码后只把 Arc 像素带入渲染命令,绘制线程无需访问 VM。
|
||||
use crate::{
|
||||
document::{RenderCommand, parse_color},
|
||||
geometry::{Point, Rect},
|
||||
@@ -299,6 +301,7 @@ impl NativeCallable for Function {
|
||||
Value::Object(resource)
|
||||
}
|
||||
LoadFont => {
|
||||
// 不仅文件读取有副作用,register_font 还会修改字体注册表,因此布局/绘制只读回调也不能加载字体。
|
||||
if cx.store().is_read_only() {
|
||||
return Err(invalid("load resources outside paint/layout"));
|
||||
}
|
||||
@@ -584,7 +587,9 @@ impl NativeCallable for Function {
|
||||
fn ranges(left: f32, right: f32, y: f32, line: f32, exclusions: &[&Exclusion]) -> Vec<(f32, f32)> {
|
||||
// 每个形状先贡献一个阻塞区间;最后统一排序/扫线,支持多个重叠障碍。
|
||||
let mut blocked = Vec::new();
|
||||
// 按资源分别求本行投影;不修改 Exclusion,使同一障碍可被多个 Flow 调用和不同文本列共享。
|
||||
for e in exclusions {
|
||||
// 圆直接求解析弦宽;矩形/图片轮廓的 circle 为 None,继续交给下面的多边形边遍历。
|
||||
if let Some((p, r)) = e.circle {
|
||||
// 行带包含圆心时 gap=0,否则为圆心到最近水平边的垂直距离。
|
||||
let gap = (y - p.y).max(p.y - y - line).max(0.);
|
||||
@@ -607,6 +612,7 @@ fn ranges(left: f32, right: f32, y: f32, line: f32, exclusions: &[&Exclusion]) -
|
||||
// 行带覆盖的顶点直接参与水平包围,避免水平边/角点没有穿越交点时被漏掉。
|
||||
xs.push(a.x);
|
||||
}
|
||||
// 同一条斜边可能跨越行带的上下两边,两个交点都要计入横向包围,不能找到一个就停止。
|
||||
for edge in [top, bottom] {
|
||||
if (a.y < edge && b.y > edge) || (b.y < edge && a.y > edge) {
|
||||
// 只有真正跨过水平边界才插值,分母 b.y-a.y 在此条件下非零。
|
||||
|
||||
Reference in New Issue
Block a user