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
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index ec6da43..a46a190 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -97,20 +97,16 @@
     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<GraphicBuffer>& 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;