详解 Android 图形系统
2010-03-10 16:45:00 来源:WEB开发网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如何创建的关键路径如下:
- ››Android 当修改一些代码时,使用什么编译命令可以最...
- ››Android 如何添加一个apk使模拟器和真机都编译进去...
- ››Android 修改Camera拍照的默认保存路径
- ››Android 如何修改默认输入法
- ››android开发中finish()和System.exit(0)的区别
- ››Android手势识别简单封装类
- ››android中查看项目数字证书的两种方法
- ››Android中获取IMEI码的办法
- ››android 相机报错 setParameters failed
- ››Android重启运用程序的代码
- ››Android为ListView的Item设置不同的布局
- ››android bitmap与base64字符串的互相转换
更多精彩
赞助商链接