layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>&sc) {
auto handle = sc->getLayerStateHandle();
if (mComposerStates.count(handle) == 0) {
// we don't have it, add an initialized layer_state to our list
ComposerState s;
s.state.surface = handle;
s.state.layerId = sc->getLayerId();
mComposerStates[handle] = s;
}
return &(mComposerStates[handle].state);
}
mComposerStates
是 Transaction 的一个字段,它是 <IBinder, ComposerState>
映射,IBinder 是 SurfaceControl 的 handle
。
- 如果
mComposerStates
中没有 sc
对应的 layer_state_t,则新建一个并设置 surface
和 layerId
。