The window is tied to a Surface and the ViewRoot asks the Surfacefor a Canvas that is then used by the Views to draw onto. AfterView draw its data to canvas, ViewRoot will callsurface.unlockCanvasAndPost(canvas) to schedulesurfaceFlinger::composeSurfaces() which do the actually display todisplay panel. SurfaceFlinger handles to transfers drawn data incanvas to surface front buffer or backbuffer.
Except for SurfaceViews, different views within the same ViewRootshare the same surface. Layer
A Layer is something that can be composited by SurfaceFlinger(should have been called LayerFlinger). There are several types ofLayers if you look in the code, in particular the regular ones(Layer.cpp) , they are backed by a Surface, and the LayerBuffer(very badly chosen name) which don't have a backing store, butreceive one from their client. . Note that the GGLSurface type,should have been called GGLBuffer.
Multiple layers are just composited to the final buffer in their Zorder. 創(chuàng )建一個(gè) Surface 的過(guò)程