Merge "Add tracing to various graphics components."

This commit is contained in:
Jamie Gennis 2012-02-27 18:06:39 -08:00 committed by Android (Google) Code Review
commit 910b2b2ff5
6 changed files with 56 additions and 0 deletions

View File

@ -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 @@ status_t BufferQueue::setBufferCount(int bufferCount) {
int BufferQueue::query(int what, int* outValue)
{
ATRACE_CALL();
Mutex::Autolock lock(mMutex);
if (mAbandoned) {
@ -221,6 +224,7 @@ int BufferQueue::query(int what, int* outValue)
}
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::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
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::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
}
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::setSynchronousMode(bool enabled) {
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 @@ status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
*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 @@ status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
}
void BufferQueue::cancelBuffer(int buf) {
ATRACE_CALL();
ST_LOGV("cancelBuffer: slot=%d", buf);
Mutex::Autolock lock(mMutex);
@ -586,6 +596,7 @@ void BufferQueue::cancelBuffer(int buf) {
}
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::setCrop(const Rect& crop) {
}
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::setTransform(uint32_t transform) {
}
status_t BufferQueue::setScalingMode(int mode) {
ATRACE_CALL();
ST_LOGV("setScalingMode: mode=%d", mode);
switch (mode) {
@ -628,6 +641,7 @@ status_t BufferQueue::setScalingMode(int mode) {
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::connect(int api,
}
status_t BufferQueue::disconnect(int api) {
ATRACE_CALL();
ST_LOGV("disconnect: api=%d", api);
Mutex::Autolock lock(mMutex);
@ -818,6 +833,8 @@ status_t BufferQueue::acquire(BufferItem *buffer) {
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::setDefaultBufferSize(uint32_t w, uint32_t h)
}
status_t BufferQueue::setBufferCountServer(int bufferCount) {
ATRACE_CALL();
Mutex::Autolock lock(mMutex);
return setBufferCountServerLocked(bufferCount);
}

View File

@ -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::setDefaultBufferSize(uint32_t w, uint32_t h)
}
status_t SurfaceTexture::updateTexImage() {
ATRACE_CALL();
ST_LOGV("updateTexImage");
Mutex::Autolock lock(mMutex);

View File

@ -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::hook_perform(ANativeWindow* window, int operation, ...
}
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::setSwapInterval(int interval) {
}
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::dequeueBuffer(android_native_buffer_t** buffer) {
}
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::lockBuffer(android_native_buffer_t* buffer) {
}
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::queueBuffer(android_native_buffer_t* buffer) {
}
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::dispatchUnlockAndPost(va_list args) {
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::connect(int api) {
}
int SurfaceTextureClient::disconnect(int api) {
ATRACE_CALL();
ALOGV("SurfaceTextureClient::disconnect");
Mutex::Autolock lock(mMutex);
freeAllBuffers();
@ -441,6 +450,7 @@ int SurfaceTextureClient::setUsage(uint32_t reqUsage)
int SurfaceTextureClient::setCrop(Rect const* rect)
{
ATRACE_CALL();
ALOGV("SurfaceTextureClient::setCrop");
Mutex::Autolock lock(mMutex);
@ -459,6 +469,7 @@ int SurfaceTextureClient::setCrop(Rect const* rect)
int SurfaceTextureClient::setBufferCount(int bufferCount)
{
ATRACE_CALL();
ALOGV("SurfaceTextureClient::setBufferCount");
Mutex::Autolock lock(mMutex);
@ -475,6 +486,7 @@ int SurfaceTextureClient::setBufferCount(int bufferCount)
int SurfaceTextureClient::setBuffersDimensions(int w, int h)
{
ATRACE_CALL();
ALOGV("SurfaceTextureClient::setBuffersDimensions");
Mutex::Autolock lock(mMutex);
@ -508,6 +520,7 @@ int SurfaceTextureClient::setBuffersFormat(int format)
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::setScalingMode(int mode)
int SurfaceTextureClient::setBuffersTransform(int transform)
{
ATRACE_CALL();
ALOGV("SurfaceTextureClient::setBuffersTransform");
Mutex::Autolock lock(mMutex);
status_t err = mSurfaceTexture->setTransform(transform);

View File

@ -14,6 +14,8 @@
** limitations under the License.
*/
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@ -34,6 +36,7 @@
#include <utils/KeyedVector.h>
#include <utils/SortedVector.h>
#include <utils/String8.h>
#include <utils/Trace.h>
#include "egl_impl.h"
#include "egl_tls.h"
@ -348,6 +351,7 @@ EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface,
}
void EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) {
ATRACE_CALL();
clearError();
egl_display_t const * const dp = validate_display(dpy);
@ -712,6 +716,7 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
{
ATRACE_CALL();
clearError();
egl_display_t const * const dp = validate_display(dpy);

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
@ -26,6 +28,7 @@
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/StopWatch.h>
#include <utils/Trace.h>
#include <ui/GraphicBuffer.h>
#include <ui/PixelFormat.h>
@ -267,6 +270,8 @@ void Layer::setPerFrameData(hwc_layer_t* hwcl) {
void Layer::onDraw(const Region& clip) const
{
ATRACE_CALL();
if (CC_UNLIKELY(mActiveBuffer == 0)) {
// the texture has not been created yet, this Layer has
// in fact never been drawn into. This happens frequently with
@ -365,6 +370,8 @@ bool Layer::isProtected() const
uint32_t Layer::doTransaction(uint32_t flags)
{
ATRACE_CALL();
const Layer::State& front(drawingState());
const Layer::State& temp(currentState());
@ -418,6 +425,8 @@ bool Layer::onPreComposition() {
void Layer::lockPageFlip(bool& recomputeVisibleRegions)
{
ATRACE_CALL();
if (mQueuedFrames > 0) {
// if we've already called updateTexImage() without going through
@ -540,6 +549,8 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
void Layer::unlockPageFlip(
const Transform& planeTransform, Region& outDirtyRegion)
{
ATRACE_CALL();
Region postedRegion(mPostedDirtyRegion);
if (!postedRegion.isEmpty()) {
mPostedDirtyRegion.clear();

View File

@ -14,6 +14,8 @@
* limitations under the License.
*/
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
@ -39,6 +41,7 @@
#include <utils/String8.h>
#include <utils/String16.h>
#include <utils/StopWatch.h>
#include <utils/Trace.h>
#include <ui/GraphicBufferAllocator.h>
#include <ui/PixelFormat.h>
@ -402,6 +405,7 @@ bool SurfaceFlinger::threadLoop()
void SurfaceFlinger::onMessageReceived(int32_t what)
{
ATRACE_CALL();
switch (what) {
case MessageQueue::REFRESH: {
// case MessageQueue::INVALIDATE: {
@ -737,6 +741,7 @@ void SurfaceFlinger::commitTransaction()
void SurfaceFlinger::handlePageFlip()
{
ATRACE_CALL();
const DisplayHardware& hw = graphicPlane(0).displayHardware();
const Region screenRegion(hw.bounds());