发现一个比较好的介绍graphic帖子, 后面会跟着帖子来梳理下graphic相关知识点
http://blog.csdn.net/u014409795/article/details/51276468
BufferQueue
class BufferQueue {
class ProxyConsumerListener : public BnConsumerListener;
static void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
sp<IGraphicBufferConsumer>* outConsumer,
const sp<IGraphicBufferAlloc>& allocator = NULL);
private:
BufferQueue(); // Create through createBufferQueue
}
//看起来只有consumer一个角色?
void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
sp<IGraphicBufferConsumer>* outConsumer,
const sp<IGraphicBufferAlloc>& allocator) {
sp<BufferQueueCore> core(new BufferQueueCore(allocator));
sp<IGraphicBufferProducer> producer(new BufferQueueProducer(core));
sp<IGraphicBufferConsumer> consumer(new BufferQueueConsumer(core));
BufferQueue核心是BufferQueueCore,
看BufferQueueCore里面是管理什么的
class BufferQueueCore : public virtual RefBase {
friend class BufferQueueProducer;
friend class BufferQueueConsumer;
typedef Vector<BufferItem> Fifo; //一个BufferItem Vector
private:
// mAllocator is the connection to SurfaceFlinger that is used to allocate
// new GraphicBuffer objects.
sp<IGraphicBufferAlloc> mAllocator;
// mSlots is an array of buffer slots that must be mirrored on the producer
// side. This allows buffer ownership to be transferred between the producer
// and consumer without sending a GraphicBuffer over Binder. The entire
// array is initialized to NULL at construction time, and buffers are
// allocated for a slot when requestBuffer is called with that slot's index.
BufferQueueDefs::SlotsType mSlots; //
BufferSlot()
: mEglDisplay(EGL_NO_DISPLAY),
mBufferState(BufferSlot::FREE), //state
mRequestBufferCalled(false),
mFrameNumber(0),
mEglFence(EGL_NO_SYNC_KHR),
mAcquireCalled(false),
mNeedsCleanupOnRelease(false),
mAttachedByConsumer(false) {
}
// mGraphicBuffer points to the buffer allocated for this slot or is NULL
// if no buffer has been allocated.
sp<GraphicBuffer> mGraphicBuffer; //bufferslot中指向GraphicBuffer
enum BufferState { // state 表示buffer state
FREE = 0, //FREE indicates that the buffer is available to be dequeued by the producer.
// 允许produce获取该buffer,填充数据,状态变为dequeue free 时表示该buffer还被bufferqueue 所有
DEQUEUED = 1,// DEQUEUED indicates that the buffer has been dequeued by the producer, but has not yet been queued or canceled. The slot is "owned" by the producer. 处于待填充数据状态,被producer所有
QUEUED = 2,//QUEUED indicates that the buffer has been filled by the producer and queued for use by the consumer; producer填充完数据,准备提供给consumer消费,被bufferqueue所有
ACQUIRED = 3//ACQUIRED indicates that the buffer has been acquired by the consumer.
buffer被consumer获取到,消费完后转为free
在bufferqueuecore中bufferItem又是什么
class BufferItem : public Flattenable<BufferItem> {
// mGraphicBuffer points to the buffer allocated for this slot, or is NULL
// if the buffer in this slot has been acquired in the past (see
// BufferSlot.mAcquireCalled).
sp<GraphicBuffer> mGraphicBuffer; //也有GraphicBuffer指针
union {
// mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
int mSlot; // slot数组中索引
// mBuf is the former name for mSlot
int mBuf; // 旧名字
};
BufferSlot 与 BufferItem 都指向GraphicBuffer,然后又 通过mSlot下标关联起来,至于两者使用场景再看
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享标题:Graphic学习笔记-创新互联
分享链接:https://www.cdcxhl.com/article0/ccidoo.html
成都网站建设公司_创新互联,为您提供网站维护、网站内链、搜索引擎优化、企业建站、App设计、商城网站
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联