From d30823a16ea4c210d96ac983d2a04bec74b2c35a Mon Sep 17 00:00:00 2001 From: Jim Shargo Date: Sat, 27 Jul 2024 02:49:39 +0000 Subject: 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 --- libs/gui/CpuConsumer.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'libs/gui/CpuConsumer.cpp') diff --git a/libs/gui/CpuConsumer.cpp b/libs/gui/CpuConsumer.cpp index 3031fa11fc..23b432e1f4 100644 --- a/libs/gui/CpuConsumer.cpp +++ b/libs/gui/CpuConsumer.cpp @@ -18,9 +18,9 @@ #define LOG_TAG "CpuConsumer" //#define ATRACE_TAG ATRACE_TAG_GRAPHICS -#include - +#include #include +#include #include #define CC_LOGV(x, ...) ALOGV("[%s] " x, mName.c_str(), ##__VA_ARGS__) @@ -31,12 +31,25 @@ namespace android { -CpuConsumer::CpuConsumer(const sp& bq, - size_t maxLockedBuffers, bool controlledByApp) : - ConsumerBase(bq, controlledByApp), - mMaxLockedBuffers(maxLockedBuffers), - mCurrentLockedBuffers(0) -{ +#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) +CpuConsumer::CpuConsumer(size_t maxLockedBuffers, bool controlledByApp, + bool isConsumerSurfaceFlinger) + : ConsumerBase(controlledByApp, isConsumerSurfaceFlinger), + mMaxLockedBuffers(maxLockedBuffers), + mCurrentLockedBuffers(0) { + // Create tracking entries for locked buffers + mAcquiredBuffers.insertAt(0, maxLockedBuffers); + + mConsumer->setConsumerUsageBits(GRALLOC_USAGE_SW_READ_OFTEN); + mConsumer->setMaxAcquiredBufferCount(static_cast(maxLockedBuffers)); +} +#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) + +CpuConsumer::CpuConsumer(const sp& bq, size_t maxLockedBuffers, + bool controlledByApp) + : ConsumerBase(bq, controlledByApp), + mMaxLockedBuffers(maxLockedBuffers), + mCurrentLockedBuffers(0) { // Create tracking entries for locked buffers mAcquiredBuffers.insertAt(0, maxLockedBuffers); -- cgit v1.2.3-59-g8ed1b