Fix non camelCase member variables
Android Framework C++ Code Style Guidelines says that member variables
should be camelCase: http://go/droidcppstyle.
Test: m, mma in frameworks/native
Bug: 68273829
Change-Id: I859b916244f1e2ca2ba35c0a6e816b6250cd71ce
diff --git a/services/bufferhub/BufferNode.cpp b/services/bufferhub/BufferNode.cpp
index 5106390..dfa2de0 100644
--- a/services/bufferhub/BufferNode.cpp
+++ b/services/bufferhub/BufferNode.cpp
@@ -14,17 +14,16 @@
void BufferNode::InitializeMetadata() {
// Using placement new here to reuse shared memory instead of new allocation
// Initialize the atomic variables to zero.
- BufferHubDefs::MetadataHeader* metadata_header = metadata_.metadata_header();
- buffer_state_ = new (&metadata_header->buffer_state) std::atomic<uint32_t>(0);
- fence_state_ = new (&metadata_header->fence_state) std::atomic<uint32_t>(0);
- active_clients_bit_mask_ =
- new (&metadata_header->active_clients_bit_mask) std::atomic<uint32_t>(0);
+ BufferHubDefs::MetadataHeader* metadataHeader = mMetadata.metadata_header();
+ mBufferState = new (&metadataHeader->buffer_state) std::atomic<uint32_t>(0);
+ mFenceState = new (&metadataHeader->fence_state) std::atomic<uint32_t>(0);
+ mActiveClientsBitMask = new (&metadataHeader->active_clients_bit_mask) std::atomic<uint32_t>(0);
// The C++ standard recommends (but does not require) that lock-free atomic operations are
// also address-free, that is, suitable for communication between processes using shared
// memory.
- LOG_ALWAYS_FATAL_IF(!std::atomic_is_lock_free(buffer_state_) ||
- !std::atomic_is_lock_free(fence_state_) ||
- !std::atomic_is_lock_free(active_clients_bit_mask_),
+ LOG_ALWAYS_FATAL_IF(!std::atomic_is_lock_free(mBufferState) ||
+ !std::atomic_is_lock_free(mFenceState) ||
+ !std::atomic_is_lock_free(mActiveClientsBitMask),
"Atomic variables in ashmen are not lock free.");
}
@@ -38,25 +37,25 @@
// hardcoded service name "bufferhub".
int ret = GraphicBufferAllocator::get().allocate(width, height, format, layer_count, usage,
const_cast<const native_handle_t**>(
- &buffer_handle_),
+ &mBufferHandle),
&out_stride,
/*graphicBufferId=*/0,
/*requestor=*/"bufferhub");
- if (ret != OK || buffer_handle_ == nullptr) {
+ if (ret != OK || mBufferHandle == nullptr) {
ALOGE("%s: Failed to allocate buffer: %s", __FUNCTION__, strerror(-ret));
return;
}
- buffer_desc_.width = width;
- buffer_desc_.height = height;
- buffer_desc_.layers = layer_count;
- buffer_desc_.format = format;
- buffer_desc_.usage = usage;
- buffer_desc_.stride = out_stride;
+ mBufferDesc.width = width;
+ mBufferDesc.height = height;
+ mBufferDesc.layers = layer_count;
+ mBufferDesc.format = format;
+ mBufferDesc.usage = usage;
+ mBufferDesc.stride = out_stride;
- metadata_ = BufferHubMetadata::Create(user_metadata_size);
- if (!metadata_.IsValid()) {
+ mMetadata = BufferHubMetadata::Create(user_metadata_size);
+ if (!mMetadata.IsValid()) {
ALOGE("%s: Failed to allocate metadata.", __FUNCTION__);
return;
}
@@ -65,8 +64,8 @@
BufferNode::~BufferNode() {
// Free the handle
- if (buffer_handle_ != nullptr) {
- status_t ret = GraphicBufferAllocator::get().free(buffer_handle_);
+ if (mBufferHandle != nullptr) {
+ status_t ret = GraphicBufferAllocator::get().free(mBufferHandle);
if (ret != OK) {
ALOGE("%s: Failed to free handle; Got error: %d", __FUNCTION__, ret);
}
@@ -79,32 +78,32 @@
}
uint32_t BufferNode::GetActiveClientsBitMask() const {
- return active_clients_bit_mask_->load(std::memory_order_acquire);
+ return mActiveClientsBitMask->load(std::memory_order_acquire);
}
uint32_t BufferNode::AddNewActiveClientsBitToMask() {
- uint32_t current_active_clients_bit_mask = GetActiveClientsBitMask();
+ uint32_t currentActiveClientsBitMask = GetActiveClientsBitMask();
uint32_t client_state_mask = 0U;
- uint32_t updated_active_clients_bit_mask = 0U;
+ uint32_t updatedActiveClientsBitMask = 0U;
do {
client_state_mask =
- BufferHubDefs::FindNextAvailableClientStateMask(current_active_clients_bit_mask);
+ BufferHubDefs::FindNextAvailableClientStateMask(currentActiveClientsBitMask);
if (client_state_mask == 0U) {
ALOGE("%s: reached the maximum number of channels per buffer node: %d.", __FUNCTION__,
BufferHubDefs::kMaxNumberOfClients);
errno = E2BIG;
return 0U;
}
- updated_active_clients_bit_mask = current_active_clients_bit_mask | client_state_mask;
- } while (!(active_clients_bit_mask_->compare_exchange_weak(current_active_clients_bit_mask,
- updated_active_clients_bit_mask,
- std::memory_order_acq_rel,
- std::memory_order_acquire)));
+ updatedActiveClientsBitMask = currentActiveClientsBitMask | client_state_mask;
+ } while (!(mActiveClientsBitMask->compare_exchange_weak(currentActiveClientsBitMask,
+ updatedActiveClientsBitMask,
+ std::memory_order_acq_rel,
+ std::memory_order_acquire)));
return client_state_mask;
}
void BufferNode::RemoveClientsBitFromMask(const uint32_t& value) {
- active_clients_bit_mask_->fetch_and(~value);
+ mActiveClientsBitMask->fetch_and(~value);
}
} // namespace implementation
diff --git a/services/bufferhub/include/bufferhub/BufferNode.h b/services/bufferhub/include/bufferhub/BufferNode.h
index 4729e1c..112a21c 100644
--- a/services/bufferhub/include/bufferhub/BufferNode.h
+++ b/services/bufferhub/include/bufferhub/BufferNode.h
@@ -22,36 +22,36 @@
~BufferNode();
// Returns whether the object holds a valid metadata.
- bool IsValid() const { return metadata_.IsValid(); }
+ bool IsValid() const { return mMetadata.IsValid(); }
int id() const { return mId; }
- size_t user_metadata_size() const { return metadata_.user_metadata_size(); }
+ size_t user_metadata_size() const { return mMetadata.user_metadata_size(); }
// Accessors of the buffer description and handle
- const native_handle_t* buffer_handle() const { return buffer_handle_; }
- const AHardwareBuffer_Desc& buffer_desc() const { return buffer_desc_; }
+ const native_handle_t* buffer_handle() const { return mBufferHandle; }
+ const AHardwareBuffer_Desc& buffer_desc() const { return mBufferDesc; }
// Accessor of event fd.
const BufferHubEventFd& eventFd() const { return mEventFd; }
- // Accessors of metadata.
- const BufferHubMetadata& metadata() const { return metadata_; }
+ // Accessors of mMetadata.
+ const BufferHubMetadata& metadata() const { return mMetadata; }
- // Gets the current value of active_clients_bit_mask in metadata_ with
+ // Gets the current value of mActiveClientsBitMask in mMetadata with
// std::memory_order_acquire, so that all previous releases of
- // active_clients_bit_mask from all threads will be returned here.
+ // mActiveClientsBitMask from all threads will be returned here.
uint32_t GetActiveClientsBitMask() const;
- // Find and add a new client_state_mask to active_clients_bit_mask in
- // metadata_.
- // Return the new client_state_mask that is added to active_clients_bit_mask.
+ // Find and add a new client state mask to mActiveClientsBitMask in
+ // mMetadata.
+ // Return the new client state mask that is added to mActiveClientsBitMask.
// Return 0U if there are already 16 clients of the buffer.
uint32_t AddNewActiveClientsBitToMask();
- // Removes the value from active_clients_bit_mask in metadata_ with
+ // Removes the value from active_clients_bit_mask in mMetadata with
// std::memory_order_release, so that the change will be visible to any
- // acquire of active_clients_bit_mask_ in any threads after the succeed of
+ // acquire of mActiveClientsBitMask in any threads after the succeed of
// this operation.
void RemoveClientsBitFromMask(const uint32_t& value);
@@ -61,34 +61,34 @@
void InitializeMetadata();
// Gralloc buffer handles.
- native_handle_t* buffer_handle_;
- AHardwareBuffer_Desc buffer_desc_;
+ native_handle_t* mBufferHandle;
+ AHardwareBuffer_Desc mBufferDesc;
// Eventfd used for signalling buffer events among the clients of the buffer.
BufferHubEventFd mEventFd;
// Metadata in shared memory.
- BufferHubMetadata metadata_;
+ BufferHubMetadata mMetadata;
// A system-unique id generated by bufferhub from 0 to std::numeric_limits<int>::max().
// BufferNodes not created by bufferhub will have id < 0, meaning "not specified".
// TODO(b/118891412): remove default id = -1 and update comments after pdx is no longer in use
const int mId = -1;
- // The following variables are atomic variables in metadata_ that are visible
+ // The following variables are atomic variables in mMetadata that are visible
// to Bn object and Bp objects. Please find more info in
// BufferHubDefs::MetadataHeader.
- // buffer_state_ tracks the state of the buffer. Buffer can be in one of these
+ // mBufferState tracks the state of the buffer. Buffer can be in one of these
// four states: gained, posted, acquired, released.
- std::atomic<uint32_t>* buffer_state_ = nullptr;
+ std::atomic<uint32_t>* mBufferState = nullptr;
- // TODO(b/112012161): add comments to fence_state_.
- std::atomic<uint32_t>* fence_state_ = nullptr;
+ // TODO(b/112012161): add comments to mFenceState.
+ std::atomic<uint32_t>* mFenceState = nullptr;
- // active_clients_bit_mask_ tracks all the bp clients of the buffer. It is the
+ // mActiveClientsBitMask tracks all the bp clients of the buffer. It is the
// union of all client_state_mask of all bp clients.
- std::atomic<uint32_t>* active_clients_bit_mask_ = nullptr;
+ std::atomic<uint32_t>* mActiveClientsBitMask = nullptr;
};
} // namespace implementation