diff options
| author | 2021-02-05 17:05:06 +0000 | |
|---|---|---|
| committer | 2021-02-05 17:05:06 +0000 | |
| commit | afbe774235a718c542a27197a5a8227f0c78b7cd (patch) | |
| tree | b77034b0034ce4bcd1c15d529d7d8b2d8a188cf2 | |
| parent | 93d860a9a7b11109456c3fe5cb0d574b56f7f76d (diff) | |
| parent | 497e81c9fb9d955391678bbf0776b75d397e9ad9 (diff) | |
Merge "Convert certain format types to another buffer format." into sc-dev
| -rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 18 | ||||
| -rw-r--r-- | libs/gui/include/gui/BLASTBufferQueue.h | 1 |
2 files changed, 17 insertions, 2 deletions
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index c62d9ad440..c2ec0fe078 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -142,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(format); + mBufferItemConsumer->setDefaultBufferFormat(convertBufferFormat(format)); mTransformHint = mSurfaceControl->getTransformHint(); mBufferItemConsumer->setTransformHint(mTransformHint); @@ -175,7 +175,7 @@ void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, std::unique_lock _lock{mMutex}; if (mFormat != format) { mFormat = format; - mBufferItemConsumer->setDefaultBufferFormat(format); + mBufferItemConsumer->setDefaultBufferFormat(convertBufferFormat(format)); } SurfaceComposerClient::Transaction t; @@ -683,4 +683,18 @@ void BLASTBufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer *outConsumer = consumer; } +PixelFormat BLASTBufferQueue::convertBufferFormat(PixelFormat& format) { + PixelFormat convertedFormat = format; + switch (format) { + case PIXEL_FORMAT_TRANSPARENT: + case PIXEL_FORMAT_TRANSLUCENT: + convertedFormat = PIXEL_FORMAT_RGBA_8888; + break; + case PIXEL_FORMAT_OPAQUE: + convertedFormat = PIXEL_FORMAT_RGBX_8888; + break; + } + return convertedFormat; +} + } // namespace android diff --git a/libs/gui/include/gui/BLASTBufferQueue.h b/libs/gui/include/gui/BLASTBufferQueue.h index fa3efe15db..bccb71b362 100644 --- a/libs/gui/include/gui/BLASTBufferQueue.h +++ b/libs/gui/include/gui/BLASTBufferQueue.h @@ -110,6 +110,7 @@ private: // Return true if we need to reject the buffer based on the scaling mode and the buffer size. bool rejectBuffer(const BufferItem& item) REQUIRES(mMutex); bool maxBuffersAcquired(bool includeExtraAcquire) const REQUIRES(mMutex); + static PixelFormat convertBufferFormat(PixelFormat& format); std::string mName; sp<SurfaceControl> mSurfaceControl; |