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

Commit 959d007a authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "Add logging of various important graphics events" into gingerbread

parents 651a0519 35b48d10
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ public:
    status_t setUpdateRectangle(const Rect& updateRect);
    status_t compositionComplete();
    
    // for debugging only
    int getCurrentBufferIndex() const;

private:
    friend class LightRefBase<FramebufferNativeWindow>;    
    ~FramebufferNativeWindow(); // this class cannot be overloaded
@@ -77,6 +80,7 @@ private:
    int32_t mNumBuffers;
    int32_t mNumFreeBuffers;
    int32_t mBufferHead;
    int32_t mCurrentBufferIndex;
    bool mUpdateOnDemand;
};
    
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _UI_GRAPHIC_LOG_H
#define _UI_GRAPHIC_LOG_H

#include <utils/Singleton.h>
#include <cutils/compiler.h>

namespace android {

class GraphicLog : public Singleton<GraphicLog>
{
    int32_t mEnabled;
    static void logImpl(int32_t tag, int32_t buffer);
    static void logImpl(int32_t tag, int32_t identity, int32_t buffer);

public:
    enum {
        SF_APP_DEQUEUE_BEFORE   = 60000,
        SF_APP_DEQUEUE_AFTER    = 60001,
        SF_APP_LOCK_BEFORE      = 60002,
        SF_APP_LOCK_AFTER       = 60003,
        SF_APP_QUEUE            = 60004,

        SF_REPAINT              = 60005,
        SF_COMPOSITION_COMPLETE = 60006,
        SF_UNLOCK_CLIENTS       = 60007,
        SF_SWAP_BUFFERS         = 60008,
        SF_REPAINT_DONE         = 60009,

        SF_FB_POST_BEFORE       = 60010,
        SF_FB_POST_AFTER        = 60011,
        SF_FB_DEQUEUE_BEFORE    = 60012,
        SF_FB_DEQUEUE_AFTER     = 60013,
        SF_FB_LOCK_BEFORE       = 60014,
        SF_FB_LOCK_AFTER        = 60015,
    };

    inline void log(int32_t tag, int32_t buffer) {
        if (CC_UNLIKELY(mEnabled))
            logImpl(tag, buffer);
    }
    inline void log(int32_t tag, int32_t identity, int32_t buffer) {
        if (CC_UNLIKELY(mEnabled))
            logImpl(tag, identity, buffer);
    }

    GraphicLog();

    void setEnabled(bool enable);
};

}

#endif // _UI_GRAPHIC_LOG_H
+18 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <ui/DisplayInfo.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBufferMapper.h>
#include <ui/GraphicLog.h>
#include <ui/Rect.h>

#include <surfaceflinger/Surface.h>
@@ -568,7 +569,13 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer)
    if (err != NO_ERROR)
        return err;

    GraphicLog& logger(GraphicLog::getInstance());
    logger.log(GraphicLog::SF_APP_DEQUEUE_BEFORE, mIdentity, -1);

    ssize_t bufIdx = mSharedBufferClient->dequeue();

    logger.log(GraphicLog::SF_APP_DEQUEUE_AFTER, mIdentity, bufIdx);

    if (bufIdx < 0) {
        LOGE("error dequeuing a buffer (%s)", strerror(bufIdx));
        return bufIdx;
@@ -617,7 +624,14 @@ int Surface::lockBuffer(android_native_buffer_t* buffer)
        return err;

    int32_t bufIdx = getBufferIndex(GraphicBuffer::getSelf(buffer));

    GraphicLog& logger(GraphicLog::getInstance());
    logger.log(GraphicLog::SF_APP_LOCK_BEFORE, mIdentity, bufIdx);

    err = mSharedBufferClient->lock(bufIdx);

    logger.log(GraphicLog::SF_APP_LOCK_AFTER, mIdentity, bufIdx);

    LOGE_IF(err, "error locking buffer %d (%s)", bufIdx, strerror(-err));
    return err;
}
@@ -633,6 +647,9 @@ int Surface::queueBuffer(android_native_buffer_t* buffer)
    }
    
    int32_t bufIdx = getBufferIndex(GraphicBuffer::getSelf(buffer));

    GraphicLog::getInstance().log(GraphicLog::SF_APP_QUEUE, mIdentity, bufIdx);

    mSharedBufferClient->setTransform(bufIdx, mNextBufferTransform);
    mSharedBufferClient->setCrop(bufIdx, mNextBufferCrop);
    mSharedBufferClient->setDirtyRegion(bufIdx, mDirtyRegion);
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ LOCAL_SRC_FILES:= \
	GraphicBuffer.cpp \
	GraphicBufferAllocator.cpp \
	GraphicBufferMapper.cpp \
	GraphicLog.cpp \
	KeyLayoutMap.cpp \
	KeyCharacterMap.cpp \
	Input.cpp \
+32 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

#include <ui/Rect.h>
#include <ui/FramebufferNativeWindow.h>
#include <ui/GraphicLog.h>

#include <EGL/egl.h>

@@ -174,6 +175,14 @@ int FramebufferNativeWindow::setSwapInterval(
    return fb->setSwapInterval(fb, interval);
}

// only for debugging / logging
int FramebufferNativeWindow::getCurrentBufferIndex() const
{
    Mutex::Autolock _l(mutex);
    const int index = mCurrentBufferIndex;
    return index;
}

int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, 
        android_native_buffer_t** buffer)
{
@@ -181,18 +190,24 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
    Mutex::Autolock _l(self->mutex);
    framebuffer_device_t* fb = self->fbDev;

    int index = self->mBufferHead++;
    if (self->mBufferHead >= self->mNumBuffers)
        self->mBufferHead = 0;

    GraphicLog& logger(GraphicLog::getInstance());
    logger.log(GraphicLog::SF_FB_DEQUEUE_BEFORE, index);

    // wait for a free buffer
    while (!self->mNumFreeBuffers) {
        self->mCondition.wait(self->mutex);
    }
    // get this buffer
    self->mNumFreeBuffers--;
    int index = self->mBufferHead++;
    if (self->mBufferHead >= self->mNumBuffers)
        self->mBufferHead = 0;
    self->mCurrentBufferIndex = index;

    *buffer = self->buffers[index].get();

    logger.log(GraphicLog::SF_FB_DEQUEUE_AFTER, index);
    return 0;
}

@@ -202,11 +217,17 @@ int FramebufferNativeWindow::lockBuffer(ANativeWindow* window,
    FramebufferNativeWindow* self = getSelf(window);
    Mutex::Autolock _l(self->mutex);

    const int index = self->mCurrentBufferIndex;
    GraphicLog& logger(GraphicLog::getInstance());
    logger.log(GraphicLog::SF_FB_LOCK_BEFORE, index);

    // wait that the buffer we're locking is not front anymore
    while (self->front == buffer) {
        self->mCondition.wait(self->mutex);
    }

    logger.log(GraphicLog::SF_FB_LOCK_AFTER, index);

    return NO_ERROR;
}

@@ -217,7 +238,15 @@ int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
    Mutex::Autolock _l(self->mutex);
    framebuffer_device_t* fb = self->fbDev;
    buffer_handle_t handle = static_cast<NativeBuffer*>(buffer)->handle;

    const int index = self->mCurrentBufferIndex;
    GraphicLog& logger(GraphicLog::getInstance());
    logger.log(GraphicLog::SF_FB_POST_BEFORE, index);

    int res = fb->post(fb, handle);

    logger.log(GraphicLog::SF_FB_POST_AFTER, index);

    self->front = static_cast<NativeBuffer*>(buffer);
    self->mNumFreeBuffers++;
    self->mCondition.broadcast();
Loading