diff options
author | 2024-07-27 02:49:39 +0000 | |
---|---|---|
committer | 2024-08-13 17:07:53 +0000 | |
commit | d30823a16ea4c210d96ac983d2a04bec74b2c35a (patch) | |
tree | 261fb6b1edc31343a491b6dd0315c70c2202b327 /libs/gui/BufferItemConsumer.cpp | |
parent | 912ff82ead372fa36870a63585ce43a2624fed99 (diff) |
libgui: ConsumerBase-based classes now create their own BufferQueues
Using ConsumerBase-based classes is now the recommended way to create
BufferQueues.
This also includes a few new methods that are used by downstream classes
to avoid calling methods on raw IGBP/IGBCs.
I decided to keep and deprecate the old ctors temporarily. Before I roll
the flag out I'll remove them, but this way I can build the whole build
with or without the flag.
This is an important step for go/warren-buffers, because it consolidates
usages of BufferQueues to supported APIs and reduces the libgui API
surface that exposes IGBP/IGBC.
BYPASS_IGBP_IGBC_API_REASON: this CL is part of the migration.
Bug: 340933754
Flag: com.android.graphics.libgui.flags.wb_consumer_base_owns_bq
Test: atest, presubmit, compiles
Change-Id: I977165f3e50bc343df396a4c5ecc97fe31a67d5a
Diffstat (limited to 'libs/gui/BufferItemConsumer.cpp')
-rw-r--r-- | libs/gui/BufferItemConsumer.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/libs/gui/BufferItemConsumer.cpp b/libs/gui/BufferItemConsumer.cpp index eeb8f196e6..bfe3d6e023 100644 --- a/libs/gui/BufferItemConsumer.cpp +++ b/libs/gui/BufferItemConsumer.cpp @@ -35,18 +35,37 @@ namespace android { +#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) +BufferItemConsumer::BufferItemConsumer(uint64_t consumerUsage, int bufferCount, + bool controlledByApp, bool isConsumerSurfaceFlinger) + : ConsumerBase(controlledByApp, isConsumerSurfaceFlinger) { + initialize(consumerUsage, bufferCount); +} + +BufferItemConsumer::BufferItemConsumer(const sp<IGraphicBufferProducer>& producer, + const sp<IGraphicBufferConsumer>& consumer, + uint64_t consumerUsage, int bufferCount, + bool controlledByApp) + : ConsumerBase(producer, consumer, controlledByApp) { + initialize(consumerUsage, bufferCount); +} +#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) + BufferItemConsumer::BufferItemConsumer( const sp<IGraphicBufferConsumer>& consumer, uint64_t consumerUsage, int bufferCount, bool controlledByApp) : ConsumerBase(consumer, controlledByApp) { + initialize(consumerUsage, bufferCount); +} + +void BufferItemConsumer::initialize(uint64_t consumerUsage, int bufferCount) { status_t err = mConsumer->setConsumerUsageBits(consumerUsage); - LOG_ALWAYS_FATAL_IF(err != OK, - "Failed to set consumer usage bits to %#" PRIx64, consumerUsage); + LOG_ALWAYS_FATAL_IF(err != OK, "Failed to set consumer usage bits to %#" PRIx64, consumerUsage); if (bufferCount != DEFAULT_MAX_BUFFERS) { err = mConsumer->setMaxAcquiredBufferCount(bufferCount); - LOG_ALWAYS_FATAL_IF(err != OK, - "Failed to set max acquired buffer count to %d", bufferCount); + LOG_ALWAYS_FATAL_IF(err != OK, "Failed to set max acquired buffer count to %d", + bufferCount); } } |