Add SurfaceSyncer class
Add Syncer class that allows callers to add desired syncs into a set and wait for them to all complete before getting a callback. The purpose of the Syncer is to be an accounting mechanism so each sync implementation doesn't need to handle it themselves. The Syncer class is used the following way. 1. SurfaceSyncer#setupSync is called 2. addToSync is called for every SyncTarget object that wants to be included in the sync. If the addSync is called for a View or SurfaceView it needs to be called on the UI thread. When addToSync is called, it's guaranteed that any UI updates that were requested before addToSync but after the last frame drew, will be included in the sync. 3. SurfaceSyncer#markSyncReady should be called when all the SyncTargets have been added to the SyncSet. Now the SyncSet is closed and no more SyncTargets can be added to it. 4. When all SyncTargets are complete, the final merged Transaction will either be applied or sent back to the caller. The following is what happens within the SyncSet 1. Each SyncableTarget will get an onReadyToSync callback that contains a SyncBufferCallback. 2. Each SyncableTarget needs to invoke SyncBufferCallback#onBufferReady. This makes sure the SyncSet knows when the SyncTarget is complete, allowing the SyncSet to get the Transaction that contains the buffer. 3. When the final FrameCallback finishes for the SyncSet, the syncRequestComplete Consumer will be invoked with the transaction that contains all information requested in the sync. This could include buffers and geometry changes. The buffer update will include the UI changes that were requested for the View. Test: SurfaceSyncerTest Test: SurfaceSyncerContinuousTest Bug: 200284684 Change-Id: Iab87bff8a0483581e57803724eae88f0a3d96c8e
Loading
Please register or sign in to comment