WMS(二):Surface的创建

144 阅读1分钟

surface的创建

WMS内容太多了,拆开来讲,最后合到一起。

ViewRootImpl创建时是会new一个 Surface对象,surface中包含一个canvas.

Surface在SurfaceFlinger侧称为Layer。

ViewRootImpl在WMS有个叫mWindowSession对应

SurfaceFlinger将不同layer 图层合成为图像数据FrameBuffer,也就是图像缓存数据送给GPU。

ViewRootIMpl创建的Surface就是第一个空壳子,这个时候没添加窗口,不知道画布尺寸。

WMglobalViewRootImpl

surface什么时候进行创建呢?

setView中有一个requestLayout, performTraversals,relayoutWindow。

mWindowSession.relayout与WMS通信。传入了outsurfaceContral 这个mWindowsSession是WMS对应Activity的一个Binder服务对象

这个surfaceControlWMglobalViewRootImpl传到WMSimage.png

WMS

outfaceControl传递到WMS,然后surfaceController创建内容copy给outsurfaceController,再由surfaceControlcopy给Surface。因为权限问题 所以要传来传去。 image.png

WMglobalViewRootImpl

书接上回,刚传进去的那个surfaceControlcopy,在WMS留洋归来。把值带回给了mSuface空壳子,现在mSurface是名副其实的surface了。 image.png

顺便看看surfaceCOntrol里有啥好东西。

image.png

流程就是

image.png