From c04f153353cdb0d291297d10452239f791d3fd2b Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 25 Apr 2011 20:22:14 -0700 Subject: Fix a bug where setgeometry couldn't be undone This change the binder protocol between SurfaceTextureClient and SurfaceTexture. dequeueBuffer() now takes the requested parameters for the buffer. SurfaceTexture decides if the buffer needs to be reallocated and does the allocation if needed. In that case it returns BUFFER_NEEDS_REALLOCATION to tell SurfaceTextureClient that it needs to call requestBuffer (which all parameters have been removed) to acquire a pointer to the buffer. dequeueBuffer and requestBuffer could be folded into a single IPC call, but we chose to optimize the case where buffers are not created and avoid some complexity in the marshalling code. Change-Id: I097a7f6f40a3491e10f3f3742eab33999286c304 --- libs/gui/SurfaceTextureClient.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'libs/gui/SurfaceTextureClient.cpp') diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index ec6da4324d..a46a1901ec 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -97,20 +97,16 @@ int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) { LOGV("SurfaceTextureClient::dequeueBuffer"); Mutex::Autolock lock(mMutex); int buf = -1; - status_t err = mSurfaceTexture->dequeueBuffer(&buf); + status_t err = mSurfaceTexture->dequeueBuffer(&buf, mReqWidth, mReqHeight, + mReqFormat, mReqUsage); if (err < 0) { - LOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer failed: %d", err); + LOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer(%d, %d, %d, %d)" + "failed: %d", err, mReqWidth, mReqHeight, mReqFormat, mReqUsage); return err; } sp& gbuf(mSlots[buf]); - if (err == ISurfaceTexture::BUFFER_NEEDS_REALLOCATION || - gbuf == 0 || - (mReqWidth && gbuf->getWidth() != mReqWidth) || - (mReqHeight && gbuf->getHeight() != mReqHeight) || - (mReqFormat && uint32_t(gbuf->getPixelFormat()) != mReqFormat) || - (gbuf->getUsage() & mReqUsage) != mReqUsage) { - gbuf = mSurfaceTexture->requestBuffer(buf, mReqWidth, mReqHeight, - mReqFormat, mReqUsage); + if (err == ISurfaceTexture::BUFFER_NEEDS_REALLOCATION || gbuf == 0) { + gbuf = mSurfaceTexture->requestBuffer(buf); if (gbuf == 0) { LOGE("dequeueBuffer: ISurfaceTexture::requestBuffer failed"); return NO_MEMORY; -- cgit v1.2.3-59-g8ed1b