首页 > 代码库 > ViewRootImpl和WindowManagerService笔记

ViewRootImpl和WindowManagerService笔记

1、每一个窗口的ViewRootImpl都有一个mWindowAttributes窗口属性,该属性在WindowManagerGlobal.updateViewLayout()->ViewRootImpl.setView()和WindowManagerGlobal.updateViewLayout->ViewRootImpl.setLayoutParams()中赋值,同时ViewRootImpl.mWindowAttributesChanged也会设为true表示窗口属性已更改,当窗口属性更改时,surfaceChanged也会设置为true

 if (mWindowAttributesChanged) {
            mWindowAttributesChanged = false;
            surfaceChanged = true;
            params = lp;
        }

当surfaceChanged设置为true时,下面这段代码会调用

if (surfaceChanged) {
                        mSurfaceHolderCallback.surfaceChanged(mSurfaceHolder,
                                lp.format, mWidth, mHeight);
                        SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks();
                        if (callbacks != null) {
                            for (SurfaceHolder.Callback c : callbacks) {
                                c.surfaceChanged(mSurfaceHolder, lp.format,
                                        mWidth, mHeight);
                            }
                        }
                    }