Skip to content

Drive PAGX viewer animations via PAGScene and PAGTimeline with playback and profiling#3580

Open
CodeJhF wants to merge 4 commits into
mainfrom
feature/markffan_pagxviewer_animation
Open

Drive PAGX viewer animations via PAGScene and PAGTimeline with playback and profiling#3580
CodeJhF wants to merge 4 commits into
mainfrom
feature/markffan_pagxviewer_animation

Conversation

@CodeJhF

@CodeJhF CodeJhF commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

背景

PAGX 预览器此前的渲染基于 tgfx DisplayList / LayerBuilder,仅能显示静态画面,缺少动画播放能力。本 PR 将其重构为基于 pagx::PAGScene + pagx::PAGTimeline 的渲染管线,并补齐完整的动画播放与性能剖析支持。

主要改动

1. 渲染管线重构

  • DisplayList / LayerBuilder 迁移到 pagx::PAGScene + pagx::PAGTimeline,通过 pagx::Record 渲染。
  • 适配层缩放/偏移改为使用场景的 DisplayOptionssetZoomScale / setContentOffset)。

2. 动画播放

  • 以墙钟时间差驱动时间轴推进(advanceAndApply),并将播放进度回报到 UI。
  • 支持暂停时按进度 seek、以及非循环动画播放结束后从头重播。
  • 非循环(LoopMode::Once)动画自然播放结束后停在末帧、按钮回到"播放"态,并停止渲染线程空转。

3. 线程安全

  • getRenderState()renderMutex 下对场景/时间轴/进度做一致性快照,渲染线程仅操作快照副本。
  • progress 改为 std::atomic<double>,消除渲染线程读、主线程写的数据竞争。
  • 引入按会话递增的 generation 机制:进度更新与"播放结束"通知都携带快照时刻的 generation,主线程据此丢弃来自旧会话(如文件重载后)的过期通知,避免误停新内容的播放。

4. 性能剖析

  • 为 PAGX 播放计算当前帧号并接入 profiler 帧直方图(帧号按末帧钳制,避免整数帧率下丢失最后一帧的统计)。
  • Profiler 新增 "Node Distribution" 节点分布面板。

已知限制

  • 嵌套合成(composition)内的子动画在暂停拖动/重播时不随顶层时间轴重定位——PAGScene 目前仅提供相对 advanceAndApply、无绝对 seek 接口,需后续在引擎层补充绝对 seek 能力后再处理。

测试

  • PAGViewer 目标编译链接通过。
  • 使用非循环动画素材手动验证:播放 → 停末帧 → 按钮变"播放" → 再点播放从头重播 → 结束后不空转。
  • 注:改动位于独立的 viewer Qt 应用,不在 PAGFullTest 覆盖范围内。

@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.57%. Comparing base (2929925) to head (5bb32b0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3580   +/-   ##
=======================================
  Coverage   82.56%   82.57%           
=======================================
  Files         707      707           
  Lines       91382    91382           
  Branches    25871    25871           
=======================================
+ Hits        75451    75455    +4     
+ Misses      10436    10433    -3     
+ Partials     5495     5494    -1     

☔ 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.

@CodeJhF
CodeJhF force-pushed the feature/markffan_pagxviewer_animation branch from 2402835 to b24223a Compare July 15, 2026 02:10
Comment thread viewer/src/rendering/pagx/PAGXRenderer.cpp Outdated
Comment thread viewer/src/profiling/PAGRunTimeDataModel.cpp Outdated
Comment thread viewer/src/rendering/pagx/PAGXRenderer.cpp
Comment thread viewer/src/rendering/pagx/PAGXViewModel.cpp Outdated
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.

3 participants