UNDERSTANDING ANDROID GRAPHICS INTERNALS – SURFACEFLINGER (II)

Prior to Jelly Bean, the threadLoop in SurfaceFlinger.cpp processes composition and rendering sequentially in a thread loop. Newly enqueued graphic buffer won’t be handled until the rendering of current frame buffer is complete. As a result, animation shown on display may appear jumpy or tearing in rendering. To address this issue, Android introduces vsync event into SurfaceFlinger.

In android, a vsync event relates to timestamp. For each display device, android assigns a DisplayEventReceiver::Event  ( defined in framework/native/include/gui/DisplayEventReceiver.h) structure, i.e. mVSyncEvent. mVSyncEvent.header.timestamp. Even though the timestamp value is refreshed with system time, the significance is whether it is non-zero. If it is nonzero, SurfaceFlinger will trigger either a refresh action or an invalidate action on the corresponding display and reset timestamp to zero.

vsync events can be generated from several sources.

  • Periodical vsync event sources

If hwcomposer module is present, it will be generated either from the vsync signal emitted from the frame buffer device driver; or faked from the hwcomposer module.

If the hwcomposer module is not present, the VSyncThread will generate it.

  • Spontaneous vsync event sources

A UI view may instantiate DisplayEventReceiver and thus obtain an IDisplayEventConnection interface through createDisplayEventConnection() call. Whenever the view has a graphic buffer to update, it may sound a requestNextVsync() call on the IDisplayEventConnection interface.

To establish concurrency between composition and rendering, SurfaceFlinger in Jelly Bean made two major changes in threading model and asynchrocy, adding a new EventThread thread to handle DisplayEventReceiver::Event events, adopted a Looper/Handler/MessageQueue paradigm in SurfaceFlinger main thread. As a side note, the EventThread also handles display hotplug event ( hwcomposer module may listen on uevent).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值