Skip to content

Add PAGX node channel reflection API, matrix animation, and in-place notifyChange refresh.#3505

Open
Hparty wants to merge 31 commits into
mainfrom
feature/partyhuang_pagx_notifyChange
Open

Add PAGX node channel reflection API, matrix animation, and in-place notifyChange refresh.#3505
Hparty wants to merge 31 commits into
mainfrom
feature/partyhuang_pagx_notifyChange

Conversation

@Hparty

@Hparty Hparty commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

新增按名读写 PAGX 节点通道的反射 API、矩阵关键帧动画,以及增量式的 PAGXDocument::notifyChange——把构建后的编辑反映到所有存活的 PAGScene 上,涵盖属性编辑、结构增删、动画(timeline)编辑和跨文档(外部 composition)编辑。同时在 PAGLayer 上暴露源节点 id。

反射 API (include/pagx/PAGXNodeChannel.h)

  • GetNodeChannel / SetNodeChannel —— 按通道名读写节点的标量属性(通道名与 PAGX XML 一致,如 alphaposition.xblendMode)。
  • IsAnimatableChannel / RequiresLayout —— 两个正交查询。一个通道可同时满足两者:形状的 size.width 在播放时可原地动画,但在文档上编辑它需要重新布局。内部由 ChannelFlags 位标志支撑(src/pagx/PAGXChannelTable.h)。

notifyChange —— 增量刷新

PAGXDocument::notifyChange(dirtyNodes, layoutChanged) 把编辑反映到每个存活 scene,并尽量保留 tgfx layer 句柄:

  • 属性编辑(alpha/颜色/几何)—— 原地刷新;layoutChanged 为 true 时对影响布局的字段重新布局。
  • 结构变更 —— 传入容器节点以协调其子 layer 列表;空 layer 新增内容时会被提升为 VectorLayer
  • 时间轴 —— 编辑时间轴节点(Animation/AnimationObject/Channel)会重建所有 timeline,使动画的增删改生效;非时间轴编辑不打断正在进行的播放。
  • 引用编辑 —— 当编辑改变了某个 @id 引用(如 AnimationObject.targetFill.color),调用方需把受影响引用链上的所有节点都标记为脏。
  • 跨文档 —— 嵌入外部 composition 文档的 scene 会反向注册到该文档;编辑子文档并调用其自身的 notifyChange 会重建所有嵌入它的 scene 的运行时树。节点只能通过其所属文档来通知(父文档不能通知子文档的节点)。

动画

  • 矩阵关键帧动画,使用共享的 TRS 分解(MatrixDecompose.h);为每个可动画通道注册运行时 writer,并由一个注册表一致性测试守护。
  • 已记录的限制:矩阵插值无法还原旋转圈数 —— 需要精确多圈旋转时请使用标量 Group::rotation 通道。

PAGLayer

  • PAGLayer::id() 返回源节点的 id,调用方可据此识别其对应的文档节点。

加固(来自两轮多 agent review)

  • 按真实渲染行为修正通道标志(Path position → 仅布局;Text x/y、形状 position → 可动画且影响布局)。
  • 原地刷新会重置被移除的 mask;并对 VectorLayer 强转加类型守卫,避免类型不匹配。
  • composition 子节点移除时分离的是 slot(不再遗留孤立容器);runtimeLayer 重同步只作用于普通子 layer,使 composition 子节点保留其子树根。
  • unbindSubtree 会回收内容元素 / 颜色源 / ColorStop / ImagePattern-Image 的绑定,并通过存活引用扫描尊重共享(@id)资源。
  • 修复一处 use-after-free:缓存的顶层 PAGTimeline 现在通过所属 scene 懒解析其 binding,从而在运行时树重建后依然有效。

兼容性

没有任何 PAGX 节点新增可序列化的属性字段。唯一的数据模型变更是 Channel 的值类型新增了 Matrix 备选项(向后兼容)。旧的 PAGX 文件解析行为不变。

测试

PAGFullTest 编译干净;全部 231 个 PAGXTest/PAGXRuntimeTest 用例通过,新增覆盖包括时间轴重建、跨文档与嵌套(A→B→C)同步、重建后显示选项保留,以及缓存 timeline 跨重建的路径。

已知限制 / 后续

  • Layer 标量变换通道(rotation/scale)有意未加入;精确旋转动画应驱动标量 Group::rotation 通道。
  • 跨文档编辑会重建嵌入 scene 的运行时树,因此编辑前获取的句柄需重新获取,且嵌入子树中正在进行的播放会重新开始。

Hparty added 19 commits June 11, 2026 18:44
…nels by name.

(cherry picked from commit 67ab9e4d89bf7daf3ea061c9c21368bb9d5ab688)
…e channels via a subclassed runtime target.

(cherry picked from commit b2f0fe1f4b1565bc818548fa6184fcc2f3de7d81)
… registry consistency test.

(cherry picked from commit c453d7ee78f6278ef060322ec97eccf73eaa154c)
@codecov-commenter

codecov-commenter commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.22043% with 322 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.65%. Comparing base (9e5ef77) to head (3653b9e).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/renderer/LayerBuilder.cpp 63.78% 105 Missing and 29 partials ⚠️
src/pagx/PAGXNodeChannel.cpp 72.75% 62 Missing and 32 partials ⚠️
src/pagx/runtime/PAGComposition.cpp 71.71% 5 Missing and 23 partials ⚠️
src/renderer/LayerBuilder.h 64.58% 11 Missing and 6 partials ⚠️
test/src/PAGXTest.cpp 98.77% 4 Missing and 7 partials ⚠️
src/pagx/runtime/KeyframeEvaluator.h 0.00% 7 Missing ⚠️
src/pagx/runtime/MatrixDecompose.h 81.57% 0 Missing and 7 partials ⚠️
src/pagx/PAGScene.cpp 83.33% 1 Missing and 5 partials ⚠️
src/pagx/PAGXImporter.cpp 0.00% 6 Missing ⚠️
src/pagx/PAGXDocument.cpp 86.66% 0 Missing and 4 partials ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3505      +/-   ##
==========================================
+ Coverage   80.57%   80.65%   +0.07%     
==========================================
  Files         620      623       +3     
  Lines       67021    68881    +1860     
  Branches    19885    20320     +435     
==========================================
+ Hits        54002    55553    +1551     
- Misses       9083     9278     +195     
- Partials     3936     4050     +114     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Hparty Hparty changed the title Add PAGX node channel reflection, matrix animation, and in-place notifyChange refresh. 添加 PAGX 节点通道反射 API、矩阵动画及 notifyChange 就地刷新。 Jun 12, 2026
@Hparty Hparty changed the title 添加 PAGX 节点通道反射 API、矩阵动画及 notifyChange 就地刷新。 Add PAGX node channel reflection API, matrix animation, and in-place notifyChange refresh. Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants