Reshape text at runtime via ViewModel and animation without mutating the document#3595
Reshape text at runtime via ViewModel and animation without mutating the document#3595Hparty wants to merge 33 commits into
Conversation
cd39fe5 to
c0dc88b
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3595 +/- ##
==========================================
+ Coverage 82.56% 82.71% +0.14%
==========================================
Files 707 710 +3
Lines 91382 93468 +2086
Branches 25871 26341 +470
==========================================
+ Hits 75450 77308 +1858
- Misses 10438 10553 +115
- Partials 5494 5607 +113 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| // A pending TextHolder reshape (ViewModel/Animation drove a text-shaping channel) has not yet | ||
| // touched the tgfx objects — flush runs inside Record(). Without this check the dirty gate would | ||
| // skip the frame and the reshape would never reach the screen. | ||
| if (_rootComposition != nullptr && _rootComposition->hasDirtyTextHolders()) { |
There was a problem hiding this comment.
性能:hasContentChanged 每帧调用,此处 hasDirtyTextHolders() 会经 CollectChildCompositions 递归遍历整棵 layer 树;flushTextHolders 每帧再遍历一次。即使文档完全不含 TextHolder(绝大多数存量场景)也照付两次 O(n) 遍历 + 临时 vector 分配。建议在 binding/scene 维护"是否存在任一 TextHolder"的标志做提前返回,或缓存子 composition 列表。
| return true; | ||
| } | ||
| std::vector<PAGComposition*> childComps = {}; | ||
| CollectChildCompositions(const_cast<PAGComposition*>(this), childComps); |
There was a problem hiding this comment.
规范:const 方法内使用 const_cast<PAGComposition*>(this) 违反项目编码规范(应避免此类强制转换)。此处仅为读取而强转,目的是绕过 CollectChildCompositions 的非 const 形参。建议给 CollectChildCompositions 增加 const 重载,或将形参改为 const PAGLayer*,从而去掉 const_cast。
| <xs:attribute name="height" type="xs:decimal" use="required"/> | ||
| </xs:complexType> | ||
|
|
||
| <!-- ========================= ViewModel & DataBind ========================= --> |
There was a problem hiding this comment.
范围建议:此处新增的 ViewModel/DataBind/Animation/StateMachine 完整 schema(约 +290 行)连同 CommandVerify.cpp 的引用收集(+126 行),与本 PR 主题"文字运行时 reshape"关联较弱,且逻辑独立、可单独合入。建议评估是否拆为独立 PR,以减小评审面积、便于后续回溯。(流程建议,非代码缺陷)
…mutating the document
…ead of builder member state
…irtual hooks instead of a bool flag
… convert method signatures clean
…ams in one header
…rebase onto main.
…hild text reshape.
… without swapping the bound object.
…on baseline render tests.
…writers for ViewModel and animation driven reshaping.
… they carry runtime writers.
…lder reshape to remove duplication.
…id a no-op holder registered for the scene.
…redundant holder dirtying.
…line surfaces to fit the reshaped text.
…, and StateMachine.
…in CollectChildCompositions.
…fect its rendering.
08978b2 to
78a5ba8
Compare
本 PR 让 ViewModel / Animation 在运行时修改文字排版属性(text / fontFamily / fontStyle / fontSize / letterSpacing / fauxBold / fauxItalic)时不改动文档,只重新构造 runtime 对象。
主要内容:
依赖的 tgfx PR(已合并):setTextBlob 接口。