gralloc 学习

1. 首先给自己做个list, 方便查找

camera 用到ANativewindow src code

         /frameworks/av/services/camera/libcameraservice/CameraHardwareInterface.h
         /system/core/include/system/window.h
        /frameworks/native/libs/gui/SurfaceTextureClient.cpp



2 . ANativeWindow API:

在这一过程中使用的API

        a 、cancelBuffer

        Hook used to cancel a buffer that has been dequeued. No synchronization is performed between dequeue() and cancel(), so either external synchronization is needed, or these functions must be called from the same thread.

        b、 queuebuffer  ---

        Hook called by EGL when modifications to the render buffer are done. This unlocks and post the buffer

The window holds a reference to the buffer between dequeueBuffer and either queueBuffer or cancelBuffer, so clients only need their own reference if they might use the buffer after queueing or canceling it.

         c、dequeuebuffer

         Hook called by EGL to acquire a buffer. This call may block if no buffers are available.

          d、lock_buffer -- do nothing

    static int __lock_buffer(struct preview_stream_ops* w,
                      buffer_handle_t* /*buffer*/)
    {
        ANativeWindow *a = anw(w);
        (void)a;
        return 0;
    }

3. GraphicBufferMapper

         GraphicBufferMapper& mapper(GraphicBufferMapper::get());

         mapper.lock(*phandle, CAMHAL_GRALLOC_USAGE, rect, &img);

The (*lock)() method is called before a buffer is accessed for the specified usage.

This call may block, for instance if the h/w needsto finish rendering or if CPU caches need to be synchronized.  

          The caller promises to modify only pixels in the area specified by (l,t,w,h).

        mapper.unlock((buffer_handle_t) *phandle);

             The (*unlock)() method must be called after all changes to the buffer are completed.

those function been defined in 

           hardware/libhardware/include/hardware/gralloc.h

      gralloc.cpp

 88         registerBuffer: gralloc_register_buffer,
  89         unregisterBuffer: gralloc_unregister_buffer,
  90         lock: gralloc_lock,                                                                                                                                      
  91         unlock: gralloc_unlock,   ->gc_gralloc_lock
  92         perform: gralloc_perform,

      lock:   1. Lock android native buffer and get Vaddress

       unlock: ion_flush(hnd);




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值