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

Commit ea52d7e0 authored by Naomi Luis's avatar Naomi Luis Committed by toastcfh
Browse files

SurfaceTexture: Add support to update the buffer geometry

Add support to allow the buffer geometry to be updated without allocating
new memory. Clients invoke the NATIVE_WINDOW_SET_BUFFERS_GEOMETRY api with
the new width, height and format. These updated parameters take effect on
the next queued buffer.
Change-Id: I39fcd864949811131eb480a22823cfca4e93b9cd
parent 56dd352c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -515,6 +515,14 @@ private:
#ifdef QCOM_HARDWARE
    // mReqSize is the required buffer size speficied by the client.
    int mReqSize;

    struct BufferInfo {
         int width;
         int height;
         int format;
     };
 
     BufferInfo mNextBufferInfo;
#endif

};
+42 −6
Original line number Diff line number Diff line
@@ -155,6 +155,11 @@ SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode,
    mNextCrop.makeInvalid();
    memcpy(mCurrentTransformMatrix, mtxIdentity,
            sizeof(mCurrentTransformMatrix));
#ifdef QCOM_HARDWARE
    mNextBufferInfo.width = 0;
    mNextBufferInfo.height = 0;
    mNextBufferInfo.format = 0;
#endif
}

SurfaceTexture::~SurfaceTexture() {
@@ -477,10 +482,28 @@ status_t SurfaceTexture::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
        mSlots[buf].mBufferState = BufferSlot::DEQUEUED;

        const sp<GraphicBuffer>& buffer(mSlots[buf].mGraphicBuffer);
#ifdef QCOM_HARDWARE
	qBufGeometry currentGeometry;
	if (buffer != NULL)
	   currentGeometry.set(buffer->width, buffer->height, buffer->format);
 	else
	   currentGeometry.set(0, 0, 0);
 
	qBufGeometry requiredGeometry;
	requiredGeometry.set(w, h, format);
 
	qBufGeometry updatedGeometry;
	updatedGeometry.set(mNextBufferInfo.width, mNextBufferInfo.height,
				mNextBufferInfo.format);
#endif
	if ((buffer == NULL) ||
#ifdef QCOM_HARDWARE
	   needNewBuffer(currentGeometry, requiredGeometry, updatedGeometry) ||
#else
	   (uint32_t(buffer->width)  != w) ||
	   (uint32_t(buffer->height) != h) ||
	   (uint32_t(buffer->format) != format) ||
#endif
	   ((uint32_t(buffer->usage) & usage) != usage))
	{
            usage |= GraphicBuffer::USAGE_HW_TEXTURE;
@@ -633,6 +656,14 @@ status_t SurfaceTexture::queueBuffer(int buf, int64_t timestamp,
        mFrameCounter++;
        mSlots[buf].mFrameNumber = mFrameCounter;

#ifdef QCOM_HARDWARE
	// Update the buffer Geometry if required
	qBufGeometry updatedGeometry;
	updatedGeometry.set(mNextBufferInfo.width,
				mNextBufferInfo.height, mNextBufferInfo.format);
	updateBufferGeometry(mSlots[buf].mGraphicBuffer, updatedGeometry);
	sp<GraphicBuffer> buffer = mSlots[buf].mGraphicBuffer;
#endif
        mDequeueCondition.signal();

        *outWidth = mDefaultWidth;
@@ -775,6 +806,11 @@ status_t SurfaceTexture::performQcomOperation(int operation, int arg1, int arg2,
	case NATIVE_WINDOW_SET_BUFFERS_SIZE:
	    mReqSize = arg1;
	    break;
	case NATIVE_WINDOW_UPDATE_BUFFERS_GEOMETRY:
            mNextBufferInfo.width = arg1;
            mNextBufferInfo.height = arg2;
            mNextBufferInfo.format = arg3;
            break;
#endif
        default: return BAD_VALUE;
     };