UNDERSTANDING ANDROID GRAPHICS INTERNALS -SURFACEFLINGER(V)
来源:互联网 发布:淘宝大号怎么关联小号 编辑:程序博客网 时间:2024/05/16 17:49
from: https://charleszblog.wordpress.com/category/android-2/graphics-android/
This SurfaceFlinger series turns lengthy. Let’s see if we can wrap it up in this post.
- FramebufferSurface and DisplayDevice
Jelly Bean supports external displays(e.g. HDMI, WiDi). Each display is represented by a DisplayDevice instance and associated with aFramebufferSurface instance which makes the mDisplaySurface field.
FramebufferSurface subclasses both ConsumeBase and DisplaySurfaceand wraps around a BufferQueue instance.
DisplayDevice maintains a reference to a vector of all sorted visible layers in mVisibleLayersSortedByZ, which is tracked in SurfaceFlinger::mDrawingState.
SurfaceFlinger tracks all DisplayDevice in an keyed vectormDisplays. SurfaceFlinger::readyToRun() creates each DisplayDevicealong with FramebufferSurface and adds each to mDisplays.
In SurfaceFlinger::doDisplayComposition(),when composition is complete and the display back frame buffer is drawn; then DisplayDevice::swapBuffers() is invoked for a DisplayDeviceinstance. Within the latter call, eglSwapBuffers() is called. As a result, FramebufferSurface::onFrameAvailable() is called.
In FramebufferSurface::onFrameAvailable(), HwComposer::fbPost() is called, in which for non HWC_DEVICE_API_VERSION_1_1,framebuffer_device_t::post in gralloc module is called to post the back frame buffer to frame buffer device driver.
- HWComposer
This class wraps framebuffer_device_t and struct hwc_composer_device_1 and manages the vsync withHWComposer::event_control(), HWComposer::sync().
SurfaceFlinger owns an instance of HWComposer.
- SurfaceFlinger
1. Implements BnISurfaceComposer functionality
BnISurfaceComposerClient is implemented by Client class; responsible for creation of Layer instances.
2. Implements HWComposer::EventHandler
Accepts on vsync and hotplug in events from hwcomposer module; process vsync enable/disable in eventControl().
3. Runs message queue on its own thread loop.
after initialization in readyToRun(), all handling is asynchronous and message driven.
4. readyToRun()
Instantiates HWComposer instances, instantiates and InitializesDisplayDevice objects and corresponding FramebufferSurface objects, initializes egl config, context, etc.
5. Maintains the current and the drawing SurfaceFlinger::State
Drawing state is the state being rendered, the current state is open for modifications. mCurrentState is copied to mDrawingState in CommitTransaction during handling of MessageQueue::TRANSACTION and MessageQueue::INVALIDATEmessages.
6. Several sources may trigger composition
new surface frame queued, changes in orientation and other flags, surface removal, vsync.
7. Composition and rendering
All layers are sorted by depth dimension Z, send layer state information to hwcomposer module to determine rendering by overlay or composition (by the prepare method in hwcomposer).
For layers selected for composition, compute visible regions based on Z and alpha blending factor, and draw them to each DisplayDevice object’s back FramebufferSurface.
When composition on a display is complete, invoke eglSwapBuffers to switch back FramebufferSurface to the front and posted to frame buffer device.
In summary, SurfaceFlinger design is complex and has to deal with many usage scenarios and corner use cases.
- UNDERSTANDING ANDROID GRAPHICS INTERNALS -SURFACEFLINGER(V)
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – SURFACEFLINGER (I)
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – SURFACEFLINGER (II)
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – SURFACEFLINGER (III)
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – GRAPHICS BASICS (I)
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – GRAPHICS BASICS(II)
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – GRALLOC AND HWCOMPOSER
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – GRAPHIC BUFFER HANDLING INTERFACES
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – THE GRAPHIC SURFACE SERVICE INTERFACES
- UNDERSTANDING ANDROID GRAPHIC- SURFACEFLINGER (IV)
- Understanding MySQL Internals
- Understanding Linux Network Internals
- 【转载】Understanding JVM Internals
- Understanding JVM Internals
- Understanding JVM Internals
- Understanding Linux Network Internals
- Understanding JVM Internals
- Understanding JVM Internals
- Java中的Random()函数
- js登录界面判断输入的用户名和密码是否为空
- Eclipse安装PMD插件
- 多媒体_创建图片副本
- Java输入输出流笔记
- UNDERSTANDING ANDROID GRAPHICS INTERNALS -SURFACEFLINGER(V)
- 第一次打开matlab
- Beam Search 简介
- digital root
- iOS -- 常用第三方框架
- UNDERSTANDING ANDROID GRAPHICS INTERNALS – SURFACEFLINGER (I)
- linux主机名被更改为bogon原理分析
- 【LTE基础知识】LTE之S1接口与X1接口介绍
- 小明同学写的打印lua表名称