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);
}
}