App窗口创建流程(Android12 )
有关的窗口对象
PhoneWindow | ActivityThread#performLaunchActivity {Activity.attach} |
Surface |
|
Layer | SurfaceFlinger::createLayer |
RenderSurface | SurfaceFlinger gpu合成layer之后的数据管理类 |
FramebufferSurface | Framebuffer管理类,负责消费合成的layer数据,送显 |
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)
}
->ActivityThread#handleResumeActivity->wm.addView(decor
->WindowManagerGlobal.addView(WindowManagerGlobal.setView
{
new ViewRootImpl()#setView -> requestlayout -> performTraversals -> 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使用
从wms.createSurfaceLocked ~ SurfaceFlinger::createLayer 如图所示
Surface创建流程见App申请Surface流程(Android12 )-CSDN博客
部分资料参考于:Android14 SurfaceFlinger Surface的创建_pendingbuffercounter-CSDN博客