UNDERSTANDING ANDROID GRAPHICS INTERNALS – GRALLOC AND HWCOMPOSER

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.

Understanding Linux Network Internals”(了解Linux网络内部)是一本介绍Linux操作系统网络内部机制的书籍。该书深入介绍了Linux操作系统中网络协议栈的实现原理,以及网络设备驱动程序、套接字接口和网络管理等方面的知识。 该书以理论和实践相结合的方式,系统地介绍了Linux网络协议栈的设计、功能和实现。它从网络硬件驱动程序开始,逐步探讨了数据在不同网络层之间的传输过程,包括数据包的封装、解封装、路由选择和转发等关键步骤。 此外,该书还介绍了Linux内核中关键的网络数据结构、算法和协议。读者可以学习到如何使用套接字编程接口创建网络应用程序,并深入了解每个网络层的功能和工作原理,从而更好地理解Linux操作系统中网络的运行机制。 对于计算机网络相关的开发人员和系统管理员而言,深入了解Linux网络内部机制是非常重要的。通过掌握Linux网络协议栈的实现原理,操作系统和网络应用程序的开发者可以更好地进行网络性能调优、故障排查和安全加固等工作。同时,系统管理员可以更好地监控和管理网络资源,提高网络的可靠性和性能。 总的来说,阅读“Understanding Linux Network Internals”这本书可以帮助读者深入了解Linux操作系统中网络的工作原理和机制,进而提升计算机网络相关领域的技术能力。这对于开发人员和系统管理员来说都是非常有价值的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值