ice-render 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,8 @@ declare abstract class ICEComponent extends ICEEventTarget {
42
42
  /** 可见性缓存(代际号 + 值):见 `isEffectivelyVisible` 的说明。 */
43
43
  private __visEpoch;
44
44
  private __visValue;
45
+ /** 本帧是否因为子树不透明度过 ctx.globalAlpha(见 __renderCore / __resetLeakyCtxState)。 */
46
+ private __opacityApplied;
45
47
  /** 声明式渐变缓存:按描述对象引用判定,`refreshParams()` 里失效(setState 必然触发它)。 */
46
48
  private __gradCache;
47
49
  /**
@@ -294,6 +296,35 @@ declare abstract class ICEComponent extends ICEEventTarget {
294
296
  * 表现为「连线的箭头与标签在缓存位图里整块消失」——离屏缓存保真测试就是抓这个的。
295
297
  */
296
298
  protected applyActiveTransform(): void;
299
+ /**
300
+ * 是否存在开启 `clipChildren` 的祖先(热路径用,命中检测与离屏缓存的门控都要问它)。
301
+ * 顶层组件直接 O(1) 返回。
302
+ */
303
+ hasClippingAncestor(): boolean;
304
+ /**
305
+ * 有效不透明度 = 自身 `state.opacity` × 所有祖先的 `state.opacity`(默认 1)。
306
+ *
307
+ * 顶层组件直接返回(绝大多数组件没有祖先,热路径上不做遍历);非法值按 1 处理。
308
+ */
309
+ private __effectiveOpacity;
310
+ /**
311
+ * 世界坐标点是否落在某个「裁剪祖先」的盒子之外。
312
+ *
313
+ * 命中检测用它实现「滚出可视区的子组件点不到」—— 与渲染时的裁剪语义保持一致。
314
+ */
315
+ isPointClippedOut(wx: number, wy: number): boolean;
316
+ /**
317
+ * 把「裁剪祖先」的盒子作为裁剪区应用到 ctx —— 在**设备空间**建立。
318
+ *
319
+ * 做法与脏矩形路径一致(见 CanvasRenderer 的局部重绘分支):
320
+ * `setTransform(单位矩阵) → rect → clip → 复原本组件 CTM`。clip 记录在 ctx 的裁剪状态里,
321
+ * 之后组件自己 `setTransform` 不会清掉它;`restore()` 才移除。
322
+ *
323
+ * 祖先有旋转/缩放时按其世界 AABB 裁剪(保守,宁可多裁不可漏裁)。
324
+ *
325
+ * @returns 是否建立过裁剪(true 时调用方必须 `ctx.restore()`)
326
+ */
327
+ private __applyAncestorClips;
297
328
  /**
298
329
  * 把「世界 → 设备」矩阵应用到 ctx。
299
330
  * debug 包围盒的坐标本身就是世界坐标,不能套「本地 → 世界」的 composed 矩阵。
@@ -42,6 +42,8 @@ declare abstract class ICEComponent extends ICEEventTarget {
42
42
  /** 可见性缓存(代际号 + 值):见 `isEffectivelyVisible` 的说明。 */
43
43
  private __visEpoch;
44
44
  private __visValue;
45
+ /** 本帧是否因为子树不透明度过 ctx.globalAlpha(见 __renderCore / __resetLeakyCtxState)。 */
46
+ private __opacityApplied;
45
47
  /** 声明式渐变缓存:按描述对象引用判定,`refreshParams()` 里失效(setState 必然触发它)。 */
46
48
  private __gradCache;
47
49
  /**
@@ -294,6 +296,35 @@ declare abstract class ICEComponent extends ICEEventTarget {
294
296
  * 表现为「连线的箭头与标签在缓存位图里整块消失」——离屏缓存保真测试就是抓这个的。
295
297
  */
296
298
  protected applyActiveTransform(): void;
299
+ /**
300
+ * 是否存在开启 `clipChildren` 的祖先(热路径用,命中检测与离屏缓存的门控都要问它)。
301
+ * 顶层组件直接 O(1) 返回。
302
+ */
303
+ hasClippingAncestor(): boolean;
304
+ /**
305
+ * 有效不透明度 = 自身 `state.opacity` × 所有祖先的 `state.opacity`(默认 1)。
306
+ *
307
+ * 顶层组件直接返回(绝大多数组件没有祖先,热路径上不做遍历);非法值按 1 处理。
308
+ */
309
+ private __effectiveOpacity;
310
+ /**
311
+ * 世界坐标点是否落在某个「裁剪祖先」的盒子之外。
312
+ *
313
+ * 命中检测用它实现「滚出可视区的子组件点不到」—— 与渲染时的裁剪语义保持一致。
314
+ */
315
+ isPointClippedOut(wx: number, wy: number): boolean;
316
+ /**
317
+ * 把「裁剪祖先」的盒子作为裁剪区应用到 ctx —— 在**设备空间**建立。
318
+ *
319
+ * 做法与脏矩形路径一致(见 CanvasRenderer 的局部重绘分支):
320
+ * `setTransform(单位矩阵) → rect → clip → 复原本组件 CTM`。clip 记录在 ctx 的裁剪状态里,
321
+ * 之后组件自己 `setTransform` 不会清掉它;`restore()` 才移除。
322
+ *
323
+ * 祖先有旋转/缩放时按其世界 AABB 裁剪(保守,宁可多裁不可漏裁)。
324
+ *
325
+ * @returns 是否建立过裁剪(true 时调用方必须 `ctx.restore()`)
326
+ */
327
+ private __applyAncestorClips;
297
328
  /**
298
329
  * 把「世界 → 设备」矩阵应用到 ctx。
299
330
  * debug 包围盒的坐标本身就是世界坐标,不能套「本地 → 世界」的 composed 矩阵。
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "大漠穷秋",
3
3
  "name": "ice-render",
4
- "version": "1.1.0",
4
+ "version": "1.3.0",
5
5
  "description": "A canvas engine for interactive graphics.",
6
6
  "repository": {
7
7
  "type": "git",