diff options
| -rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 14 | ||||
| -rw-r--r-- | libs/gui/include/gui/BLASTBufferQueue.h | 5 | ||||
| -rw-r--r-- | libs/gui/tests/BLASTBufferQueue_test.cpp | 5 |
3 files changed, 17 insertions, 7 deletions
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index f4b5a26033..0a3d44d336 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -117,11 +117,13 @@ void BLASTBufferItemConsumer::getConnectionEvents(uint64_t frameNumber, bool* ne } 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 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceCont 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 @@ BLASTBufferQueue::~BLASTBufferQueue() { 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); diff --git a/libs/gui/include/gui/BLASTBufferQueue.h b/libs/gui/include/gui/BLASTBufferQueue.h index 0fbcbdc50f..411526eeb3 100644 --- a/libs/gui/include/gui/BLASTBufferQueue.h +++ b/libs/gui/include/gui/BLASTBufferQueue.h @@ -68,7 +68,7 @@ class BLASTBufferQueue { public: BLASTBufferQueue(const std::string& name, const sp<SurfaceControl>& surface, int width, - int height, bool enableTripleBuffering = true); + int height, int32_t format, bool enableTripleBuffering = true); sp<IGraphicBufferProducer> getIGraphicBufferProducer() const { return mProducer; @@ -88,7 +88,7 @@ public: void setTransactionCompleteCallback(uint64_t frameNumber, std::function<void(int64_t)>&& transactionCompleteCallback); - void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height); + void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format); void flushShadowQueue() { mFlushShadowQueue = true; } status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless); @@ -136,6 +136,7 @@ private: ui::Size mSize GUARDED_BY(mMutex); ui::Size mRequestedSize GUARDED_BY(mMutex); + int32_t mFormat GUARDED_BY(mMutex); uint32_t mTransformHint GUARDED_BY(mMutex); diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp index d69b7c38a3..70e656da9b 100644 --- a/libs/gui/tests/BLASTBufferQueue_test.cpp +++ b/libs/gui/tests/BLASTBufferQueue_test.cpp @@ -45,11 +45,12 @@ using android::hardware::graphics::common::V1_2::BufferUsage; class BLASTBufferQueueHelper { public: BLASTBufferQueueHelper(const sp<SurfaceControl>& sc, int width, int height) { - mBlastBufferQueueAdapter = new BLASTBufferQueue("TestBLASTBufferQueue", sc, width, height); + mBlastBufferQueueAdapter = new BLASTBufferQueue("TestBLASTBufferQueue", sc, width, height, + PIXEL_FORMAT_RGBA_8888); } void update(const sp<SurfaceControl>& sc, int width, int height) { - mBlastBufferQueueAdapter->update(sc, width, height); + mBlastBufferQueueAdapter->update(sc, width, height, PIXEL_FORMAT_RGBA_8888); } void setNextTransaction(Transaction* next) { |