UNDERSTANDING ANDROID GRAPHIC- SURFACEFLINGER (IV)

Having known that BufferQueue exposes the APIs for consuming surface frame while implementing BnGraphicBufferProducer, we continue our attempt to demystify surface compositions and rendering with an examination of a few more classes with respect to surface composing.

  • SurfaceFlingerConsumer and GLConsumer class

Defined in framework/native/services/surfaceflinger/SurfaceFlingerConsumer.h, and framework/native/include/gui/GLConsumer.h,SurfaceFlingerConsumer and GLConsumer are the core classes to fetch the current buffer from BufferQueue to bind to a surface layer specific GL texture.  GLConsumer uses GLES functions to conduct the operation while SurfaceFlingerConsumer is a wrapper around it to safeguard the operation. The main APIs in SurfaceFlingerConsumerare  updateTexImage() and bindTextureImage().

Note that a surface frame will be drawn to the display frame buffer as a GL texture and GLConsumer inherits from ConsumerBase.

  • Layer Class

It has been known that when a SurfaceComposerClient::createSurface  is invoked, Client in SurfaceFlinger posts a MessageCreateLayer toSurfaceFlinger which in turn calls SurfaceFlinger::createLayer() create aLayer instance to service the remote Surface instance.

Applying a lazy initialization, Layer delays until first reference to instantiate a BufferQueue object and SurfaceFlingerConsumercorresponding to the remote Surface object; meanwhile Layer links the BufferQueue object to SurfaceFlingerConsumer object and register itself as SurfaceFlingerConsumer::FrameAvailableListener listener among other procedures.

When Surface::queueBuffer() is invoked, BufferQueue::queueBuffer() and Layer::onFrameAvailable() call ensue ,as we elaborated in post SurfaceFlinger(III).

Subsequently , the Layer::draw() and Layer::onDraw() will be called to run SurfaceFlingerConsumer::bindTextureImage() andLayer::drawWithOpenGL() to FramebufferSurface current frame buffer.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值