Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a85ca37c authored by Jamie Gennis's avatar Jamie Gennis
Browse files

Add tracing to various graphics components.

This change adds ATRACE call tracing to BufferQueue,
SurfaceTextureClient, SurfaceTexture, SurfaceFlinger, Layer, and EGL.

Change-Id: I9d75ed26f5a3f0d1af635da38289520134cfbbb7
parent 6835237f
Loading
Loading
Loading
Loading
+18 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


#define LOG_TAG "BufferQueue"
#define LOG_TAG "BufferQueue"
//#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0
#define ATRACE_TAG ATRACE_TAG_GRAPHICS


#define GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
@@ -29,6 +30,7 @@


#include <utils/Log.h>
#include <utils/Log.h>
#include <gui/SurfaceTexture.h>
#include <gui/SurfaceTexture.h>
#include <utils/Trace.h>


// This compile option causes SurfaceTexture to return the buffer that is currently
// This compile option causes SurfaceTexture to return the buffer that is currently
// attached to the GL texture from dequeueBuffer when no other buffers are
// 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)
int BufferQueue::query(int what, int* outValue)
{
{
    ATRACE_CALL();
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


    if (mAbandoned) {
    if (mAbandoned) {
@@ -221,6 +224,7 @@ int BufferQueue::query(int what, int* outValue)
}
}


status_t BufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
status_t BufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
    ATRACE_CALL();
    ST_LOGV("requestBuffer: slot=%d", slot);
    ST_LOGV("requestBuffer: slot=%d", slot);
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    if (mAbandoned) {
    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,
status_t BufferQueue::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
        uint32_t format, uint32_t usage) {
        uint32_t format, uint32_t usage) {
    ATRACE_CALL();
    ST_LOGV("dequeueBuffer: w=%d h=%d fmt=%#x usage=%#x", w, h, format, usage);
    ST_LOGV("dequeueBuffer: w=%d h=%d fmt=%#x usage=%#x", w, h, format, usage);


    if ((w && !h) || (!w && h)) {
    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) {
status_t BufferQueue::setSynchronousMode(bool enabled) {
    ATRACE_CALL();
    ST_LOGV("setSynchronousMode: enabled=%d", enabled);
    ST_LOGV("setSynchronousMode: enabled=%d", enabled);
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


@@ -490,6 +496,7 @@ status_t BufferQueue::setSynchronousMode(bool enabled) {


status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
        uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
        uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
    ATRACE_CALL();
    ST_LOGV("queueBuffer: slot=%d time=%lld", buf, timestamp);
    ST_LOGV("queueBuffer: slot=%d time=%lld", buf, timestamp);


    sp<FrameAvailableListener> listener;
    sp<FrameAvailableListener> listener;
@@ -553,6 +560,8 @@ status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
        *outWidth = mDefaultWidth;
        *outWidth = mDefaultWidth;
        *outHeight = mDefaultHeight;
        *outHeight = mDefaultHeight;
        *outTransform = 0;
        *outTransform = 0;

        ATRACE_INT(mConsumerName.string(), mQueue.size());
    } // scope for the lock
    } // scope for the lock


    // call back without lock held
    // call back without lock held
@@ -563,6 +572,7 @@ status_t BufferQueue::queueBuffer(int buf, int64_t timestamp,
}
}


void BufferQueue::cancelBuffer(int buf) {
void BufferQueue::cancelBuffer(int buf) {
    ATRACE_CALL();
    ST_LOGV("cancelBuffer: slot=%d", buf);
    ST_LOGV("cancelBuffer: slot=%d", buf);
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


@@ -586,6 +596,7 @@ void BufferQueue::cancelBuffer(int buf) {
}
}


status_t BufferQueue::setCrop(const Rect& crop) {
status_t BufferQueue::setCrop(const Rect& crop) {
    ATRACE_CALL();
    ST_LOGV("setCrop: crop=[%d,%d,%d,%d]", crop.left, crop.top, crop.right,
    ST_LOGV("setCrop: crop=[%d,%d,%d,%d]", crop.left, crop.top, crop.right,
            crop.bottom);
            crop.bottom);


@@ -599,6 +610,7 @@ status_t BufferQueue::setCrop(const Rect& crop) {
}
}


status_t BufferQueue::setTransform(uint32_t transform) {
status_t BufferQueue::setTransform(uint32_t transform) {
    ATRACE_CALL();
    ST_LOGV("setTransform: xform=%#x", transform);
    ST_LOGV("setTransform: xform=%#x", transform);
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    if (mAbandoned) {
    if (mAbandoned) {
@@ -610,6 +622,7 @@ status_t BufferQueue::setTransform(uint32_t transform) {
}
}


status_t BufferQueue::setScalingMode(int mode) {
status_t BufferQueue::setScalingMode(int mode) {
    ATRACE_CALL();
    ST_LOGV("setScalingMode: mode=%d", mode);
    ST_LOGV("setScalingMode: mode=%d", mode);


    switch (mode) {
    switch (mode) {
@@ -628,6 +641,7 @@ status_t BufferQueue::setScalingMode(int mode) {


status_t BufferQueue::connect(int api,
status_t BufferQueue::connect(int api,
        uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
        uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
    ATRACE_CALL();
    ST_LOGV("connect: api=%d", api);
    ST_LOGV("connect: api=%d", api);
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


@@ -664,6 +678,7 @@ status_t BufferQueue::connect(int api,
}
}


status_t BufferQueue::disconnect(int api) {
status_t BufferQueue::disconnect(int api) {
    ATRACE_CALL();
    ST_LOGV("disconnect: api=%d", api);
    ST_LOGV("disconnect: api=%d", api);
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


@@ -818,6 +833,8 @@ status_t BufferQueue::acquire(BufferItem *buffer) {


        mSlots[buf].mBufferState = BufferSlot::ACQUIRED;
        mSlots[buf].mBufferState = BufferSlot::ACQUIRED;
        mQueue.erase(front);
        mQueue.erase(front);

        ATRACE_INT(mConsumerName.string(), mQueue.size());
    }
    }
    else {
    else {
        return -EINVAL; //should be a better return code
        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) {
status_t BufferQueue::setBufferCountServer(int bufferCount) {
    ATRACE_CALL();
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    return setBufferCountServerLocked(bufferCount);
    return setBufferCountServerLocked(bufferCount);
}
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
 */
 */


#define LOG_TAG "SurfaceTexture"
#define LOG_TAG "SurfaceTexture"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
//#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0


#define GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
@@ -36,6 +37,7 @@


#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/String8.h>
#include <utils/String8.h>
#include <utils/Trace.h>


// This compile option makes SurfaceTexture use the EGL_KHR_fence_sync extension
// This compile option makes SurfaceTexture use the EGL_KHR_fence_sync extension
// to synchronize access to the buffers.  It will cause dequeueBuffer to stall,
// 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() {
status_t SurfaceTexture::updateTexImage() {
    ATRACE_CALL();
    ST_LOGV("updateTexImage");
    ST_LOGV("updateTexImage");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


+14 −0
Original line number Original line Diff line number Diff line
@@ -15,9 +15,11 @@
 */
 */


#define LOG_TAG "SurfaceTextureClient"
#define LOG_TAG "SurfaceTextureClient"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
//#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0


#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/Trace.h>


#include <gui/ISurfaceComposer.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/SurfaceComposerClient.h>
@@ -121,6 +123,7 @@ int SurfaceTextureClient::hook_perform(ANativeWindow* window, int operation, ...
}
}


int SurfaceTextureClient::setSwapInterval(int interval) {
int SurfaceTextureClient::setSwapInterval(int interval) {
    ATRACE_CALL();
    // EGL specification states:
    // EGL specification states:
    //  interval is silently clamped to minimum and maximum implementation
    //  interval is silently clamped to minimum and maximum implementation
    //  dependent values before being stored.
    //  dependent values before being stored.
@@ -138,6 +141,7 @@ int SurfaceTextureClient::setSwapInterval(int interval) {
}
}


int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) {
int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) {
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::dequeueBuffer");
    ALOGV("SurfaceTextureClient::dequeueBuffer");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    int buf = -1;
    int buf = -1;
@@ -167,6 +171,7 @@ int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) {
}
}


int SurfaceTextureClient::cancelBuffer(android_native_buffer_t* buffer) {
int SurfaceTextureClient::cancelBuffer(android_native_buffer_t* buffer) {
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::cancelBuffer");
    ALOGV("SurfaceTextureClient::cancelBuffer");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    int i = getSlotFromBufferLocked(buffer);
    int i = getSlotFromBufferLocked(buffer);
@@ -213,6 +218,7 @@ int SurfaceTextureClient::lockBuffer(android_native_buffer_t* buffer) {
}
}


int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) {
int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) {
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::queueBuffer");
    ALOGV("SurfaceTextureClient::queueBuffer");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    int64_t timestamp;
    int64_t timestamp;
@@ -236,6 +242,7 @@ int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) {
}
}


int SurfaceTextureClient::query(int what, int* value) const {
int SurfaceTextureClient::query(int what, int* value) const {
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::query");
    ALOGV("SurfaceTextureClient::query");
    { // scope for the lock
    { // scope for the lock
        Mutex::Autolock lock(mMutex);
        Mutex::Autolock lock(mMutex);
@@ -404,6 +411,7 @@ int SurfaceTextureClient::dispatchUnlockAndPost(va_list args) {




int SurfaceTextureClient::connect(int api) {
int SurfaceTextureClient::connect(int api) {
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::connect");
    ALOGV("SurfaceTextureClient::connect");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    int err = mSurfaceTexture->connect(api,
    int err = mSurfaceTexture->connect(api,
@@ -415,6 +423,7 @@ int SurfaceTextureClient::connect(int api) {
}
}


int SurfaceTextureClient::disconnect(int api) {
int SurfaceTextureClient::disconnect(int api) {
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::disconnect");
    ALOGV("SurfaceTextureClient::disconnect");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    freeAllBuffers();
    freeAllBuffers();
@@ -441,6 +450,7 @@ int SurfaceTextureClient::setUsage(uint32_t reqUsage)


int SurfaceTextureClient::setCrop(Rect const* rect)
int SurfaceTextureClient::setCrop(Rect const* rect)
{
{
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::setCrop");
    ALOGV("SurfaceTextureClient::setCrop");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


@@ -459,6 +469,7 @@ int SurfaceTextureClient::setCrop(Rect const* rect)


int SurfaceTextureClient::setBufferCount(int bufferCount)
int SurfaceTextureClient::setBufferCount(int bufferCount)
{
{
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::setBufferCount");
    ALOGV("SurfaceTextureClient::setBufferCount");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


@@ -475,6 +486,7 @@ int SurfaceTextureClient::setBufferCount(int bufferCount)


int SurfaceTextureClient::setBuffersDimensions(int w, int h)
int SurfaceTextureClient::setBuffersDimensions(int w, int h)
{
{
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::setBuffersDimensions");
    ALOGV("SurfaceTextureClient::setBuffersDimensions");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);


@@ -508,6 +520,7 @@ int SurfaceTextureClient::setBuffersFormat(int format)


int SurfaceTextureClient::setScalingMode(int mode)
int SurfaceTextureClient::setScalingMode(int mode)
{
{
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::setScalingMode(%d)", mode);
    ALOGV("SurfaceTextureClient::setScalingMode(%d)", mode);
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    // mode is validated on the server
    // mode is validated on the server
@@ -520,6 +533,7 @@ int SurfaceTextureClient::setScalingMode(int mode)


int SurfaceTextureClient::setBuffersTransform(int transform)
int SurfaceTextureClient::setBuffersTransform(int transform)
{
{
    ATRACE_CALL();
    ALOGV("SurfaceTextureClient::setBuffersTransform");
    ALOGV("SurfaceTextureClient::setBuffersTransform");
    Mutex::Autolock lock(mMutex);
    Mutex::Autolock lock(mMutex);
    status_t err = mSurfaceTexture->setTransform(transform);
    status_t err = mSurfaceTexture->setTransform(transform);
+5 −0
Original line number Original line Diff line number Diff line
@@ -14,6 +14,8 @@
 ** limitations under the License.
 ** limitations under the License.
 */
 */


#define ATRACE_TAG ATRACE_TAG_GRAPHICS

#include <ctype.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
@@ -34,6 +36,7 @@
#include <utils/KeyedVector.h>
#include <utils/KeyedVector.h>
#include <utils/SortedVector.h>
#include <utils/SortedVector.h>
#include <utils/String8.h>
#include <utils/String8.h>
#include <utils/Trace.h>


#include "egl_impl.h"
#include "egl_impl.h"
#include "egl_tls.h"
#include "egl_tls.h"
@@ -348,6 +351,7 @@ EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface,
}
}


void EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) {
void EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) {
    ATRACE_CALL();
    clearError();
    clearError();


    egl_display_t const * const dp = validate_display(dpy);
    egl_display_t const * const dp = validate_display(dpy);
@@ -712,6 +716,7 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)


EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
{
{
    ATRACE_CALL();
    clearError();
    clearError();


    egl_display_t const * const dp = validate_display(dpy);
    egl_display_t const * const dp = validate_display(dpy);
+11 −0
Original line number Original line Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#define ATRACE_TAG ATRACE_TAG_GRAPHICS

#include <stdlib.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/types.h>
@@ -26,6 +28,7 @@
#include <utils/Errors.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/StopWatch.h>
#include <utils/StopWatch.h>
#include <utils/Trace.h>


#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
#include <ui/PixelFormat.h>
#include <ui/PixelFormat.h>
@@ -267,6 +270,8 @@ void Layer::setPerFrameData(hwc_layer_t* hwcl) {


void Layer::onDraw(const Region& clip) const
void Layer::onDraw(const Region& clip) const
{
{
    ATRACE_CALL();

    if (CC_UNLIKELY(mActiveBuffer == 0)) {
    if (CC_UNLIKELY(mActiveBuffer == 0)) {
        // the texture has not been created yet, this Layer has
        // the texture has not been created yet, this Layer has
        // in fact never been drawn into. This happens frequently with
        // 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)
uint32_t Layer::doTransaction(uint32_t flags)
{
{
    ATRACE_CALL();

    const Layer::State& front(drawingState());
    const Layer::State& front(drawingState());
    const Layer::State& temp(currentState());
    const Layer::State& temp(currentState());


@@ -418,6 +425,8 @@ bool Layer::onPreComposition() {


void Layer::lockPageFlip(bool& recomputeVisibleRegions)
void Layer::lockPageFlip(bool& recomputeVisibleRegions)
{
{
    ATRACE_CALL();

    if (mQueuedFrames > 0) {
    if (mQueuedFrames > 0) {


        // if we've already called updateTexImage() without going through
        // if we've already called updateTexImage() without going through
@@ -540,6 +549,8 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
void Layer::unlockPageFlip(
void Layer::unlockPageFlip(
        const Transform& planeTransform, Region& outDirtyRegion)
        const Transform& planeTransform, Region& outDirtyRegion)
{
{
    ATRACE_CALL();

    Region postedRegion(mPostedDirtyRegion);
    Region postedRegion(mPostedDirtyRegion);
    if (!postedRegion.isEmpty()) {
    if (!postedRegion.isEmpty()) {
        mPostedDirtyRegion.clear();
        mPostedDirtyRegion.clear();
Loading