Add tracing to various graphics components.
This change adds ATRACE call tracing to BufferQueue,
SurfaceTextureClient, SurfaceTexture, SurfaceFlinger, Layer, and EGL.
Change-Id: I9d75ed26f5a3f0d1af635da38289520134cfbbb7
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index 66fc16d..d761680 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -16,6 +16,7 @@
#define LOG_TAG "BufferQueue"
//#define LOG_NDEBUG 0
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
@@ -29,6 +30,7 @@
#include <utils/Log.h>
#include <gui/SurfaceTexture.h>
+#include <utils/Trace.h>
// This compile option causes SurfaceTexture to return the buffer that is currently
// attached to the GL texture from dequeueBuffer when no other buffers are
@@ -191,6 +193,7 @@
int BufferQueue::query(int what, int* outValue)
{
+ ATRACE_CALL();
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
@@ -221,6 +224,7 @@
}
status_t BufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
+ ATRACE_CALL();
ST_LOGV("requestBuffer: slot=%d", slot);
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
@@ -239,6 +243,7 @@
status_t BufferQueue::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
uint32_t format, uint32_t usage) {
+ ATRACE_CALL();
ST_LOGV("dequeueBuffer: w=%d h=%d fmt=%#x usage=%#x", w, h, format, usage);
if ((w && !h) || (!w && h)) {
@@ -458,6 +463,7 @@
}
status_t BufferQueue::setSynchronousMode(bool enabled) {
+ ATRACE_CALL();
ST_LOGV("setSynchronousMode: enabled=%d", enabled);
Mutex::Autolock lock(mMutex);
@@ -490,6 +496,7 @@
status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
+ ATRACE_CALL();
ST_LOGV("queueBuffer: slot=%d time=%lld", buf, timestamp);
sp<FrameAvailableListener> listener;
@@ -553,6 +560,8 @@
*outWidth = mDefaultWidth;
*outHeight = mDefaultHeight;
*outTransform = 0;
+
+ ATRACE_INT(mConsumerName.string(), mQueue.size());
} // scope for the lock
// call back without lock held
@@ -563,6 +572,7 @@
}
void BufferQueue::cancelBuffer(int buf) {
+ ATRACE_CALL();
ST_LOGV("cancelBuffer: slot=%d", buf);
Mutex::Autolock lock(mMutex);
@@ -586,6 +596,7 @@
}
status_t BufferQueue::setCrop(const Rect& crop) {
+ ATRACE_CALL();
ST_LOGV("setCrop: crop=[%d,%d,%d,%d]", crop.left, crop.top, crop.right,
crop.bottom);
@@ -599,6 +610,7 @@
}
status_t BufferQueue::setTransform(uint32_t transform) {
+ ATRACE_CALL();
ST_LOGV("setTransform: xform=%#x", transform);
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
@@ -610,6 +622,7 @@
}
status_t BufferQueue::setScalingMode(int mode) {
+ ATRACE_CALL();
ST_LOGV("setScalingMode: mode=%d", mode);
switch (mode) {
@@ -628,6 +641,7 @@
status_t BufferQueue::connect(int api,
uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
+ ATRACE_CALL();
ST_LOGV("connect: api=%d", api);
Mutex::Autolock lock(mMutex);
@@ -664,6 +678,7 @@
}
status_t BufferQueue::disconnect(int api) {
+ ATRACE_CALL();
ST_LOGV("disconnect: api=%d", api);
Mutex::Autolock lock(mMutex);
@@ -818,6 +833,8 @@
mSlots[buf].mBufferState = BufferSlot::ACQUIRED;
mQueue.erase(front);
+
+ ATRACE_INT(mConsumerName.string(), mQueue.size());
}
else {
return -EINVAL; //should be a better return code
@@ -875,6 +892,7 @@
}
status_t BufferQueue::setBufferCountServer(int bufferCount) {
+ ATRACE_CALL();
Mutex::Autolock lock(mMutex);
return setBufferCountServerLocked(bufferCount);
}
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index a23a328..b42aa34 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -15,6 +15,7 @@
*/
#define LOG_TAG "SurfaceTexture"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
//#define LOG_NDEBUG 0
#define GL_GLEXT_PROTOTYPES
@@ -36,6 +37,7 @@
#include <utils/Log.h>
#include <utils/String8.h>
+#include <utils/Trace.h>
// This compile option makes SurfaceTexture use the EGL_KHR_fence_sync extension
// to synchronize access to the buffers. It will cause dequeueBuffer to stall,
@@ -143,6 +145,7 @@
}
status_t SurfaceTexture::updateTexImage() {
+ ATRACE_CALL();
ST_LOGV("updateTexImage");
Mutex::Autolock lock(mMutex);
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index dac54a8..f88dcaf 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -15,9 +15,11 @@
*/
#define LOG_TAG "SurfaceTextureClient"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
//#define LOG_NDEBUG 0
#include <utils/Log.h>
+#include <utils/Trace.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
@@ -121,6 +123,7 @@
}
int SurfaceTextureClient::setSwapInterval(int interval) {
+ ATRACE_CALL();
// EGL specification states:
// interval is silently clamped to minimum and maximum implementation
// dependent values before being stored.
@@ -138,6 +141,7 @@
}
int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) {
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::dequeueBuffer");
Mutex::Autolock lock(mMutex);
int buf = -1;
@@ -167,6 +171,7 @@
}
int SurfaceTextureClient::cancelBuffer(android_native_buffer_t* buffer) {
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::cancelBuffer");
Mutex::Autolock lock(mMutex);
int i = getSlotFromBufferLocked(buffer);
@@ -213,6 +218,7 @@
}
int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) {
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::queueBuffer");
Mutex::Autolock lock(mMutex);
int64_t timestamp;
@@ -236,6 +242,7 @@
}
int SurfaceTextureClient::query(int what, int* value) const {
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::query");
{ // scope for the lock
Mutex::Autolock lock(mMutex);
@@ -404,6 +411,7 @@
int SurfaceTextureClient::connect(int api) {
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::connect");
Mutex::Autolock lock(mMutex);
int err = mSurfaceTexture->connect(api,
@@ -415,6 +423,7 @@
}
int SurfaceTextureClient::disconnect(int api) {
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::disconnect");
Mutex::Autolock lock(mMutex);
freeAllBuffers();
@@ -441,6 +450,7 @@
int SurfaceTextureClient::setCrop(Rect const* rect)
{
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::setCrop");
Mutex::Autolock lock(mMutex);
@@ -459,6 +469,7 @@
int SurfaceTextureClient::setBufferCount(int bufferCount)
{
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::setBufferCount");
Mutex::Autolock lock(mMutex);
@@ -475,6 +486,7 @@
int SurfaceTextureClient::setBuffersDimensions(int w, int h)
{
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::setBuffersDimensions");
Mutex::Autolock lock(mMutex);
@@ -508,6 +520,7 @@
int SurfaceTextureClient::setScalingMode(int mode)
{
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::setScalingMode(%d)", mode);
Mutex::Autolock lock(mMutex);
// mode is validated on the server
@@ -520,6 +533,7 @@
int SurfaceTextureClient::setBuffersTransform(int transform)
{
+ ATRACE_CALL();
ALOGV("SurfaceTextureClient::setBuffersTransform");
Mutex::Autolock lock(mMutex);
status_t err = mSurfaceTexture->setTransform(transform);