有关的窗口对象
PhoneWindow | ActivityThread#performLaunchActivity {Activity.attach} |
Surface | new ViewRootImpl 创建null对象 |
Layer | SurfaceFlinger::createLayer |
SurfaceControl | ViewRootImpl#relayoutWindow{mSurface.copyFrom(mSurfaceControl)} //改变Surface buffer属性 |
IWindowSession | new ViewRootImpl(contexst, display, WindowManagerGlobal.getWindowSession()) |
WindowManagerGlobal | ActivityThread#handleLaunchActivity {WindowManagerGlobal.initialize()} |
App窗口完整创建流程
Launcher#startActivity() -> SystemServer -> zygote newProcess
->App #newActivityThread.main() ->ActivityThread#handleLaunchActivity
-> ActivityThread.performLaunchActivity
{
WindowManagerGlobal.initialize()
newActivity().attach(context)
}
- AMS newActivityRecord.showStartingWindow()
->WindowManagerGlobal.addView(WindowManagerGlobal.setView
{
newViewRootImpl()#performTraversals -> ViewRootImpl#relayoutWindow
mWindowSession.relayout(mSurfaceControl .........
}
wms.relayout会创建SurfaceControl和Layer
创建SurfaceControl过程:
- mWindowSession.relayout(mSurfaceControl
- -> wms.createSurfaceControl()
- ->mSurfaceControl = WindowStateAnimator.createSurfaceLocked 开始创建Surface
- ->mSurface.copyFrom(mSurfaceControl)把mSurfaceControl复制到ViewRootImpl对象的mSurface里面后续操作window使用
WindowStateAnimator.createSurfaceLocked创建Surface过程:
从wms.createSurfaceLocked ~ SurfaceFlinger::createLayer如图所示
参考于:Android14 SurfaceFlinger Surface的创建_pendingbuffercounter-CSDN博客