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

Commit 8e3e92b9 authored by Pablo Ceballos's avatar Pablo Ceballos
Browse files

BQ: Add and expose a unique id

Bug 29422927

Change-Id: I80eab94f073ebc378302f00fa86a740c3643657e
parent ced6078b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -322,6 +322,8 @@ private:
    // The slot of the last queued buffer
    int mLastQueuedSlot;

    const uint64_t mUniqueId;

}; // class BufferQueueCore

} // namespace android
+3 −0
Original line number Diff line number Diff line
@@ -186,6 +186,9 @@ public:
    virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
            sp<Fence>* outFence, float outTransformMatrix[16]) override;

    // See IGraphicBufferProducer::getUniqueId
    virtual status_t getUniqueId(uint64_t* outId) const override;

private:
    // This is required by the IBinder::DeathRecipient interface
    virtual void binderDied(const wp<IBinder>& who);
+3 −0
Original line number Diff line number Diff line
@@ -568,6 +568,9 @@ public:
    // Returns NO_ERROR or the status of the Binder transaction
    virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
            sp<Fence>* outFence, float outTransformMatrix[16]) = 0;

    // Returns a unique id for this BufferQueue
    virtual status_t getUniqueId(uint64_t* outId) const = 0;
};

// ----------------------------------------------------------------------------
+2 −0
Original line number Diff line number Diff line
@@ -134,6 +134,8 @@ public:
    status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer,
            sp<Fence>* outFence, float outTransformMatrix[16]);

    status_t getUniqueId(uint64_t* outId) const;

protected:
    virtual ~Surface();

+8 −1
Original line number Diff line number Diff line
@@ -44,6 +44,12 @@ static String8 getUniqueName() {
            android_atomic_inc(&counter));
}

static uint64_t getUniqueId() {
    static std::atomic<uint32_t> counter{0};
    static uint64_t id = static_cast<uint64_t>(getpid()) << 32;
    return id | counter++;
}

BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
    mAllocator(allocator),
    mMutex(),
@@ -82,7 +88,8 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
    mAutoRefresh(false),
    mSharedBufferSlot(INVALID_BUFFER_SLOT),
    mSharedBufferCache(Rect::INVALID_RECT, 0, NATIVE_WINDOW_SCALING_MODE_FREEZE,
            HAL_DATASPACE_UNKNOWN)
            HAL_DATASPACE_UNKNOWN),
    mUniqueId(getUniqueId())
{
    if (allocator == NULL) {
        sp<ISurfaceComposer> composer(ComposerService::getComposerService());
Loading