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

Commit b856052c authored by Daniel Lam's avatar Daniel Lam
Browse files

Refactored query function from SurfaceTexture into BufferQueue

Change-Id: Id1cb6cc38d01edb4fcfcad867c5a7693bdcc3ab1
parent 9e4b8948
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ public:
    BufferQueue(bool allowSynchronousMode = true);
    virtual ~BufferQueue();

    virtual int query(int what, int* value);

    // setBufferCount updates the number of available buffer slots.  After
    // calling this all buffer slots are both unallocated and owned by the
    // BufferQueue object (i.e. they are not owned by the client).
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public:

    virtual ~SurfaceTexture();

    virtual int query(int what, int* value);


    // updateTexImage sets the image contents of the target texture to that of
    // the most recently queued buffer.
+31 −0
Original line number Diff line number Diff line
@@ -166,6 +166,37 @@ status_t BufferQueue::setBufferCount(int bufferCount) {
    return OK;
}

int BufferQueue::query(int what, int* outValue)
{
    Mutex::Autolock lock(mMutex);

    if (mAbandoned) {
        ST_LOGE("query: SurfaceTexture has been abandoned!");
        return NO_INIT;
    }

    int value;
    switch (what) {
    case NATIVE_WINDOW_WIDTH:
        value = mDefaultWidth;
        break;
    case NATIVE_WINDOW_HEIGHT:
        value = mDefaultHeight;
        break;
    case NATIVE_WINDOW_FORMAT:
        value = mPixelFormat;
        break;
    case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
        value = mSynchronousMode ?
                (MIN_UNDEQUEUED_BUFFERS-1) : MIN_UNDEQUEUED_BUFFERS;
        break;
    default:
        return BAD_VALUE;
    }
    outValue[0] = value;
    return NO_ERROR;
}

status_t BufferQueue::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
    ST_LOGV("requestBuffer: slot=%d", slot);
    Mutex::Autolock lock(mMutex);
+0 −29
Original line number Diff line number Diff line
@@ -416,36 +416,7 @@ bool SurfaceTexture::isSynchronousMode() const {
    return mSynchronousMode;
}

int SurfaceTexture::query(int what, int* outValue)
{
    Mutex::Autolock lock(mMutex);

    if (mAbandoned) {
        ST_LOGE("query: SurfaceTexture has been abandoned!");
        return NO_INIT;
    }

    int value;
    switch (what) {
    case NATIVE_WINDOW_WIDTH:
        value = mDefaultWidth;
        break;
    case NATIVE_WINDOW_HEIGHT:
        value = mDefaultHeight;
        break;
    case NATIVE_WINDOW_FORMAT:
        value = mPixelFormat;
        break;
    case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
        value = mSynchronousMode ?
                (MIN_UNDEQUEUED_BUFFERS-1) : MIN_UNDEQUEUED_BUFFERS;
        break;
    default:
        return BAD_VALUE;
    }
    outValue[0] = value;
    return NO_ERROR;
}

void SurfaceTexture::abandon() {
    Mutex::Autolock lock(mMutex);