WEB开发网      婵犻潧鍊婚弲顐︽偟椤栨稓闄勯柦妯侯槸閻庤霉濠婂骸浜剧紒杈ㄥ笚閹峰懘鎮╅崹顐ゆ殸婵炴垶鎸撮崑鎾趁归悩鐑橆棄闁搞劌瀛╃粋宥夘敃閿濆柊锕傛煙鐎涙ê鐏f繝濠冨灴閹啴宕熼鍡╀紘婵炲濮惧Λ鍕叏閳哄懎绀夋繛鎴濈-楠炪垽鎮归崶褍妲婚柛銊ュ缁傚秹鏁撻敓锟� ---闂佹寧娲╅幏锟�
开发学院手机开发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 [复制链接] [打 印]
赞助商链接