問題:
1) Layer 之間能否進行單獨更新,比如其中video 層上面彈出的狀態欄場景如何優化;
初步構想每次僅更新video layer或則將video layer 繞過BQ 進行處理。
2)FW 以及GPU對video layer 的常見處理;
3)幾個變量的理解;
(1)mCurrentTexture ,nextTextureImage;
(2)BufferItem,BufferQueue,mslots;slot,mqueuedframe,mqueuedItem;
(3)syncForReleaseLocked,updateAndReleaseLocked,releaseBufferLocked,releaseBuffer
(4)
/ acquireBuffer attempts to acquire ownership of the next pending buffer in the BufferQueue. 54 // If no buffer is pending then it returns NO_BUFFER_AVAILABLE. If a buffer is successfully 55 // acquired, the information about the buffer is returned in BufferItem. 56 // 57 // If the buffer returned had previously been acquired then the BufferItem::mGraphicBuffer field 58 // of buffer is set to NULL and it is assumed that the consumer still holds a reference to the 59 // buffer. 60 // 61 // If presentWhen is non-zero, it indicates the time when the buffer will be displayed on 62 // screen. If the buffer's timestamp is farther in the future, the buffer won't be acquired, and 63 // PRESENT_LATER will be returned. The presentation time is in nanoseconds, and the time base 64 // is CLOCK_MONOTONIC. 65 // 66 // If maxFrameNumber is non-zero, it indicates that acquireBuffer should only return a buffer 67 // with a frame number less than or equal to maxFrameNumber. If no such frame is available 68 // (such as when a buffer has been replaced but the consumer has not received the 69 // onFrameReplaced callback), then PRESENT_LATER will be returned. 70 // 71 // Return of NO_ERROR means the operation completed as normal. 72 // 73 // Return of a positive value means the operation could not be completed at this time, but the 74 // user should try again later: 75 // * NO_BUFFER_AVAILABLE - no buffer is pending (nothing queued by producer) 76 // * PRESENT_LATER - the buffer's timestamp is farther in the future 77 // 78 // Return of a negative value means an error has occurred: 79 // * INVALID_OPERATION - too many buffers have been acquired
// Returned by releaseBuffer, after which the consumer must free any references to the 45 // just-released buffer that it might have. 46 STALE_BUFFER_SLOT = 1, 47 // Returned by dequeueBuffer if there are no pending buffers available. 48 NO_BUFFER_AVAILABLE, 49 // Returned by dequeueBuffer if it's too early for the buffer to be acquired. 50 PRESENT_LATER,
(5)mslots 與mframe 以及mframenumber 的區別
(6)onframavailable 和latchbuffer ,reject,updateteximage,的邏輯。
其中updateteximage;
(7)bufferitem 與mslots的區別
(8)bufferqueueconsumer 與bufferitemconsumer區別;
(9)acquirebuffer的fence 邏輯,fencefd是哪來的;
status_t Fence::waitForever(const char* logname) { 64 ATRACE_CALL(); 65 if (mFenceFd == -1) { 66 return NO_ERROR; 67 } 68 int warningTimeout = 3000; 69 int err = sync_wait(mFenceFd, warningTimeout); 70 if (err < 0 && errno == ETIME) { 71 ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd, 72 warningTimeout); 73 err = sync_wait(mFenceFd, TIMEOUT_NEVER); 74 } 75 return err < 0 ? -errno : status_t(NO_ERROR); 76 }
struct EglSlot {
465 EglSlot() : mEglFence(EGL_NO_SYNC_KHR) {}
466
467 // mEglImage is the EGLImage created from mGraphicBuffer.
468 sp<EglImage> mEglImage;
469
470 // mFence is the EGL sync object that must signal before the buffer
471 // associated with this buffer slot may be dequeued. It is initialized
472 // to EGL_NO_SYNC_KHR when the buffer is created and (optionally, based
473 // on a compile-time option) set to a new sync object in updateTexImage.
474 EGLSyncKHR mEglFence;
475 };
(10)
updateAndReleaseLocked(item, &mPendingRelease),
updateAndReleaseLocked(item),
bindTextureImageLocked()