关闭

UNDERSTANDING ANDROID GRAPHICS INTERNALS – GRALLOC AND HWCOMPOSER

153人阅读 评论(0) 收藏 举报
分类:

gralloc and hwcomposer are hardware abstraction modules compliant to hw_module_t (defined in hardware/libhardware/include/hardware/hardware.h). Vendors mostly overwrite the android release implementation to suite their hardware platforms for optimal performance.

  • gralloc

Gralloc’s hardware module ide is GRALLOC_HARDWARE_MODULE_ID and hosts two hw_device_t instances with the name of GRALLOC_HARDWARE_GPU0 and GRALLOC_HARDWARE_FB0 respectively.

The GRALLOC_HARDWARE_GPU0 device provides the APIs to allocate and release graphic buffer memory from ashmem driver; in case GRALLOC_USAGE_HW_FB is set, the buffer memory will be allocated from the frame buffer device, which are physically contiguous. In SurfaceFlinger FramebufferSurface handles frame buffer allocation. The number of frame buffer to allocate is macro defined in NUM_FRAMEBUFFER_SURFACE_BUFFERS. The default value is 2.

In the framework, a singleton utility class GraphicBufferMapper (defined in frameworks/native/include/ui/GraphicBufferMapper.h) helps the mapping/unmapping of buffer_handle_t instance to virtual memory address, and register/unregister a remote buffer_handle_t instance allocated out of the process. You may GraphicBuffer has a field to get a per process reference to the singleton class.

The GRALLOC_HARDWARE_FB0 device exposes methods to set frame swap interval  and post a frame for rendering; it also exposes typical frame buffer device parameters for querying, which include frame buffer flags, geometrical sizes, resolutions, color scheme etc.

In SurfaceFlinger, the GRALLOC_HARDWARE_FB0 device is managed by HWComposer class; The latter manages the hwcomposer module as well.

  • hwcomposer

Its hardware module id is HWC_HARDWARE_MODULE_ID; It contains one device with the name  of HWC_HARDWARE_COMPOSER.  hwcomposer’s functionality is well documented in hardware/libhardware/include/hwcomposer.h. You may view the file from the link (https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/hwcomposer.h)

The (*prepare)() and (*set)() methods in the abstract device are two methods to determine whether a surface layer shall be rendered through overlay and trigger the frame buffer switch respectively. The (*eventControl)() is for vsync purpose.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:14735次
    • 积分:282
    • 等级:
    • 排名:千里之外
    • 原创:8篇
    • 转载:38篇
    • 译文:0篇
    • 评论:0条
    文章分类