Loading libs/gui/BufferItemConsumer.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <com_android_graphics_libgui_flags.h> #include <gui/BufferItem.h> #include <gui/BufferItemConsumer.h> #include <gui/Surface.h> #include <ui/BufferQueueDefs.h> #include <ui/GraphicBuffer.h> Loading @@ -35,6 +36,30 @@ namespace android { std::tuple<sp<BufferItemConsumer>, sp<Surface>> BufferItemConsumer::create( uint64_t consumerUsage, int bufferCount, bool controlledByApp, bool isConsumerSurfaceFlinger) { #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) sp<BufferItemConsumer> bufferItemConsumer = sp<BufferItemConsumer>::make(consumerUsage, bufferCount, controlledByApp, isConsumerSurfaceFlinger); return {bufferItemConsumer, bufferItemConsumer->getSurface()}; #else sp<IGraphicBufferProducer> igbp; sp<IGraphicBufferConsumer> igbc; BufferQueue::createBufferQueue(&igbp, &igbc, isConsumerSurfaceFlinger); sp<BufferItemConsumer> bufferItemConsumer = sp<BufferItemConsumer>::make(igbc, consumerUsage, bufferCount, controlledByApp); return {bufferItemConsumer, sp<Surface>::make(igbp, controlledByApp)}; #endif } sp<BufferItemConsumer> BufferItemConsumer::create(const sp<IGraphicBufferConsumer>& consumer, uint64_t consumerUsage, int bufferCount, bool controlledByApp) { return sp<BufferItemConsumer>::make(consumer, consumerUsage, bufferCount, controlledByApp); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) BufferItemConsumer::BufferItemConsumer(uint64_t consumerUsage, int bufferCount, bool controlledByApp, bool isConsumerSurfaceFlinger) Loading libs/gui/ConsumerBase.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -480,7 +480,6 @@ status_t ConsumerBase::setMaxAcquiredBufferCount(int maxAcquiredBuffers) { return mConsumer->setMaxAcquiredBufferCount(maxAcquiredBuffers); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) status_t ConsumerBase::setConsumerIsProtected(bool isProtected) { Mutex::Autolock lock(mMutex); if (mAbandoned) { Loading @@ -489,7 +488,6 @@ status_t ConsumerBase::setConsumerIsProtected(bool isProtected) { } return mConsumer->setConsumerIsProtected(isProtected); } #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) sp<NativeHandle> ConsumerBase::getSidebandStream() const { Mutex::Autolock _l(mMutex); Loading libs/gui/include/gui/BufferItemConsumer.h +10 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,16 @@ class BufferItemConsumer: public ConsumerBase enum { INVALID_BUFFER_SLOT = BufferQueue::INVALID_BUFFER_SLOT }; enum { NO_BUFFER_AVAILABLE = BufferQueue::NO_BUFFER_AVAILABLE }; static std::tuple<sp<BufferItemConsumer>, sp<Surface>> create( uint64_t consumerUsage, int bufferCount = DEFAULT_MAX_BUFFERS, bool controlledByApp = false, bool isConsumerSurfaceFlinger = false); static sp<BufferItemConsumer> create(const sp<IGraphicBufferConsumer>& consumer, uint64_t consumerUsage, int bufferCount = DEFAULT_MAX_BUFFERS, bool controlledByApp = false) __attribute((deprecated("Prefer ctors that create their own surface and consumer."))); // Create a new buffer item consumer. The consumerUsage parameter determines // the consumer usage flags passed to the graphics allocator. The // bufferCount parameter specifies how many buffers can be locked for user Loading libs/gui/include/gui/ConsumerBase.h +0 −2 Original line number Diff line number Diff line Loading @@ -123,9 +123,7 @@ public: // See IGraphicBufferConsumer::setMaxAcquiredBufferCount status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers); #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) status_t setConsumerIsProtected(bool isProtected); #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) // See IGraphicBufferConsumer::getSidebandStream sp<NativeHandle> getSidebandStream() const; Loading libs/gui/tests/BufferItemConsumer_test.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -62,14 +62,15 @@ class BufferItemConsumerTest : public ::testing::Test { void SetUp() override { mBuffers.resize(BufferQueueDefs::NUM_BUFFER_SLOTS); mBIC = new BufferItemConsumer(kUsage, kMaxLockedBuffers, true); sp<Surface> surface; std::tie(mBIC, surface) = BufferItemConsumer::create(kUsage, kMaxLockedBuffers, true); String8 name("BufferItemConsumer_Under_Test"); mBIC->setName(name); mBFL = new BufferFreedListener(this); mBIC->setBufferFreedListener(mBFL); sp<IProducerListener> producerListener = new TrackingProducerListener(this); mProducer = mBIC->getSurface()->getIGraphicBufferProducer(); mProducer = surface->getIGraphicBufferProducer(); IGraphicBufferProducer::QueueBufferOutput bufferOutput; ASSERT_EQ(NO_ERROR, mProducer->connect(producerListener, NATIVE_WINDOW_API_CPU, Loading Loading
libs/gui/BufferItemConsumer.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <com_android_graphics_libgui_flags.h> #include <gui/BufferItem.h> #include <gui/BufferItemConsumer.h> #include <gui/Surface.h> #include <ui/BufferQueueDefs.h> #include <ui/GraphicBuffer.h> Loading @@ -35,6 +36,30 @@ namespace android { std::tuple<sp<BufferItemConsumer>, sp<Surface>> BufferItemConsumer::create( uint64_t consumerUsage, int bufferCount, bool controlledByApp, bool isConsumerSurfaceFlinger) { #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) sp<BufferItemConsumer> bufferItemConsumer = sp<BufferItemConsumer>::make(consumerUsage, bufferCount, controlledByApp, isConsumerSurfaceFlinger); return {bufferItemConsumer, bufferItemConsumer->getSurface()}; #else sp<IGraphicBufferProducer> igbp; sp<IGraphicBufferConsumer> igbc; BufferQueue::createBufferQueue(&igbp, &igbc, isConsumerSurfaceFlinger); sp<BufferItemConsumer> bufferItemConsumer = sp<BufferItemConsumer>::make(igbc, consumerUsage, bufferCount, controlledByApp); return {bufferItemConsumer, sp<Surface>::make(igbp, controlledByApp)}; #endif } sp<BufferItemConsumer> BufferItemConsumer::create(const sp<IGraphicBufferConsumer>& consumer, uint64_t consumerUsage, int bufferCount, bool controlledByApp) { return sp<BufferItemConsumer>::make(consumer, consumerUsage, bufferCount, controlledByApp); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) BufferItemConsumer::BufferItemConsumer(uint64_t consumerUsage, int bufferCount, bool controlledByApp, bool isConsumerSurfaceFlinger) Loading
libs/gui/ConsumerBase.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -480,7 +480,6 @@ status_t ConsumerBase::setMaxAcquiredBufferCount(int maxAcquiredBuffers) { return mConsumer->setMaxAcquiredBufferCount(maxAcquiredBuffers); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) status_t ConsumerBase::setConsumerIsProtected(bool isProtected) { Mutex::Autolock lock(mMutex); if (mAbandoned) { Loading @@ -489,7 +488,6 @@ status_t ConsumerBase::setConsumerIsProtected(bool isProtected) { } return mConsumer->setConsumerIsProtected(isProtected); } #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) sp<NativeHandle> ConsumerBase::getSidebandStream() const { Mutex::Autolock _l(mMutex); Loading
libs/gui/include/gui/BufferItemConsumer.h +10 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,16 @@ class BufferItemConsumer: public ConsumerBase enum { INVALID_BUFFER_SLOT = BufferQueue::INVALID_BUFFER_SLOT }; enum { NO_BUFFER_AVAILABLE = BufferQueue::NO_BUFFER_AVAILABLE }; static std::tuple<sp<BufferItemConsumer>, sp<Surface>> create( uint64_t consumerUsage, int bufferCount = DEFAULT_MAX_BUFFERS, bool controlledByApp = false, bool isConsumerSurfaceFlinger = false); static sp<BufferItemConsumer> create(const sp<IGraphicBufferConsumer>& consumer, uint64_t consumerUsage, int bufferCount = DEFAULT_MAX_BUFFERS, bool controlledByApp = false) __attribute((deprecated("Prefer ctors that create their own surface and consumer."))); // Create a new buffer item consumer. The consumerUsage parameter determines // the consumer usage flags passed to the graphics allocator. The // bufferCount parameter specifies how many buffers can be locked for user Loading
libs/gui/include/gui/ConsumerBase.h +0 −2 Original line number Diff line number Diff line Loading @@ -123,9 +123,7 @@ public: // See IGraphicBufferConsumer::setMaxAcquiredBufferCount status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers); #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) status_t setConsumerIsProtected(bool isProtected); #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) // See IGraphicBufferConsumer::getSidebandStream sp<NativeHandle> getSidebandStream() const; Loading
libs/gui/tests/BufferItemConsumer_test.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -62,14 +62,15 @@ class BufferItemConsumerTest : public ::testing::Test { void SetUp() override { mBuffers.resize(BufferQueueDefs::NUM_BUFFER_SLOTS); mBIC = new BufferItemConsumer(kUsage, kMaxLockedBuffers, true); sp<Surface> surface; std::tie(mBIC, surface) = BufferItemConsumer::create(kUsage, kMaxLockedBuffers, true); String8 name("BufferItemConsumer_Under_Test"); mBIC->setName(name); mBFL = new BufferFreedListener(this); mBIC->setBufferFreedListener(mBFL); sp<IProducerListener> producerListener = new TrackingProducerListener(this); mProducer = mBIC->getSurface()->getIGraphicBufferProducer(); mProducer = surface->getIGraphicBufferProducer(); IGraphicBufferProducer::QueueBufferOutput bufferOutput; ASSERT_EQ(NO_ERROR, mProducer->connect(producerListener, NATIVE_WINDOW_API_CPU, Loading