reduce IPC with BufferQueue

collapse setCrop, setTransform and setScalingMode to queueBuffer()
this ends up simplifying things quite a bit and reducing the numnber
of IPC needed per frame.

Change-Id: I3a13c07603abe4e76b8251e6380b107fde22e6d9
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index 99776b5..a808216 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -128,11 +128,9 @@
     // (zero point, etc) are client-dependent and should be documented by the
     // client.
     virtual status_t queueBuffer(int buf, int64_t timestamp,
+            const Rect& crop, int scalingMode, uint32_t transform,
             uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform);
     virtual void cancelBuffer(int buf);
-    virtual status_t setCrop(const Rect& reg);
-    virtual status_t setTransform(uint32_t transform);
-    virtual status_t setScalingMode(int mode);
 
     // setSynchronousMode set whether dequeueBuffer is synchronous or
     // asynchronous. In synchronous mode, dequeueBuffer blocks until
@@ -180,18 +178,13 @@
         // if no buffer has been allocated.
         sp<GraphicBuffer> mGraphicBuffer;
 
-        // mCrop is the current crop rectangle for this buffer slot. This gets
-        // set to mNextCrop each time queueBuffer gets called for this buffer.
+        // mCrop is the current crop rectangle for this buffer slot.
         Rect mCrop;
 
-        // mTransform is the current transform flags for this buffer slot. This
-        // gets set to mNextTransform each time queueBuffer gets called for this
-        // slot.
+        // mTransform is the current transform flags for this buffer slot.
         uint32_t mTransform;
 
-        // mScalingMode is the current scaling mode for this buffer slot. This
-        // gets set to mNextScalingMode each time queueBuffer gets called for
-        // this slot.
+        // mScalingMode is the current scaling mode for this buffer slot.
         uint32_t mScalingMode;
 
         // mTimestamp is the current timestamp for this buffer slot. This gets
@@ -359,18 +352,13 @@
         // needed but useful for debugging and catching client bugs.
         bool mRequestBufferCalled;
 
-        // mCrop is the current crop rectangle for this buffer slot. This gets
-        // set to mNextCrop each time queueBuffer gets called for this buffer.
+        // mCrop is the current crop rectangle for this buffer slot.
         Rect mCrop;
 
-        // mTransform is the current transform flags for this buffer slot. This
-        // gets set to mNextTransform each time queueBuffer gets called for this
-        // slot.
+        // mTransform is the current transform flags for this buffer slot.
         uint32_t mTransform;
 
-        // mScalingMode is the current scaling mode for this buffer slot. This
-        // gets set to mNextScalingMode each time queueBuffer gets called for
-        // this slot.
+        // mScalingMode is the current scaling mode for this buffer slot.
         uint32_t mScalingMode;
 
         // mTimestamp is the current timestamp for this buffer slot. This gets
@@ -422,18 +410,6 @@
     // mServerBufferCount buffer count requested by the server-side
     int mServerBufferCount;
 
-    // mNextCrop is the crop rectangle that will be used for the next buffer
-    // that gets queued. It is set by calling setCrop.
-    Rect mNextCrop;
-
-    // mNextTransform is the transform identifier that will be used for the next
-    // buffer that gets queued. It is set by calling setTransform.
-    uint32_t mNextTransform;
-
-    // mNextScalingMode is the scaling mode that will be used for the next
-    // buffers that get queued. It is set by calling setScalingMode.
-    int mNextScalingMode;
-
     // mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to
     // allocate new GraphicBuffer objects.
     sp<IGraphicBufferAlloc> mGraphicBufferAlloc;
diff --git a/include/gui/ISurfaceTexture.h b/include/gui/ISurfaceTexture.h
index 50626a0..b31fdaf 100644
--- a/include/gui/ISurfaceTexture.h
+++ b/include/gui/ISurfaceTexture.h
@@ -83,6 +83,7 @@
     // and height of the window and current transform applied to buffers,
     // respectively.
     virtual status_t queueBuffer(int slot, int64_t timestamp,
+            const Rect& crop, int scalingMode, uint32_t transform,
             uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) = 0;
 
     // cancelBuffer indicates that the client does not wish to fill in the
@@ -90,10 +91,6 @@
     // the server.
     virtual void cancelBuffer(int slot) = 0;
 
-    virtual status_t setCrop(const Rect& reg) = 0;
-    virtual status_t setTransform(uint32_t transform) = 0;
-    virtual status_t setScalingMode(int mode) = 0;
-
     // query retrieves some information for this surface
     // 'what' tokens allowed are that of android_natives.h
     virtual int query(int what, int* value) = 0;
diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h
index f86e8fd..b68fa81 100644
--- a/include/gui/SurfaceTextureClient.h
+++ b/include/gui/SurfaceTextureClient.h
@@ -129,8 +129,8 @@
     // operation. It is initialized to 1.
     uint32_t mReqWidth;
 
-    // mReqHeight is the buffer height that will be requested at the next deuque
-    // operation. It is initialized to 1.
+    // mReqHeight is the buffer height that will be requested at the next
+    // dequeue operation. It is initialized to 1.
     uint32_t mReqHeight;
 
     // mReqFormat is the buffer pixel format that will be requested at the next
@@ -146,6 +146,18 @@
     // a timestamp is auto-generated when queueBuffer is called.
     int64_t mTimestamp;
 
+    // mCrop is the crop rectangle that will be used for the next buffer
+    // that gets queued. It is set by calling setCrop.
+    Rect mCrop;
+
+    // mScalingMode is the scaling mode that will be used for the next
+    // buffers that get queued. It is set by calling setScalingMode.
+    int mScalingMode;
+
+    // mTransform is the transform identifier that will be used for the next
+    // buffer that gets queued. It is set by calling setTransform.
+    uint32_t mTransform;
+
     // mDefaultWidth is default width of the window, regardless of the
     // native_window_set_buffers_dimensions call
     uint32_t mDefaultWidth;