Pass in format when creating and updating BBQ.

Pixel format should be passed in when creating or updating BBQ since the
format is set on the consumer.

Test: go/wm-smoke
Bug: 177557720
Change-Id: Ib9137eb83d4014d98e9022527d21ad67765caad0
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index f4b5a26..0a3d44d 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -117,11 +117,13 @@
 }
 
 BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceControl>& surface,
-                                   int width, int height, bool enableTripleBuffering)
+                                   int width, int height, int32_t format,
+                                   bool enableTripleBuffering)
       : mName(name),
         mSurfaceControl(surface),
         mSize(width, height),
         mRequestedSize(mSize),
+        mFormat(format),
         mNextTransaction(nullptr) {
     createBufferQueue(&mProducer, &mConsumer);
     // since the adapter is in the client process, set dequeue timeout
@@ -140,7 +142,7 @@
     mBufferItemConsumer->setFrameAvailableListener(this);
     mBufferItemConsumer->setBufferFreedListener(this);
     mBufferItemConsumer->setDefaultBufferSize(mSize.width, mSize.height);
-    mBufferItemConsumer->setDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888);
+    mBufferItemConsumer->setDefaultBufferFormat(format);
 
     mTransformHint = mSurfaceControl->getTransformHint();
     mBufferItemConsumer->setTransformHint(mTransformHint);
@@ -164,10 +166,16 @@
     t.apply();
 }
 
-void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height) {
+void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height,
+                              int32_t format) {
     std::unique_lock _lock{mMutex};
     mSurfaceControl = surface;
 
+    if (mFormat != format) {
+        mFormat = format;
+        mBufferItemConsumer->setDefaultBufferFormat(format);
+    }
+
     ui::Size newSize(width, height);
     if (mRequestedSize != newSize) {
         mRequestedSize.set(newSize);