1.应用/SystemServer通过SurfaceControl向SF发送对应Layer的更新操作
2.sf通过轮询scheduler中的消息,调用commit,进而调用flushTransactions()方法,解析mLocklessTransactionQueue(其中存储的是上层发来的layer信息),存储到mPendingTransactionQueues,进而封装到frontend::Update
继续继续调用updateLayerSnapshotsLegacy(),其返回值表示是否有内容更新,其返回值决定commit的返回值。
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #00 pc 000000000032e4bc /system/lib64/libsurfaceflinger.so (android::SurfaceFlinger::applyTransactionsLocked(std::__1::vector<android::TransactionState, std::__1::allocator<android::TransactionState> >&, android::VsyncId)+396) (BuildId: f8a802dd32acd0642e8a0ce7272507e3)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #01 pc 000000000031e01c /system/lib64/libsurfaceflinger.so (android::SurfaceFlinger::updateLayerSnapshotsLegacy(android::VsyncId, android::surfaceflinger::frontend::Update&, bool, bool&)+164) (BuildId: f8a802dd32acd0642e8a0ce7272507e3)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #02 pc 000000000032105c /system/lib64/libsurfaceflinger.so (android::SurfaceFlinger::commit(android::TimePoint, android::VsyncId, android::TimePoint)+2588) (BuildId: f8a802dd32acd0642e8a0ce7272507e3)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #03 pc 00000000002f9410 /system/lib64/libsurfaceflinger.so (android::scheduler::Scheduler::onFrameSignal(android::ICompositor&, android::VsyncId, android::TimePoint)+64) (BuildId: f8a802dd32acd0642e8a0ce7272507e3)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #04 pc 0000000000018b00 /system/lib64/libutils.so (android::Looper::pollInner(int)+380) (BuildId: 6913e460ab4318ffea97f6eb91eeb70e)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #05 pc 0000000000018920 /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+124) (BuildId: 6913e460ab4318ffea97f6eb91eeb70e)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #06 pc 00000000002e8b1c /system/lib64/libsurfaceflinger.so (android::impl::MessageQueue::waitMessage()+88) (BuildId: f8a802dd32acd0642e8a0ce7272507e3)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #07 pc 00000000002f93c8 /system/lib64/libsurfaceflinger.so (android::scheduler::Scheduler::run()+32) (BuildId: f8a802dd32acd0642e8a0ce7272507e3)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #08 pc 000000000001a80c /system/bin/surfaceflinger (main+1816) (BuildId: d37bfafd0ae00cb3d8e8f862dc988c9f)
11-07 09:06:26.270 1906 1906 D WZ_DEBUG_SF: #09 pc 000000000008d99c /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: 1e3ca19bcae05c01b019c85f3f422e56)
3.commit返回false的时候,表示有必要更新内容,接下来就会走合成的流程
void Scheduler::onFrameSignal(ICompositor& compositor, VsyncId vsyncId,
TimePoint expectedVsyncTime) {
const TimePoint frameTime = SchedulerClock::now();
if (!compositor.commit(frameTime, vsyncId, expectedVsyncTime)) {
return;
}
compositor.composite(frameTime, vsyncId);
compositor.sample();
}