1616
1717#define LOG_TAG " BufferQueue"
1818// #define LOG_NDEBUG 0
19+ #define ATRACE_TAG ATRACE_TAG_GRAPHICS
1920
2021#define GL_GLEXT_PROTOTYPES
2122#define EGL_EGLEXT_PROTOTYPES
2930
3031#include < utils/Log.h>
3132#include < gui/SurfaceTexture.h>
33+ #include < utils/Trace.h>
3234
3335// This compile option causes SurfaceTexture to return the buffer that is currently
3436// attached to the GL texture from dequeueBuffer when no other buffers are
@@ -191,6 +193,7 @@ status_t BufferQueue::setBufferCount(int bufferCount) {
191193
192194int BufferQueue::query (int what, int * outValue)
193195{
196+ ATRACE_CALL ();
194197 Mutex::Autolock lock (mMutex );
195198
196199 if (mAbandoned ) {
@@ -221,6 +224,7 @@ int BufferQueue::query(int what, int* outValue)
221224}
222225
223226status_t BufferQueue::requestBuffer (int slot, sp<GraphicBuffer>* buf) {
227+ ATRACE_CALL ();
224228 ST_LOGV (" requestBuffer: slot=%d" , slot);
225229 Mutex::Autolock lock (mMutex );
226230 if (mAbandoned ) {
@@ -239,6 +243,7 @@ status_t BufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
239243
240244status_t BufferQueue::dequeueBuffer (int *outBuf, uint32_t w, uint32_t h,
241245 uint32_t format, uint32_t usage) {
246+ ATRACE_CALL ();
242247 ST_LOGV (" dequeueBuffer: w=%d h=%d fmt=%#x usage=%#x" , w, h, format, usage);
243248
244249 if ((w && !h) || (!w && h)) {
@@ -458,6 +463,7 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
458463}
459464
460465status_t BufferQueue::setSynchronousMode (bool enabled) {
466+ ATRACE_CALL ();
461467 ST_LOGV (" setSynchronousMode: enabled=%d" , enabled);
462468 Mutex::Autolock lock (mMutex );
463469
@@ -490,6 +496,7 @@ status_t BufferQueue::setSynchronousMode(bool enabled) {
490496
491497status_t BufferQueue::queueBuffer (int buf, int64_t timestamp,
492498 uint32_t * outWidth, uint32_t * outHeight, uint32_t * outTransform) {
499+ ATRACE_CALL ();
493500 ST_LOGV (" queueBuffer: slot=%d time=%lld" , buf, timestamp);
494501
495502 sp<FrameAvailableListener> listener;
@@ -553,6 +560,8 @@ status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
553560 *outWidth = mDefaultWidth ;
554561 *outHeight = mDefaultHeight ;
555562 *outTransform = 0 ;
563+
564+ ATRACE_INT (mConsumerName .string (), mQueue .size ());
556565 } // scope for the lock
557566
558567 // call back without lock held
@@ -563,6 +572,7 @@ status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
563572}
564573
565574void BufferQueue::cancelBuffer (int buf) {
575+ ATRACE_CALL ();
566576 ST_LOGV (" cancelBuffer: slot=%d" , buf);
567577 Mutex::Autolock lock (mMutex );
568578
@@ -586,6 +596,7 @@ void BufferQueue::cancelBuffer(int buf) {
586596}
587597
588598status_t BufferQueue::setCrop (const Rect& crop) {
599+ ATRACE_CALL ();
589600 ST_LOGV (" setCrop: crop=[%d,%d,%d,%d]" , crop.left , crop.top , crop.right ,
590601 crop.bottom );
591602
@@ -599,6 +610,7 @@ status_t BufferQueue::setCrop(const Rect& crop) {
599610}
600611
601612status_t BufferQueue::setTransform (uint32_t transform) {
613+ ATRACE_CALL ();
602614 ST_LOGV (" setTransform: xform=%#x" , transform);
603615 Mutex::Autolock lock (mMutex );
604616 if (mAbandoned ) {
@@ -610,6 +622,7 @@ status_t BufferQueue::setTransform(uint32_t transform) {
610622}
611623
612624status_t BufferQueue::setScalingMode (int mode) {
625+ ATRACE_CALL ();
613626 ST_LOGV (" setScalingMode: mode=%d" , mode);
614627
615628 switch (mode) {
@@ -628,6 +641,7 @@ status_t BufferQueue::setScalingMode(int mode) {
628641
629642status_t BufferQueue::connect (int api,
630643 uint32_t * outWidth, uint32_t * outHeight, uint32_t * outTransform) {
644+ ATRACE_CALL ();
631645 ST_LOGV (" connect: api=%d" , api);
632646 Mutex::Autolock lock (mMutex );
633647
@@ -664,6 +678,7 @@ status_t BufferQueue::connect(int api,
664678}
665679
666680status_t BufferQueue::disconnect (int api) {
681+ ATRACE_CALL ();
667682 ST_LOGV (" disconnect: api=%d" , api);
668683 Mutex::Autolock lock (mMutex );
669684
@@ -818,6 +833,8 @@ status_t BufferQueue::acquire(BufferItem *buffer) {
818833
819834 mSlots [buf].mBufferState = BufferSlot::ACQUIRED;
820835 mQueue .erase (front);
836+
837+ ATRACE_INT (mConsumerName .string (), mQueue .size ());
821838 }
822839 else {
823840 return -EINVAL; // should be a better return code
@@ -875,6 +892,7 @@ status_t BufferQueue::setDefaultBufferSize(uint32_t w, uint32_t h)
875892}
876893
877894status_t BufferQueue::setBufferCountServer (int bufferCount) {
895+ ATRACE_CALL ();
878896 Mutex::Autolock lock (mMutex );
879897 return setBufferCountServerLocked (bufferCount);
880898}
0 commit comments