Change the variable name "buffer_state_bit" into "client_state_mask".
Reasons:
1. This variable is not refering to a property of the buffer. It refers
to a client of the buffer.
2. The original "buffer_state_bit" of a producer/consumer is actually
the client state bit mask for both buffer_state and fence_state in
shared memory. Thus, "buffer_state_bit" does not make sense for the
fence state.
3. In the future, Every clients takes up two bits in the buffer_state.
For simpler bit manipulation, there will be a future change making the
client_state_bits two bits as well. Please refer to ag/5236978 for an
early look at the future bit manipulation. Thus, this change replaces
"bit" with "mask".
Test: build
Bug: 112007999
Change-Id: I72f59ab9491bd2f135da068f578195fbf5e6c2b6
diff --git a/libs/ui/BufferHubBuffer.cpp b/libs/ui/BufferHubBuffer.cpp
index 44a947e..a6e6d73 100644
--- a/libs/ui/BufferHubBuffer.cpp
+++ b/libs/ui/BufferHubBuffer.cpp
@@ -159,7 +159,7 @@
// If all imports succeed, replace the previous buffer and id.
mId = bufferId;
- mBufferStateBit = bufferTraits.buffer_state_bit();
+ mClientStateMask = bufferTraits.client_state_mask();
// TODO(b/112012161) Set up shared fences.
ALOGD("BufferHubBuffer::ImportGraphicBuffer: id=%d, buffer_state=%" PRIx64 ".", id(),
diff --git a/libs/ui/include/ui/BufferHubBuffer.h b/libs/ui/include/ui/BufferHubBuffer.h
index cefe5b3..daf6192 100644
--- a/libs/ui/include/ui/BufferHubBuffer.h
+++ b/libs/ui/include/ui/BufferHubBuffer.h
@@ -88,7 +88,7 @@
// A state mask which is unique to a buffer hub client among all its siblings sharing the same
// concrete graphic buffer.
- uint64_t buffer_state_bit() const { return mBufferStateBit; }
+ uint64_t client_state_mask() const { return mClientStateMask; }
size_t user_metadata_size() const { return mMetadata.user_metadata_size(); }
@@ -126,7 +126,7 @@
// Global id for the buffer that is consistent across processes.
int mId = -1;
- uint64_t mBufferStateBit = 0;
+ uint64_t mClientStateMask = 0;
// Wrapps the gralloc buffer handle of this buffer.
dvr::NativeHandleWrapper<pdx::LocalHandle> mBufferHandle;
diff --git a/libs/ui/tests/BufferHubBuffer_test.cpp b/libs/ui/tests/BufferHubBuffer_test.cpp
index be06ad2..f0253b2 100644
--- a/libs/ui/tests/BufferHubBuffer_test.cpp
+++ b/libs/ui/tests/BufferHubBuffer_test.cpp
@@ -100,12 +100,12 @@
// These two buffer instances are based on the same physical buffer under the
// hood, so they should share the same id.
EXPECT_EQ(id1, id2);
- // We use buffer_state_bit() to tell those two instances apart.
- EXPECT_NE(b1->buffer_state_bit(), b2->buffer_state_bit());
- EXPECT_NE(b1->buffer_state_bit(), 0ULL);
- EXPECT_NE(b2->buffer_state_bit(), 0ULL);
- EXPECT_NE(b1->buffer_state_bit(), kProducerStateBit);
- EXPECT_NE(b2->buffer_state_bit(), kProducerStateBit);
+ // We use client_state_mask() to tell those two instances apart.
+ EXPECT_NE(b1->client_state_mask(), b2->client_state_mask());
+ EXPECT_NE(b1->client_state_mask(), 0ULL);
+ EXPECT_NE(b2->client_state_mask(), 0ULL);
+ EXPECT_NE(b1->client_state_mask(), kProducerStateBit);
+ EXPECT_NE(b2->client_state_mask(), kProducerStateBit);
// Both buffer instances should be in gained state.
EXPECT_TRUE(IsBufferGained(b1->buffer_state()));