WEB开发网
开发学院手机开发Android 开发 详解 Android 图形系统 阅读

详解 Android 图形系统

 2010-03-10 16:45:00 来源:WEB开发网   
核心提示:SurfaceFlingerSurfaceFlinger 在 整个图形系统中担任 server 角色,它负责将各个 surface 根据 Z order 合成 (composer) 起来,详解 Android 图形系统,SurfaceAndroid图 形系统中一个重要的概念和线索是surface,View及其子类(如

SurfaceFlinger

SurfaceFlinger 在 整个图形系统中担任 server 角色,它负责将各个 surface 根据 Z order 合成 (composer) 起来。

Surface

Android图 形系统中一个重要的概念和线索是surface。View及其子类(如 TextView, Button)要画在surface上。每个surface创 建一个Canvas对象 (但属性时常改变),用来管理view在surface上 的绘图操作,如画点画线。每个 canvas对象对应一个bitmap,存储画在surface上 的内容。

每个Surface通常对应两个buffer, 一个front buffer, 一个back buffer。其中, back buffer就是canvas绘图时对应的bitmap (研究 android _view_Surface.cpp::lockCanvas)。因此,绘画总是在back buffer上, 需要更新时,则将back buffer和front buffer互换。

The window is tied to a Surface and the ViewRoot asks the Surface for a Canvas that is then used by the Views to draw onto. After View draw its data to canvas, ViewRoot will call surface.unlockCanvasAndPost(canvas) to schedule surfaceFlinger::composeSurfaces() which do the actually display to display panel. SurfaceFlinger handles to transfers drawn data in canvas to surface front buffer or backbuffer.

Except for SurfaceViews, different views within the same ViewRoot share the same surface.

Layer

每个surface又对应一个layer, SurfaceFlinger负责将各个layer的front buffer合成 (composite)绘制 到屏幕上。

A Layer is something that can be composited by SurfaceFlinger (should have been called LayerFlinger). There are several types of Layers 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, but receive 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 Z order.

创 建一个 Surface 的过程

Android 创建一个 Surface 的 过程如下面的序列图所示:

研究一个surface如何创建的关键路径如下:

1 2 3 4  下一页

Tags:详解 Android 图形

编辑录入:coldstar [复制链接] [打 印]
赞助商链接