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

Commit c479e18d authored by Mathias Agopian's avatar Mathias Agopian
Browse files

resolved conflicts for merge of 48a86240 to master

Change-Id: I2305fef9f4dd46183337217d822df3c675b6b6e5
parents ee6d0ecd 5e4cf02d
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -56,6 +56,9 @@ public:
    status_t setUpdateRectangle(const Rect& updateRect);
    status_t setUpdateRectangle(const Rect& updateRect);
    status_t compositionComplete();
    status_t compositionComplete();
    
    
    // for debugging only
    int getCurrentBufferIndex() const;

private:
private:
    friend class LightRefBase<FramebufferNativeWindow>;    
    friend class LightRefBase<FramebufferNativeWindow>;    
    ~FramebufferNativeWindow(); // this class cannot be overloaded
    ~FramebufferNativeWindow(); // this class cannot be overloaded
@@ -77,6 +80,7 @@ private:
    int32_t mNumBuffers;
    int32_t mNumBuffers;
    int32_t mNumFreeBuffers;
    int32_t mNumFreeBuffers;
    int32_t mBufferHead;
    int32_t mBufferHead;
    int32_t mCurrentBufferIndex;
    bool mUpdateOnDemand;
    bool mUpdateOnDemand;
};
};
    
    
+70 −0
Original line number Original line 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 Original line Diff line number Diff line
@@ -32,6 +32,7 @@
#include <ui/DisplayInfo.h>
#include <ui/DisplayInfo.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBufferMapper.h>
#include <ui/GraphicBufferMapper.h>
#include <ui/GraphicLog.h>
#include <ui/Rect.h>
#include <ui/Rect.h>


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


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

    ssize_t bufIdx = mSharedBufferClient->dequeue();
    ssize_t bufIdx = mSharedBufferClient->dequeue();

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

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


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

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

    err = mSharedBufferClient->lock(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));
    LOGE_IF(err, "error locking buffer %d (%s)", bufIdx, strerror(-err));
    return err;
    return err;
}
}
@@ -643,6 +657,9 @@ int Surface::queueBuffer(android_native_buffer_t* buffer)
    }
    }
    
    
    int32_t bufIdx = getBufferIndex(GraphicBuffer::getSelf(buffer));
    int32_t bufIdx = getBufferIndex(GraphicBuffer::getSelf(buffer));

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

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


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


#include <EGL/egl.h>
#include <EGL/egl.h>


@@ -174,6 +175,14 @@ int FramebufferNativeWindow::setSwapInterval(
    return fb->setSwapInterval(fb, interval);
    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, 
int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window, 
        android_native_buffer_t** buffer)
        android_native_buffer_t** buffer)
{
{
@@ -181,18 +190,24 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
    Mutex::Autolock _l(self->mutex);
    Mutex::Autolock _l(self->mutex);
    framebuffer_device_t* fb = self->fbDev;
    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
    // wait for a free buffer
    while (!self->mNumFreeBuffers) {
    while (!self->mNumFreeBuffers) {
        self->mCondition.wait(self->mutex);
        self->mCondition.wait(self->mutex);
    }
    }
    // get this buffer
    // get this buffer
    self->mNumFreeBuffers--;
    self->mNumFreeBuffers--;
    int index = self->mBufferHead++;
    self->mCurrentBufferIndex = index;
    if (self->mBufferHead >= self->mNumBuffers)
        self->mBufferHead = 0;


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


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


@@ -202,11 +217,17 @@ int FramebufferNativeWindow::lockBuffer(ANativeWindow* window,
    FramebufferNativeWindow* self = getSelf(window);
    FramebufferNativeWindow* self = getSelf(window);
    Mutex::Autolock _l(self->mutex);
    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
    // wait that the buffer we're locking is not front anymore
    while (self->front == buffer) {
    while (self->front == buffer) {
        self->mCondition.wait(self->mutex);
        self->mCondition.wait(self->mutex);
    }
    }


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

    return NO_ERROR;
    return NO_ERROR;
}
}


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

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

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