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

Commit 41edafd7 authored by Naomi Luis's avatar Naomi Luis Committed by Giulio Cervera
Browse files

SurfaceFlinger: Set the buffer size in the GraphicBufferAlloc

When setting the buffer size, store the required size, and allocate
the buffer of the required size in GraphicBufferAlloc, instead of
SurfaceTexture. We do this because SurfaceTexture does not always
run in the server process space. GraphicBufferAlloc always runs in the
server process.
parent 81b18090
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -513,9 +513,6 @@ private:
    uint64_t mFrameCounter;

#ifdef QCOM_HARDWARE
    // mReqSize is the required buffer size speficied by the client.
    int mReqSize;

    struct BufferInfo {
         int width;
         int height;
+3 −0
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ public:

    /* Free the GraphicBuffer at the specified index */
    virtual void freeGraphicBufferAtIndex(int bufIndex) = 0;

    /* Sets the required size of the Graphic Buffers */
    virtual void setGraphicBufferSize(int size) = 0;
#endif
};

+15 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ enum {
#ifdef QCOM_HARDWARE
    FREE_ALL_GRAPHIC_BUFFERS_EXCEPT,
    FREE_GRAPHIC_BUFFER_AT_INDEX,
    SET_GRAPHIC_BUFFER_SIZE,
#endif
};

@@ -84,6 +85,14 @@ public:
        data.writeInt32(bufIdx);
        remote()->transact(FREE_GRAPHIC_BUFFER_AT_INDEX, data, &reply);
    }

    virtual void setGraphicBufferSize(int size) {
        Parcel data, reply;
        data.writeInterfaceToken(
                IGraphicBufferAlloc::getInterfaceDescriptor());
        data.writeInt32(size);
        remote()->transact(SET_GRAPHIC_BUFFER_SIZE, data, &reply);
    }
#endif
};

@@ -143,6 +152,12 @@ status_t BnGraphicBufferAlloc::onTransact(
            freeGraphicBufferAtIndex(bufIdx);
            return NO_ERROR;
        } break;
        case SET_GRAPHIC_BUFFER_SIZE: {
            CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
            int size = data.readInt32();
            setGraphicBufferSize(size);
            return NO_ERROR;
        } break;
#endif
        default:
            return BBinder::onTransact(code, data, reply, flags);
+10 −14
Original line number Diff line number Diff line
@@ -142,9 +142,6 @@ SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode,
    mUseFenceSync(false),
#endif
    mTexTarget(texTarget),
#ifdef QCOM_HARDWARE
    mReqSize(0),
#endif
    mFrameCounter(0) {
    // Choose a name using the PID and a process-unique ID.
    mName = String8::format("unnamed-%d-%d", getpid(), createProcessUniqueId());
@@ -524,9 +521,7 @@ status_t SurfaceTexture::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
            if (updateFormat) {
                mPixelFormat = format;
            }
#ifdef QCOM_HARDWARE
	    checkBuffer((native_handle_t *)graphicBuffer->handle, mReqSize, usage);
#endif

            mSlots[buf].mGraphicBuffer = graphicBuffer;
            mSlots[buf].mRequestBufferCalled = false;
            mSlots[buf].mFence = EGL_NO_SYNC_KHR;
@@ -807,14 +802,15 @@ status_t SurfaceTexture::performQcomOperation(int operation, int arg1, int arg2,
    ST_LOGV("SurfaceTexture::performQcomOperation operation=%d", operation);

    switch(operation) {
        case NATIVE_WINDOW_SET_BUFFERS_SIZE:
            mReqSize = arg1;
            break;
        case NATIVE_WINDOW_UPDATE_BUFFERS_GEOMETRY:
        case NATIVE_WINDOW_SET_BUFFERS_SIZE: {
            int size = arg1;
            mGraphicBufferAlloc->setGraphicBufferSize(size);
        } break;
        case NATIVE_WINDOW_UPDATE_BUFFERS_GEOMETRY: {
            mNextBufferInfo.width = arg1;
            mNextBufferInfo.height = arg2;
            mNextBufferInfo.format = arg3;
            break;
        } break;
        default: return BAD_VALUE;
     };
     return OK;
+6 −0
Original line number Diff line number Diff line
@@ -2719,6 +2719,7 @@ status_t Client::destroySurface(SurfaceID sid) {
#ifdef QCOM_HARDWARE
GraphicBufferAlloc::GraphicBufferAlloc() {
    mFreedIndex = -1;
    mSize = 0;
}
#else
GraphicBufferAlloc::GraphicBufferAlloc() {}
@@ -2741,6 +2742,7 @@ sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h
        return 0;
    }
#ifdef QCOM_HARDWARE
    checkBuffer((native_handle_t *)graphicBuffer->handle, mSize, usage);
    Mutex::Autolock _l(mLock);
    if (-1 != mFreedIndex) {
        mBuffers.insertAt(graphicBuffer, mFreedIndex);
@@ -2774,6 +2776,10 @@ void GraphicBufferAlloc::freeGraphicBufferAtIndex(int bufIdx) {
        mFreedIndex = -1;
     }
}

void GraphicBufferAlloc::setGraphicBufferSize(int size) {
    mSize = size;
}
#endif
// ---------------------------------------------------------------------------

Loading