SurfaceFlinger的commit/handleTransaction分析
https://blog.csdn.net/liaosongmao1/article/details/136214295
composite
Android13 SurfaceFlinger composite(合成)流程分析_surfaceflinger图层合成-CSDN博客
display id
Android Display ID 对应关系_android displayid-CSDN博客
vsync
Andoid SurfaceFlinger(二) VSYNC的开始,连续,结束_surfaceflinger workduration-CSDN博客
Android Qcom Display学习(四)
Android Qcom Display学习(四)_presentdisplay-CSDN博客
Android SurfaceFlinger导读(10)理解DisplayDevice-CSDN博客
GitHub - Aegisub/Aegisub: Cross-platform advanced subtitle editor
disp 配置
/ifs//lib64/graphics.conf
- Configuring Screen (qnx.com)
transactionIsReadyToBeApplied vsyncId: 18650
dispatchSetFrameTimelineInfo
1、请求合成请求vsync
MessageQueue.cpp
返回nextWakeupTime
struct ArmingInfo {
nsecs_t mActualWakeupTime;
nsecs_t mActualVsyncTime;
nsecs_t mActualReadyTime;
};
在schedule 请求vsync 时会根据算法计算出nextVsyncTime时间,
nextVsyncTime = tracker.nextAnticipatedVSyncTimeFrom
nextWakeupTime = nextVsyncTime - timing.workDuration - timing.readyDuration;
nextReadyTime = nextVsyncTime - timing.readyDuration;
并赋值mArmedInfo = {nextWakeupTime, nextVsyncTime, nextReadyTime};
dumpsys SurfaceFlinger
根据rearmTimerSkippingUpdateFor 根据mIntendedWakeupTime 来定时setTimer
当定时时间到会回调timerCallback
1、mIntendedWakeupTime 是设置vsync 到来时间setTimer时对应的vsync 到来时间到来时间
mLastTimerSchedule 是设置vsync 到来时间setTimer时对应的当前系统时间
vsync 时间到来,执行timerCallback,找到满足条件的回调,这个时候执行callback->executing()将mLastDispatchTime = mArmedInfo->mActualVsyncTime;赋值,将
invocations.emplace_back(Invocation{callback, *callback->lastExecutedVsyncTarget(),*wakeupTime, *readyTime});callback->lastExecutedVsyncTarget()对应mLastDispatchTime。
callback->executing() 里面会清空mArmedInfo.
2、再次rearmTimer(mTimeKeeper->now());->rearmTimerSkippingUpdateFor
callback->update() 会再次更新下次vsync 时间,从而再次启动定时setTimer
3、重新设置定时时间,再调用vsync 到来的回调
for (auto const& invocation : invocations) {
invocation.callback->callback(invocation.vsyncTimestamp, invocation.wakeupTimestamp,
invocation.deadlineTimestamp);
}
}
//vsyncDuration对应vsync周期,60hz手机就是16666666ns
//sfDuration就是对应sf.duration
nsecs_t sfDurationToOffset(std::chrono::nanoseconds sfDuration, nsecs_t vsyncDuration) {
return vsyncDuration - sfDuration.count() % vsyncDuration;
}
//vsyncDuration对应vsync周期,60hz手机就是16666666(纳秒)
//sfDuration就是对应sf.duration
//appDuration就是对应app.duration
nsecs_t appDurationToOffset(std::chrono::nanoseconds appDuration,
std::chrono::nanoseconds sfDuration, nsecs_t vsyncDuration) {
return vsyncDuration - (appDuration + sfDuration).count() % vsyncDuration;
}
sfDurationToOffset 对应 app phase
appDurationToOffset 对应 SF phase
app phase: 1000000 ns SF phase: 1000000 ns
app duration: 16666666 ns SF duration: 15666666 ns
early app phase: 1000000 ns early SF phase: 1000000 ns
early app duration: 16666666 ns early SF duration: 15666666 ns
GL early app phase: 1000000 ns GL early SF phase: 1000000 ns
GL early app duration: 16666666 ns GL early SF duration: 15666666 ns
HWC min duration: 0 ns
present offset: 0 ns VSYNC period: 16666666 ns
(mode override by backdoor: no)
sf:
workDuration: 15.67ms readyDuration: 0.00ms earliestVsync: -1436.61ms relative to now
mLastDispatchTime: 448.00ms ago
appSf:
workDuration: 16.67ms readyDuration: 15.67ms earliestVsync: -10077906.00ms relative to now
mLastDispatchTime: 10077906.00ms ago
app: [wake up in 5.78ms deadline in 22.45ms for vsync 38.12ms from now]
workDuration: 16.67ms readyDuration: 15.67ms earliestVsync: 21.37ms relative to now
mLastDispatchTime: -21.37ms ago
vsyn-app 信号到来,执行回调,会掉里面执行schedule
app
nextAknownTime =0074047163404 timePoint= 0074047163404 nextvsync= 0074047180071
updat nextVsyncTime =0074047180071 wakeupTime= 0074047147737 nextReadyTime= 0074047164404us now=0074047131071
timePoint = now + app.workduration+app.readyduration=0074047131071 + workDuration: 16.67ms + readyDuration: 15.67ms
nextvsync = timePoint + 1 个 vsync
wakeupTime = nextvsync - app.workduration-app.readyduration = now + 1 个 vsync
setTransateState 提交sf
nextAknownTime =0074047149707 timePoint= 0074047149707 nextvsync= 0074047166374
updatnextVsyncTime =0074047166374 wakeupTime= 0074047150707 nextReadyTime= 0074047166374us now=0074047134040
timePoint =now + sf.workduration+sf.readyduration=0074047134040 + workDuration: 15.67ms readyDuration: 0.00ms
nextvsync = timePoint + 1 个 vsync
wakeupTime = updatnextVsyncTime - sf.workduration-sf.readyduration = now + 1个vsync
sf 不满足
sf wakeupTime= 0074047150707us; mIntende= 0074047147737us;mTimerSlack=500us;lagAllowance=63
定时时候到,不满足。因为这里mIntenedWakeupTime 是vsync-app 上个vsync 时间,从而不满足;其实这里的差值是vysn-app wakpup 时间和 setTransate 时间得差值
update 更新sf 下一次时间
sf 下次
nextAknownTime =0074047163485 timePoint= 0074047163485 nextvsync= 0074047180152
updatnextVsyncTime =0074047180152 wakeupTime= 0074047164485 nextReadyTime= 0074047180152us now=0074047147819
mTimerSlack: 0.50ms mMinVsyncDistance: 3.00ms