上图为WMS, SurfaceFlinger, app如何同步buffer大小,总结下来有如下6 个步骤
1 Window宽度高度发生变化,如转屏或者window动画.
2 WMS更新SurfaceControl大小,这一步要通过事务来完成
3 SurfaceFlinger到下一个vsync周期处理事务翻转,这时候会设置该Layer的mDefaultWidth和mDefaultHeight
4 为客户端这边的动作,客户端会进行下一帧的绘制,绘制完成后进行queueBuffer, queueBuffer的过程会返回sf中关于
该layout的mDefaultWidth和mDefaultHeight,使用这个宽度高度更新request height和request width
5 客户端使用新的request height ,request width去dequeueBuffer(注意这里会尽量不改变dequeueBuffer的大小,如果发生转屏的话是不用改变reques大小的,只需要queueBuffer进行旋转buffer就可以)
6 下次queueBuffer前根据宽度高度去旋转buffer的角度. 然后queueBuffer
7 sf收到queueBuffer和Layer的mDefaultWidth,mDefaultHeight相等后,开始使用新的宽度高度渲染.
所以这里第四步还是渲染在旧的大小的buffer上. 这就算是一个过度过程.
const bool resizePending = ((c.requested.w != c.active.w) || (c.requested.h != c.active.h)) &&
(getBE().compositionInfo.mBuffer != nullptr) ;
if (!isFixedSize()) {
if (resizePending && getBE().compositionInfo.hwc.sidebandStream == nullptr) {
flags |= eDontUpdateGeometryState;
}
}
// Here we apply various requested geometry states, depending on our
// latching configuration. See Layer.h for a detailed discussion of
// how geometry latching is controlled.
if (!(flags & eDontUpdateGeometryState)) {
Layer::State& editCurrentState(getCurrentState());
// If mFreezeGeometryUpdates is true we are in the setGeometryAppliesWithResize
// mode, which causes attributes which normally latch regardless of scaling mode,
// to be delayed. We copy the requested state to the active state making sure
// to respect these rules (again se