Merge "binder: make setRequestingSid(false) work"
diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp
index 609ddaf..670abea 100644
--- a/cmds/installd/otapreopt_chroot.cpp
+++ b/cmds/installd/otapreopt_chroot.cpp
@@ -80,8 +80,6 @@
// system/apex/apexd/apexd_main.cpp.
//
// Only scan the APEX directory under /system (within the chroot dir).
- // Note that this leaves around the loop devices created and used by
- // libapexd's code, but this is fine, as we expect to reboot soon after.
apex::scanPackagesDirAndActivate(apex::kApexPackageSystemDir);
return apex::getActivePackages();
}
diff --git a/libs/binder/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h
index f6381f7..0d30560 100644
--- a/libs/binder/include/binder/IInterface.h
+++ b/libs/binder/include/binder/IInterface.h
@@ -54,6 +54,7 @@
virtual const String16& getInterfaceDescriptor() const;
protected:
+ typedef INTERFACE BaseInterface;
virtual IBinder* onAsBinder();
};
@@ -66,6 +67,7 @@
explicit BpInterface(const sp<IBinder>& remote);
protected:
+ typedef INTERFACE BaseInterface;
virtual IBinder* onAsBinder();
};
diff --git a/libs/ui/BufferHubBuffer.cpp b/libs/ui/BufferHubBuffer.cpp
index 4b20772..7693fcb 100644
--- a/libs/ui/BufferHubBuffer.cpp
+++ b/libs/ui/BufferHubBuffer.cpp
@@ -24,12 +24,12 @@
#include <utils/Trace.h>
using ::android::base::unique_fd;
-using ::android::BufferHubDefs::AnyClientAcquired;
-using ::android::BufferHubDefs::AnyClientGained;
-using ::android::BufferHubDefs::IsClientAcquired;
-using ::android::BufferHubDefs::IsClientGained;
-using ::android::BufferHubDefs::IsClientPosted;
-using ::android::BufferHubDefs::IsClientReleased;
+using ::android::BufferHubDefs::isAnyClientAcquired;
+using ::android::BufferHubDefs::isAnyClientGained;
+using ::android::BufferHubDefs::isClientAcquired;
+using ::android::BufferHubDefs::isClientGained;
+using ::android::BufferHubDefs::isClientPosted;
+using ::android::BufferHubDefs::isClientReleased;
using ::android::frameworks::bufferhub::V1_0::BufferHubStatus;
using ::android::frameworks::bufferhub::V1_0::BufferTraits;
using ::android::frameworks::bufferhub::V1_0::IBufferClient;
@@ -39,22 +39,22 @@
namespace android {
-std::unique_ptr<BufferHubBuffer> BufferHubBuffer::Create(uint32_t width, uint32_t height,
+std::unique_ptr<BufferHubBuffer> BufferHubBuffer::create(uint32_t width, uint32_t height,
uint32_t layerCount, uint32_t format,
uint64_t usage, size_t userMetadataSize) {
auto buffer = std::unique_ptr<BufferHubBuffer>(
new BufferHubBuffer(width, height, layerCount, format, usage, userMetadataSize));
- return buffer->IsValid() ? std::move(buffer) : nullptr;
+ return buffer->isValid() ? std::move(buffer) : nullptr;
}
-std::unique_ptr<BufferHubBuffer> BufferHubBuffer::Import(const native_handle_t* token) {
+std::unique_ptr<BufferHubBuffer> BufferHubBuffer::import(const native_handle_t* token) {
if (token == nullptr) {
ALOGE("%s: token cannot be nullptr!", __FUNCTION__);
return nullptr;
}
auto buffer = std::unique_ptr<BufferHubBuffer>(new BufferHubBuffer(token));
- return buffer->IsValid() ? std::move(buffer) : nullptr;
+ return buffer->isValid() ? std::move(buffer) : nullptr;
}
BufferHubBuffer::BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layerCount,
@@ -169,8 +169,8 @@
// Import fds. Dup fds because hidl_handle owns the fds.
unique_fd ashmemFd(fcntl(bufferTraits.bufferInfo->data[0], F_DUPFD_CLOEXEC, 0));
- mMetadata = BufferHubMetadata::Import(std::move(ashmemFd));
- if (!mMetadata.IsValid()) {
+ mMetadata = BufferHubMetadata::import(std::move(ashmemFd));
+ if (!mMetadata.isValid()) {
ALOGE("%s: Received an invalid metadata.", __FUNCTION__);
return -EINVAL;
}
@@ -196,29 +196,29 @@
uint32_t userMetadataSize;
memcpy(&userMetadataSize, &bufferTraits.bufferInfo->data[4], sizeof(userMetadataSize));
- if (mMetadata.user_metadata_size() != userMetadataSize) {
+ if (mMetadata.userMetadataSize() != userMetadataSize) {
ALOGE("%s: user metadata size not match: expected %u, actual %zu.", __FUNCTION__,
- userMetadataSize, mMetadata.user_metadata_size());
+ userMetadataSize, mMetadata.userMetadataSize());
return -EINVAL;
}
- size_t metadataSize = static_cast<size_t>(mMetadata.metadata_size());
+ size_t metadataSize = static_cast<size_t>(mMetadata.metadataSize());
if (metadataSize < BufferHubDefs::kMetadataHeaderSize) {
ALOGE("%s: metadata too small: %zu", __FUNCTION__, metadataSize);
return -EINVAL;
}
// Populate shortcuts to the atomics in metadata.
- auto metadata_header = mMetadata.metadata_header();
- buffer_state_ = &metadata_header->buffer_state;
- fence_state_ = &metadata_header->fence_state;
- active_clients_bit_mask_ = &metadata_header->active_clients_bit_mask;
+ auto metadata_header = mMetadata.metadataHeader();
+ mBufferState = &metadata_header->buffer_state;
+ mFenceState = &metadata_header->fence_state;
+ mActiveClientsBitMask = &metadata_header->active_clients_bit_mask;
// 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.");
// Import the buffer: We only need to hold on the native_handle_t here so that
@@ -231,104 +231,104 @@
// TODO(b/112012161) Set up shared fences.
ALOGD("%s: id=%d, buffer_state=%" PRIx32 ".", __FUNCTION__, mId,
- buffer_state_->load(std::memory_order_acquire));
+ mBufferState->load(std::memory_order_acquire));
return 0;
}
-int BufferHubBuffer::Gain() {
- uint32_t current_buffer_state = buffer_state_->load(std::memory_order_acquire);
- if (IsClientGained(current_buffer_state, mClientStateMask)) {
+int BufferHubBuffer::gain() {
+ uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
+ if (isClientGained(currentBufferState, mClientStateMask)) {
ALOGV("%s: Buffer is already gained by this client %" PRIx32 ".", __FUNCTION__,
mClientStateMask);
return 0;
}
do {
- if (AnyClientGained(current_buffer_state & (~mClientStateMask)) ||
- AnyClientAcquired(current_buffer_state)) {
+ if (isAnyClientGained(currentBufferState & (~mClientStateMask)) ||
+ isAnyClientAcquired(currentBufferState)) {
ALOGE("%s: Buffer is in use, id=%d mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
- __FUNCTION__, mId, mClientStateMask, current_buffer_state);
+ __FUNCTION__, mId, mClientStateMask, currentBufferState);
return -EBUSY;
}
// Change the buffer state to gained state, whose value happens to be the same as
// mClientStateMask.
- } while (!buffer_state_->compare_exchange_weak(current_buffer_state, mClientStateMask,
- std::memory_order_acq_rel,
- std::memory_order_acquire));
+ } while (!mBufferState->compare_exchange_weak(currentBufferState, mClientStateMask,
+ std::memory_order_acq_rel,
+ std::memory_order_acquire));
// TODO(b/119837586): Update fence state and return GPU fence.
return 0;
}
-int BufferHubBuffer::Post() {
- uint32_t current_buffer_state = buffer_state_->load(std::memory_order_acquire);
- uint32_t updated_buffer_state = (~mClientStateMask) & BufferHubDefs::kHighBitsMask;
+int BufferHubBuffer::post() {
+ uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
+ uint32_t updatedBufferState = (~mClientStateMask) & BufferHubDefs::kHighBitsMask;
do {
- if (!IsClientGained(current_buffer_state, mClientStateMask)) {
+ if (!isClientGained(currentBufferState, mClientStateMask)) {
ALOGE("%s: Cannot post a buffer that is not gained by this client. buffer_id=%d "
"mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
- __FUNCTION__, mId, mClientStateMask, current_buffer_state);
+ __FUNCTION__, mId, mClientStateMask, currentBufferState);
return -EBUSY;
}
// Set the producer client buffer state to released, other clients' buffer state to posted.
// Post to all existing and non-existing clients.
- } while (!buffer_state_->compare_exchange_weak(current_buffer_state, updated_buffer_state,
- std::memory_order_acq_rel,
- std::memory_order_acquire));
+ } while (!mBufferState->compare_exchange_weak(currentBufferState, updatedBufferState,
+ std::memory_order_acq_rel,
+ std::memory_order_acquire));
// TODO(b/119837586): Update fence state and return GPU fence if needed.
return 0;
}
-int BufferHubBuffer::Acquire() {
- uint32_t current_buffer_state = buffer_state_->load(std::memory_order_acquire);
- if (IsClientAcquired(current_buffer_state, mClientStateMask)) {
+int BufferHubBuffer::acquire() {
+ uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
+ if (isClientAcquired(currentBufferState, mClientStateMask)) {
ALOGV("%s: Buffer is already acquired by this client %" PRIx32 ".", __FUNCTION__,
mClientStateMask);
return 0;
}
- uint32_t updated_buffer_state = 0U;
+ uint32_t updatedBufferState = 0U;
do {
- if (!IsClientPosted(current_buffer_state, mClientStateMask)) {
+ if (!isClientPosted(currentBufferState, mClientStateMask)) {
ALOGE("%s: Cannot acquire a buffer that is not in posted state. buffer_id=%d "
"mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
- __FUNCTION__, mId, mClientStateMask, current_buffer_state);
+ __FUNCTION__, mId, mClientStateMask, currentBufferState);
return -EBUSY;
}
// Change the buffer state for this consumer from posted to acquired.
- updated_buffer_state = current_buffer_state ^ mClientStateMask;
- } while (!buffer_state_->compare_exchange_weak(current_buffer_state, updated_buffer_state,
- std::memory_order_acq_rel,
- std::memory_order_acquire));
+ updatedBufferState = currentBufferState ^ mClientStateMask;
+ } while (!mBufferState->compare_exchange_weak(currentBufferState, updatedBufferState,
+ std::memory_order_acq_rel,
+ std::memory_order_acquire));
// TODO(b/119837586): Update fence state and return GPU fence.
return 0;
}
-int BufferHubBuffer::Release() {
- uint32_t current_buffer_state = buffer_state_->load(std::memory_order_acquire);
- if (IsClientReleased(current_buffer_state, mClientStateMask)) {
+int BufferHubBuffer::release() {
+ uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
+ if (isClientReleased(currentBufferState, mClientStateMask)) {
ALOGV("%s: Buffer is already released by this client %" PRIx32 ".", __FUNCTION__,
mClientStateMask);
return 0;
}
- uint32_t updated_buffer_state = 0U;
+ uint32_t updatedBufferState = 0U;
do {
- updated_buffer_state = current_buffer_state & (~mClientStateMask);
- } while (!buffer_state_->compare_exchange_weak(current_buffer_state, updated_buffer_state,
- std::memory_order_acq_rel,
- std::memory_order_acquire));
+ updatedBufferState = currentBufferState & (~mClientStateMask);
+ } while (!mBufferState->compare_exchange_weak(currentBufferState, updatedBufferState,
+ std::memory_order_acq_rel,
+ std::memory_order_acquire));
// TODO(b/119837586): Update fence state and return GPU fence if needed.
return 0;
}
-bool BufferHubBuffer::IsReleased() const {
- return (buffer_state_->load(std::memory_order_acquire) &
- active_clients_bit_mask_->load(std::memory_order_acquire)) == 0;
+bool BufferHubBuffer::isReleased() const {
+ return (mBufferState->load(std::memory_order_acquire) &
+ mActiveClientsBitMask->load(std::memory_order_acquire)) == 0;
}
-bool BufferHubBuffer::IsValid() const {
+bool BufferHubBuffer::isValid() const {
return mBufferHandle.getNativeHandle() != nullptr && mId >= 0 && mClientStateMask != 0U &&
- mEventFd.get() >= 0 && mMetadata.IsValid() && mBufferClient != nullptr;
+ mEventFd.get() >= 0 && mMetadata.isValid() && mBufferClient != nullptr;
}
-native_handle_t* BufferHubBuffer::Duplicate() {
+native_handle_t* BufferHubBuffer::duplicate() {
if (mBufferClient == nullptr) {
ALOGE("%s: missing BufferClient!", __FUNCTION__);
return nullptr;
diff --git a/libs/ui/BufferHubMetadata.cpp b/libs/ui/BufferHubMetadata.cpp
index 816707d..05bc7dd 100644
--- a/libs/ui/BufferHubMetadata.cpp
+++ b/libs/ui/BufferHubMetadata.cpp
@@ -34,7 +34,7 @@
using BufferHubDefs::MetadataHeader;
/* static */
-BufferHubMetadata BufferHubMetadata::Create(size_t userMetadataSize) {
+BufferHubMetadata BufferHubMetadata::create(size_t userMetadataSize) {
// The size the of metadata buffer is used as the "width" parameter during allocation. Thus it
// cannot overflow uint32_t.
if (userMetadataSize >= (std::numeric_limits<uint32_t>::max() - kMetadataHeaderSize)) {
@@ -59,11 +59,11 @@
return {};
}
- return BufferHubMetadata::Import(std::move(ashmemFd));
+ return BufferHubMetadata::import(std::move(ashmemFd));
}
/* static */
-BufferHubMetadata BufferHubMetadata::Import(unique_fd ashmemFd) {
+BufferHubMetadata BufferHubMetadata::import(unique_fd ashmemFd) {
if (!ashmem_valid(ashmemFd.get())) {
ALOGE("BufferHubMetadata::Import: invalid ashmem fd.");
return {};
@@ -94,7 +94,7 @@
BufferHubMetadata::~BufferHubMetadata() {
if (mMetadataHeader != nullptr) {
- int ret = munmap(mMetadataHeader, metadata_size());
+ int ret = munmap(mMetadataHeader, metadataSize());
ALOGE_IF(ret != 0,
"BufferHubMetadata::~BufferHubMetadata: failed to unmap ashmem, error=%d.", errno);
mMetadataHeader = nullptr;
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 41ae253..f487dfa 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -100,7 +100,7 @@
return;
}
- mInitCheck = initWithHandle(buffer->DuplicateHandle(), /*method=*/TAKE_UNREGISTERED_HANDLE,
+ mInitCheck = initWithHandle(buffer->duplicateHandle(), /*method=*/TAKE_UNREGISTERED_HANDLE,
buffer->desc().width, buffer->desc().height,
static_cast<PixelFormat>(buffer->desc().format),
buffer->desc().layers, buffer->desc().usage, buffer->desc().stride);
diff --git a/libs/ui/include/ui/BufferHubBuffer.h b/libs/ui/include/ui/BufferHubBuffer.h
index 0b6d75a..eac8c84 100644
--- a/libs/ui/include/ui/BufferHubBuffer.h
+++ b/libs/ui/include/ui/BufferHubBuffer.h
@@ -29,14 +29,14 @@
class BufferHubBuffer {
public:
// Allocates a standalone BufferHubBuffer.
- static std::unique_ptr<BufferHubBuffer> Create(uint32_t width, uint32_t height,
+ static std::unique_ptr<BufferHubBuffer> create(uint32_t width, uint32_t height,
uint32_t layerCount, uint32_t format,
uint64_t usage, size_t userMetadataSize);
// Imports the given token to a BufferHubBuffer. Not taking ownership of the token. Caller
// should close and destroy the token after calling this function regardless of output.
// TODO(b/122543147): use a movable wrapper for token
- static std::unique_ptr<BufferHubBuffer> Import(const native_handle_t* token);
+ static std::unique_ptr<BufferHubBuffer> import(const native_handle_t* token);
BufferHubBuffer(const BufferHubBuffer&) = delete;
void operator=(const BufferHubBuffer&) = delete;
@@ -52,51 +52,51 @@
// Duplicate the underlying Gralloc buffer handle. Caller is responsible to free the handle
// after use.
- native_handle_t* DuplicateHandle() {
+ native_handle_t* duplicateHandle() {
return native_handle_clone(mBufferHandle.getNativeHandle());
}
const BufferHubEventFd& eventFd() const { return mEventFd; }
// Returns the current value of MetadataHeader::buffer_state.
- uint32_t buffer_state() const { return buffer_state_->load(std::memory_order_acquire); }
+ uint32_t bufferState() const { return mBufferState->load(std::memory_order_acquire); }
// A state mask which is unique to a buffer hub client among all its siblings sharing the same
// concrete graphic buffer.
- uint32_t client_state_mask() const { return mClientStateMask; }
+ uint32_t clientStateMask() const { return mClientStateMask; }
- size_t user_metadata_size() const { return mMetadata.user_metadata_size(); }
+ size_t userMetadataSize() const { return mMetadata.userMetadataSize(); }
// Returns true if the BufferClient is still alive.
- bool IsConnected() const { return mBufferClient->ping().isOk(); }
+ bool isConnected() const { return mBufferClient->ping().isOk(); }
// Returns true if the buffer is valid: non-null buffer handle, valid id, valid client bit mask,
// valid metadata and valid buffer client
- bool IsValid() const;
+ bool isValid() const;
// Gains the buffer for exclusive write permission. Read permission is implied once a buffer is
// gained.
// The buffer can be gained as long as there is no other client in acquired or gained state.
- int Gain();
+ int gain();
// Posts the gained buffer for other buffer clients to use the buffer.
// The buffer can be posted iff the buffer state for this client is gained.
// After posting the buffer, this client is put to released state and does not have access to
// the buffer for this cycle of the usage of the buffer.
- int Post();
+ int post();
// Acquires the buffer for shared read permission.
// The buffer can be acquired iff the buffer state for this client is posted.
- int Acquire();
+ int acquire();
// Releases the buffer.
// The buffer can be released from any buffer state.
// After releasing the buffer, this client no longer have any permissions to the buffer for the
// current cycle of the usage of the buffer.
- int Release();
+ int release();
// Returns whether the buffer is released by all active clients or not.
- bool IsReleased() const;
+ bool isReleased() const;
// Creates a token that stands for this BufferHubBuffer client and could be used for Import to
// create another BufferHubBuffer. The new BufferHubBuffer will share the same underlying
@@ -104,7 +104,7 @@
// should free it after use.
// Returns a valid token on success, nullptr on failure.
// TODO(b/122543147): use a movable wrapper for token
- native_handle_t* Duplicate();
+ native_handle_t* duplicate();
private:
BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layerCount, uint32_t format,
@@ -134,9 +134,9 @@
// bufferhubd daemon and all buffer clients.
BufferHubMetadata mMetadata;
// Shortcuts to the atomics inside the header of mMetadata.
- std::atomic<uint32_t>* buffer_state_ = nullptr;
- std::atomic<uint32_t>* fence_state_ = nullptr;
- std::atomic<uint32_t>* active_clients_bit_mask_ = nullptr;
+ std::atomic<uint32_t>* mBufferState = nullptr;
+ std::atomic<uint32_t>* mFenceState = nullptr;
+ std::atomic<uint32_t>* mActiveClientsBitMask = nullptr;
// HwBinder backend
sp<frameworks::bufferhub::V1_0::IBufferClient> mBufferClient;
diff --git a/libs/ui/include/ui/BufferHubDefs.h b/libs/ui/include/ui/BufferHubDefs.h
index ff970cb..722a060 100644
--- a/libs/ui/include/ui/BufferHubDefs.h
+++ b/libs/ui/include/ui/BufferHubDefs.h
@@ -63,19 +63,19 @@
static constexpr uint32_t kFirstClientBitMask = (1U << kMaxNumberOfClients) + 1U;
// Returns true if any of the client is in gained state.
-static inline bool AnyClientGained(uint32_t state) {
+static inline bool isAnyClientGained(uint32_t state) {
uint32_t high_bits = state >> kMaxNumberOfClients;
uint32_t low_bits = state & kLowbitsMask;
return high_bits == low_bits && low_bits != 0U;
}
// Returns true if the input client is in gained state.
-static inline bool IsClientGained(uint32_t state, uint32_t client_bit_mask) {
+static inline bool isClientGained(uint32_t state, uint32_t client_bit_mask) {
return state == client_bit_mask;
}
// Returns true if any of the client is in posted state.
-static inline bool AnyClientPosted(uint32_t state) {
+static inline bool isAnyClientPosted(uint32_t state) {
uint32_t high_bits = state >> kMaxNumberOfClients;
uint32_t low_bits = state & kLowbitsMask;
uint32_t posted_or_acquired = high_bits ^ low_bits;
@@ -83,7 +83,7 @@
}
// Returns true if the input client is in posted state.
-static inline bool IsClientPosted(uint32_t state, uint32_t client_bit_mask) {
+static inline bool isClientPosted(uint32_t state, uint32_t client_bit_mask) {
uint32_t client_bits = state & client_bit_mask;
if (client_bits == 0U) return false;
uint32_t low_bits = client_bits & kLowbitsMask;
@@ -91,7 +91,7 @@
}
// Return true if any of the client is in acquired state.
-static inline bool AnyClientAcquired(uint32_t state) {
+static inline bool isAnyClientAcquired(uint32_t state) {
uint32_t high_bits = state >> kMaxNumberOfClients;
uint32_t low_bits = state & kLowbitsMask;
uint32_t posted_or_acquired = high_bits ^ low_bits;
@@ -99,7 +99,7 @@
}
// Return true if the input client is in acquired state.
-static inline bool IsClientAcquired(uint32_t state, uint32_t client_bit_mask) {
+static inline bool isClientAcquired(uint32_t state, uint32_t client_bit_mask) {
uint32_t client_bits = state & client_bit_mask;
if (client_bits == 0U) return false;
uint32_t high_bits = client_bits & kHighBitsMask;
@@ -107,13 +107,13 @@
}
// Returns true if the input client is in released state.
-static inline bool IsClientReleased(uint32_t state, uint32_t client_bit_mask) {
+static inline bool isClientReleased(uint32_t state, uint32_t client_bit_mask) {
return (state & client_bit_mask) == 0U;
}
// Returns the next available buffer client's client_state_masks.
// @params union_bits. Union of all existing clients' client_state_masks.
-static inline uint32_t FindNextAvailableClientStateMask(uint32_t union_bits) {
+static inline uint32_t findNextAvailableClientStateMask(uint32_t union_bits) {
uint32_t low_union = union_bits & kLowbitsMask;
if (low_union == kLowbitsMask) return 0U;
uint32_t incremented = low_union + 1U;
diff --git a/libs/ui/include/ui/BufferHubMetadata.h b/libs/ui/include/ui/BufferHubMetadata.h
index 2121894..3482507 100644
--- a/libs/ui/include/ui/BufferHubMetadata.h
+++ b/libs/ui/include/ui/BufferHubMetadata.h
@@ -33,12 +33,12 @@
// @param userMetadataSize Size in bytes of the user defined metadata. The entire metadata
// shared memory region to be allocated is the size of canonical
// BufferHubDefs::MetadataHeader plus userMetadataSize.
- static BufferHubMetadata Create(size_t userMetadataSize);
+ static BufferHubMetadata create(size_t userMetadataSize);
// Imports an existing BufferHubMetadata from an ashmem FD.
//
// @param ashmemFd Ashmem file descriptor representing an ashmem region.
- static BufferHubMetadata Import(unique_fd ashmemFd);
+ static BufferHubMetadata import(unique_fd ashmemFd);
BufferHubMetadata() = default;
@@ -63,13 +63,13 @@
// Returns true if the metadata is valid, i.e. the metadata has a valid ashmem fd and the ashmem
// has been mapped into virtual address space.
- bool IsValid() const { return mAshmemFd.get() != -1 && mMetadataHeader != nullptr; }
+ bool isValid() const { return mAshmemFd.get() != -1 && mMetadataHeader != nullptr; }
- size_t user_metadata_size() const { return mUserMetadataSize; }
- size_t metadata_size() const { return mUserMetadataSize + BufferHubDefs::kMetadataHeaderSize; }
+ size_t userMetadataSize() const { return mUserMetadataSize; }
+ size_t metadataSize() const { return mUserMetadataSize + BufferHubDefs::kMetadataHeaderSize; }
- const unique_fd& ashmem_fd() const { return mAshmemFd; }
- BufferHubDefs::MetadataHeader* metadata_header() { return mMetadataHeader; }
+ const unique_fd& ashmemFd() const { return mAshmemFd; }
+ BufferHubDefs::MetadataHeader* metadataHeader() { return mMetadataHeader; }
private:
BufferHubMetadata(size_t userMetadataSize, unique_fd ashmemFd,
diff --git a/libs/ui/tests/BufferHubBuffer_test.cpp b/libs/ui/tests/BufferHubBuffer_test.cpp
index 3bcd935..3087a90 100644
--- a/libs/ui/tests/BufferHubBuffer_test.cpp
+++ b/libs/ui/tests/BufferHubBuffer_test.cpp
@@ -32,13 +32,13 @@
namespace {
-using ::android::BufferHubDefs::AnyClientAcquired;
-using ::android::BufferHubDefs::AnyClientGained;
-using ::android::BufferHubDefs::AnyClientPosted;
-using ::android::BufferHubDefs::IsClientAcquired;
-using ::android::BufferHubDefs::IsClientGained;
-using ::android::BufferHubDefs::IsClientPosted;
-using ::android::BufferHubDefs::IsClientReleased;
+using ::android::BufferHubDefs::isAnyClientAcquired;
+using ::android::BufferHubDefs::isAnyClientGained;
+using ::android::BufferHubDefs::isAnyClientPosted;
+using ::android::BufferHubDefs::isClientAcquired;
+using ::android::BufferHubDefs::isClientGained;
+using ::android::BufferHubDefs::isClientPosted;
+using ::android::BufferHubDefs::isClientReleased;
using ::android::BufferHubDefs::kMetadataHeaderSize;
using ::testing::IsNull;
using ::testing::NotNull;
@@ -81,88 +81,88 @@
};
void BufferHubBufferStateTransitionTest::CreateTwoClientsOfABuffer() {
- b1 = BufferHubBuffer::Create(kWidth, kHeight, kLayerCount, kFormat, kUsage, kUserMetadataSize);
+ b1 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage, kUserMetadataSize);
ASSERT_THAT(b1, NotNull());
- b1ClientMask = b1->client_state_mask();
+ b1ClientMask = b1->clientStateMask();
ASSERT_NE(b1ClientMask, 0U);
- native_handle_t* token = b1->Duplicate();
+ native_handle_t* token = b1->duplicate();
ASSERT_THAT(token, NotNull());
// TODO(b/122543147): use a movalbe wrapper for token
- b2 = BufferHubBuffer::Import(token);
+ b2 = BufferHubBuffer::import(token);
native_handle_close(token);
native_handle_delete(token);
ASSERT_THAT(b2, NotNull());
- b2ClientMask = b2->client_state_mask();
+ b2ClientMask = b2->clientStateMask();
ASSERT_NE(b2ClientMask, 0U);
ASSERT_NE(b2ClientMask, b1ClientMask);
}
TEST_F(BufferHubBufferTest, CreateBufferFails) {
// Buffer Creation will fail: BLOB format requires height to be 1.
- auto b1 = BufferHubBuffer::Create(kWidth, /*height=*/2, kLayerCount,
+ auto b1 = BufferHubBuffer::create(kWidth, /*height=*/2, kLayerCount,
/*format=*/HAL_PIXEL_FORMAT_BLOB, kUsage, kUserMetadataSize);
EXPECT_THAT(b1, IsNull());
// Buffer Creation will fail: user metadata size too large.
- auto b2 = BufferHubBuffer::Create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
+ auto b2 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
/*userMetadataSize=*/std::numeric_limits<size_t>::max());
EXPECT_THAT(b2, IsNull());
// Buffer Creation will fail: user metadata size too large.
const size_t userMetadataSize = std::numeric_limits<size_t>::max() - kMetadataHeaderSize;
- auto b3 = BufferHubBuffer::Create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
+ auto b3 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
userMetadataSize);
EXPECT_THAT(b3, IsNull());
}
TEST_F(BufferHubBufferTest, CreateBuffer) {
- auto b1 = BufferHubBuffer::Create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
+ auto b1 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
kUserMetadataSize);
ASSERT_THAT(b1, NotNull());
- EXPECT_TRUE(b1->IsConnected());
- EXPECT_TRUE(b1->IsValid());
+ EXPECT_TRUE(b1->isConnected());
+ EXPECT_TRUE(b1->isValid());
EXPECT_TRUE(cmpAHardwareBufferDesc(b1->desc(), kDesc));
- EXPECT_EQ(b1->user_metadata_size(), kUserMetadataSize);
+ EXPECT_EQ(b1->userMetadataSize(), kUserMetadataSize);
}
TEST_F(BufferHubBufferTest, DuplicateAndImportBuffer) {
- auto b1 = BufferHubBuffer::Create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
+ auto b1 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
kUserMetadataSize);
ASSERT_THAT(b1, NotNull());
- EXPECT_TRUE(b1->IsValid());
+ EXPECT_TRUE(b1->isValid());
- native_handle_t* token = b1->Duplicate();
+ native_handle_t* token = b1->duplicate();
EXPECT_TRUE(token);
// The detached buffer should still be valid.
- EXPECT_TRUE(b1->IsConnected());
- EXPECT_TRUE(b1->IsValid());
+ EXPECT_TRUE(b1->isConnected());
+ EXPECT_TRUE(b1->isValid());
- std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::Import(token);
+ std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::import(token);
native_handle_close(token);
native_handle_delete(token);
ASSERT_THAT(b2, NotNull());
- EXPECT_TRUE(b2->IsValid());
+ EXPECT_TRUE(b2->isValid());
EXPECT_TRUE(cmpAHardwareBufferDesc(b1->desc(), b2->desc()));
- EXPECT_EQ(b1->user_metadata_size(), b2->user_metadata_size());
+ EXPECT_EQ(b1->userMetadataSize(), b2->userMetadataSize());
// These two buffer instances are based on the same physical buffer under the
// hood, so they should share the same id.
EXPECT_EQ(b1->id(), b2->id());
- // We use client_state_mask() to tell those two instances apart.
- EXPECT_NE(b1->client_state_mask(), b2->client_state_mask());
+ // We use clientStateMask() to tell those two instances apart.
+ EXPECT_NE(b1->clientStateMask(), b2->clientStateMask());
// Both buffer instances should be in released state currently.
- EXPECT_TRUE(b1->IsReleased());
- EXPECT_TRUE(b2->IsReleased());
+ EXPECT_TRUE(b1->isReleased());
+ EXPECT_TRUE(b2->isReleased());
// The event fd should behave like duped event fds.
const BufferHubEventFd& eventFd1 = b1->eventFd();
@@ -192,19 +192,19 @@
}
TEST_F(BufferHubBufferTest, ImportFreedBuffer) {
- auto b1 = BufferHubBuffer::Create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
+ auto b1 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
kUserMetadataSize);
ASSERT_THAT(b1, NotNull());
- EXPECT_TRUE(b1->IsValid());
+ EXPECT_TRUE(b1->isValid());
- native_handle_t* token = b1->Duplicate();
+ native_handle_t* token = b1->duplicate();
EXPECT_TRUE(token);
// Explicitly destroy b1. Backend buffer should be freed and token becomes invalid
b1.reset();
// TODO(b/122543147): use a movalbe wrapper for token
- std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::Import(token);
+ std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::import(token);
native_handle_close(token);
native_handle_delete(token);
@@ -214,7 +214,7 @@
// nullptr must not crash the service
TEST_F(BufferHubBufferTest, ImportNullToken) {
- auto b1 = BufferHubBuffer::Import(nullptr);
+ auto b1 = BufferHubBuffer::import(nullptr);
EXPECT_THAT(b1, IsNull());
}
@@ -222,185 +222,185 @@
native_handle_t* token = native_handle_create(/*numFds=*/0, /*numInts=*/1);
token->data[0] = 0;
- auto b1 = BufferHubBuffer::Import(token);
+ auto b1 = BufferHubBuffer::import(token);
native_handle_delete(token);
EXPECT_THAT(b1, IsNull());
}
TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromReleasedState) {
- ASSERT_TRUE(b1->IsReleased());
+ ASSERT_TRUE(b1->isReleased());
// Successful gaining the buffer should change the buffer state bit of b1 to
// gained state, other client state bits to released state.
- EXPECT_EQ(b1->Gain(), 0);
- EXPECT_TRUE(IsClientGained(b1->buffer_state(), b1ClientMask));
+ EXPECT_EQ(b1->gain(), 0);
+ EXPECT_TRUE(isClientGained(b1->bufferState(), b1ClientMask));
}
TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromGainedState) {
- ASSERT_EQ(b1->Gain(), 0);
- auto current_buffer_state = b1->buffer_state();
- ASSERT_TRUE(IsClientGained(current_buffer_state, b1ClientMask));
+ ASSERT_EQ(b1->gain(), 0);
+ auto currentBufferState = b1->bufferState();
+ ASSERT_TRUE(isClientGained(currentBufferState, b1ClientMask));
// Gaining from gained state by the same client should not return error.
- EXPECT_EQ(b1->Gain(), 0);
+ EXPECT_EQ(b1->gain(), 0);
// Gaining from gained state by another client should return error.
- EXPECT_EQ(b2->Gain(), -EBUSY);
+ EXPECT_EQ(b2->gain(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromAcquiredState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_EQ(b2->Acquire(), 0);
- ASSERT_TRUE(AnyClientAcquired(b1->buffer_state()));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_EQ(b2->acquire(), 0);
+ ASSERT_TRUE(isAnyClientAcquired(b1->bufferState()));
// Gaining from acquired state should fail.
- EXPECT_EQ(b1->Gain(), -EBUSY);
- EXPECT_EQ(b2->Gain(), -EBUSY);
+ EXPECT_EQ(b1->gain(), -EBUSY);
+ EXPECT_EQ(b2->gain(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromOtherClientInPostedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_TRUE(AnyClientPosted(b1->buffer_state()));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_TRUE(isAnyClientPosted(b1->bufferState()));
// Gaining a buffer who has other posted client should succeed.
- EXPECT_EQ(b1->Gain(), 0);
+ EXPECT_EQ(b1->gain(), 0);
}
TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromSelfInPostedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_TRUE(AnyClientPosted(b1->buffer_state()));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_TRUE(isAnyClientPosted(b1->bufferState()));
// A posted client should be able to gain the buffer when there is no other clients in
// acquired state.
- EXPECT_EQ(b2->Gain(), 0);
+ EXPECT_EQ(b2->gain(), 0);
}
TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromOtherInGainedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_TRUE(IsClientGained(b1->buffer_state(), b1ClientMask));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_TRUE(isClientGained(b1->bufferState(), b1ClientMask));
- EXPECT_EQ(b2->Post(), -EBUSY);
+ EXPECT_EQ(b2->post(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromSelfInGainedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_TRUE(IsClientGained(b1->buffer_state(), b1ClientMask));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_TRUE(isClientGained(b1->bufferState(), b1ClientMask));
- EXPECT_EQ(b1->Post(), 0);
- auto current_buffer_state = b1->buffer_state();
- EXPECT_TRUE(IsClientReleased(current_buffer_state, b1ClientMask));
- EXPECT_TRUE(IsClientPosted(current_buffer_state, b2ClientMask));
+ EXPECT_EQ(b1->post(), 0);
+ auto currentBufferState = b1->bufferState();
+ EXPECT_TRUE(isClientReleased(currentBufferState, b1ClientMask));
+ EXPECT_TRUE(isClientPosted(currentBufferState, b2ClientMask));
}
TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromPostedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_TRUE(AnyClientPosted(b1->buffer_state()));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_TRUE(isAnyClientPosted(b1->bufferState()));
// Post from posted state should fail.
- EXPECT_EQ(b1->Post(), -EBUSY);
- EXPECT_EQ(b2->Post(), -EBUSY);
+ EXPECT_EQ(b1->post(), -EBUSY);
+ EXPECT_EQ(b2->post(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromAcquiredState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_EQ(b2->Acquire(), 0);
- ASSERT_TRUE(AnyClientAcquired(b1->buffer_state()));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_EQ(b2->acquire(), 0);
+ ASSERT_TRUE(isAnyClientAcquired(b1->bufferState()));
// Posting from acquired state should fail.
- EXPECT_EQ(b1->Post(), -EBUSY);
- EXPECT_EQ(b2->Post(), -EBUSY);
+ EXPECT_EQ(b1->post(), -EBUSY);
+ EXPECT_EQ(b2->post(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromReleasedState) {
- ASSERT_TRUE(b1->IsReleased());
+ ASSERT_TRUE(b1->isReleased());
// Posting from released state should fail.
- EXPECT_EQ(b1->Post(), -EBUSY);
- EXPECT_EQ(b2->Post(), -EBUSY);
+ EXPECT_EQ(b1->post(), -EBUSY);
+ EXPECT_EQ(b2->post(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromSelfInPostedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_TRUE(IsClientPosted(b1->buffer_state(), b2ClientMask));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_TRUE(isClientPosted(b1->bufferState(), b2ClientMask));
// Acquire from posted state should pass.
- EXPECT_EQ(b2->Acquire(), 0);
+ EXPECT_EQ(b2->acquire(), 0);
}
TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromOtherInPostedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_TRUE(IsClientPosted(b1->buffer_state(), b2ClientMask));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_TRUE(isClientPosted(b1->bufferState(), b2ClientMask));
// Acquire from released state should fail, although there are other clients
// in posted state.
- EXPECT_EQ(b1->Acquire(), -EBUSY);
+ EXPECT_EQ(b1->acquire(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromSelfInAcquiredState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_EQ(b2->Acquire(), 0);
- auto current_buffer_state = b1->buffer_state();
- ASSERT_TRUE(IsClientAcquired(current_buffer_state, b2ClientMask));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_EQ(b2->acquire(), 0);
+ auto currentBufferState = b1->bufferState();
+ ASSERT_TRUE(isClientAcquired(currentBufferState, b2ClientMask));
// Acquiring from acquired state by the same client should not error out.
- EXPECT_EQ(b2->Acquire(), 0);
+ EXPECT_EQ(b2->acquire(), 0);
}
TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromReleasedState) {
- ASSERT_TRUE(b1->IsReleased());
+ ASSERT_TRUE(b1->isReleased());
// Acquiring form released state should fail.
- EXPECT_EQ(b1->Acquire(), -EBUSY);
- EXPECT_EQ(b2->Acquire(), -EBUSY);
+ EXPECT_EQ(b1->acquire(), -EBUSY);
+ EXPECT_EQ(b2->acquire(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromGainedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_TRUE(AnyClientGained(b1->buffer_state()));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_TRUE(isAnyClientGained(b1->bufferState()));
// Acquiring from gained state should fail.
- EXPECT_EQ(b1->Acquire(), -EBUSY);
- EXPECT_EQ(b2->Acquire(), -EBUSY);
+ EXPECT_EQ(b1->acquire(), -EBUSY);
+ EXPECT_EQ(b2->acquire(), -EBUSY);
}
TEST_F(BufferHubBufferStateTransitionTest, ReleaseBuffer_fromSelfInReleasedState) {
- ASSERT_TRUE(b1->IsReleased());
+ ASSERT_TRUE(b1->isReleased());
- EXPECT_EQ(b1->Release(), 0);
+ EXPECT_EQ(b1->release(), 0);
}
TEST_F(BufferHubBufferStateTransitionTest, ReleaseBuffer_fromSelfInGainedState) {
- ASSERT_TRUE(b1->IsReleased());
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_TRUE(AnyClientGained(b1->buffer_state()));
+ ASSERT_TRUE(b1->isReleased());
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_TRUE(isAnyClientGained(b1->bufferState()));
- EXPECT_EQ(b1->Release(), 0);
+ EXPECT_EQ(b1->release(), 0);
}
TEST_F(BufferHubBufferStateTransitionTest, ReleaseBuffer_fromSelfInPostedState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_TRUE(AnyClientPosted(b1->buffer_state()));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_TRUE(isAnyClientPosted(b1->bufferState()));
- EXPECT_EQ(b2->Release(), 0);
+ EXPECT_EQ(b2->release(), 0);
}
TEST_F(BufferHubBufferStateTransitionTest, ReleaseBuffer_fromSelfInAcquiredState) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_EQ(b2->Acquire(), 0);
- ASSERT_TRUE(AnyClientAcquired(b1->buffer_state()));
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_EQ(b2->acquire(), 0);
+ ASSERT_TRUE(isAnyClientAcquired(b1->bufferState()));
- EXPECT_EQ(b2->Release(), 0);
+ EXPECT_EQ(b2->release(), 0);
}
TEST_F(BufferHubBufferStateTransitionTest, BasicUsage) {
@@ -408,60 +408,60 @@
// Test if this set of basic operation succeed:
// Producer post three times to the consumer, and released by consumer.
for (int i = 0; i < 3; ++i) {
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
- ASSERT_EQ(b2->Acquire(), 0);
- ASSERT_EQ(b2->Release(), 0);
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ ASSERT_EQ(b2->acquire(), 0);
+ ASSERT_EQ(b2->release(), 0);
}
}
TEST_F(BufferHubBufferTest, createNewConsumerAfterGain) {
// Create a poducer buffer and gain.
std::unique_ptr<BufferHubBuffer> b1 =
- BufferHubBuffer::Create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
+ BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
kUserMetadataSize);
ASSERT_THAT(b1, NotNull());
- ASSERT_EQ(b1->Gain(), 0);
+ ASSERT_EQ(b1->gain(), 0);
// Create a consumer of the buffer and test if the consumer can acquire the
// buffer if producer posts.
// TODO(b/122543147): use a movalbe wrapper for token
- native_handle_t* token = b1->Duplicate();
+ native_handle_t* token = b1->duplicate();
ASSERT_TRUE(token);
- std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::Import(token);
+ std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::import(token);
native_handle_close(token);
native_handle_delete(token);
ASSERT_THAT(b2, NotNull());
- ASSERT_NE(b1->client_state_mask(), b2->client_state_mask());
+ ASSERT_NE(b1->clientStateMask(), b2->clientStateMask());
- ASSERT_EQ(b1->Post(), 0);
- EXPECT_EQ(b2->Acquire(), 0);
+ ASSERT_EQ(b1->post(), 0);
+ EXPECT_EQ(b2->acquire(), 0);
}
TEST_F(BufferHubBufferTest, createNewConsumerAfterPost) {
// Create a poducer buffer and post.
std::unique_ptr<BufferHubBuffer> b1 =
- BufferHubBuffer::Create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
+ BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
kUserMetadataSize);
- ASSERT_EQ(b1->Gain(), 0);
- ASSERT_EQ(b1->Post(), 0);
+ ASSERT_EQ(b1->gain(), 0);
+ ASSERT_EQ(b1->post(), 0);
// Create a consumer of the buffer and test if the consumer can acquire the
// buffer if producer posts.
// TODO(b/122543147): use a movalbe wrapper for token
- native_handle_t* token = b1->Duplicate();
+ native_handle_t* token = b1->duplicate();
ASSERT_TRUE(token);
- std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::Import(token);
+ std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::import(token);
native_handle_close(token);
native_handle_delete(token);
ASSERT_THAT(b2, NotNull());
- ASSERT_NE(b1->client_state_mask(), b2->client_state_mask());
+ ASSERT_NE(b1->clientStateMask(), b2->clientStateMask());
- EXPECT_EQ(b2->Acquire(), 0);
+ EXPECT_EQ(b2->acquire(), 0);
}
} // namespace
diff --git a/libs/ui/tests/BufferHubMetadata_test.cpp b/libs/ui/tests/BufferHubMetadata_test.cpp
index b7f0b4b..f02c4fc 100644
--- a/libs/ui/tests/BufferHubMetadata_test.cpp
+++ b/libs/ui/tests/BufferHubMetadata_test.cpp
@@ -25,74 +25,73 @@
class BufferHubMetadataTest : public ::testing::Test {};
TEST_F(BufferHubMetadataTest, Create_UserMetdataSizeTooBig) {
- BufferHubMetadata m1 =
- BufferHubMetadata::Create(std::numeric_limits<uint32_t>::max());
- EXPECT_FALSE(m1.IsValid());
+ BufferHubMetadata m1 = BufferHubMetadata::create(std::numeric_limits<uint32_t>::max());
+ EXPECT_FALSE(m1.isValid());
}
TEST_F(BufferHubMetadataTest, Create_Success) {
- BufferHubMetadata m1 = BufferHubMetadata::Create(kEmptyUserMetadataSize);
- EXPECT_TRUE(m1.IsValid());
- EXPECT_NE(m1.metadata_header(), nullptr);
+ BufferHubMetadata m1 = BufferHubMetadata::create(kEmptyUserMetadataSize);
+ EXPECT_TRUE(m1.isValid());
+ EXPECT_NE(m1.metadataHeader(), nullptr);
}
TEST_F(BufferHubMetadataTest, Import_Success) {
- BufferHubMetadata m1 = BufferHubMetadata::Create(kEmptyUserMetadataSize);
- EXPECT_TRUE(m1.IsValid());
- EXPECT_NE(m1.metadata_header(), nullptr);
+ BufferHubMetadata m1 = BufferHubMetadata::create(kEmptyUserMetadataSize);
+ EXPECT_TRUE(m1.isValid());
+ EXPECT_NE(m1.metadataHeader(), nullptr);
- unique_fd h2 = unique_fd(dup(m1.ashmem_fd().get()));
- EXPECT_NE(h2.get(), -1);
+ unique_fd h2 = unique_fd(dup(m1.ashmemFd().get()));
+ EXPECT_NE(h2.get(), -1);
- BufferHubMetadata m2 = BufferHubMetadata::Import(std::move(h2));
- EXPECT_EQ(h2.get(), -1);
- EXPECT_TRUE(m1.IsValid());
- BufferHubDefs::MetadataHeader* mh1 = m1.metadata_header();
- EXPECT_NE(mh1, nullptr);
+ BufferHubMetadata m2 = BufferHubMetadata::import(std::move(h2));
+ EXPECT_EQ(h2.get(), -1);
+ EXPECT_TRUE(m1.isValid());
+ BufferHubDefs::MetadataHeader* mh1 = m1.metadataHeader();
+ EXPECT_NE(mh1, nullptr);
- // Check if the newly allocated buffer is initialized in released state (i.e.
- // state equals to 0U).
- EXPECT_TRUE(mh1->buffer_state.load() == 0U);
+ // Check if the newly allocated buffer is initialized in released state (i.e.
+ // state equals to 0U).
+ EXPECT_TRUE(mh1->buffer_state.load() == 0U);
- EXPECT_TRUE(m2.IsValid());
- BufferHubDefs::MetadataHeader* mh2 = m2.metadata_header();
- EXPECT_NE(mh2, nullptr);
+ EXPECT_TRUE(m2.isValid());
+ BufferHubDefs::MetadataHeader* mh2 = m2.metadataHeader();
+ EXPECT_NE(mh2, nullptr);
- // Check if the newly allocated buffer is initialized in released state (i.e.
- // state equals to 0U).
- EXPECT_TRUE(mh2->buffer_state.load() == 0U);
+ // Check if the newly allocated buffer is initialized in released state (i.e.
+ // state equals to 0U).
+ EXPECT_TRUE(mh2->buffer_state.load() == 0U);
}
TEST_F(BufferHubMetadataTest, MoveMetadataInvalidatesOldOne) {
- BufferHubMetadata m1 = BufferHubMetadata::Create(sizeof(int));
- EXPECT_TRUE(m1.IsValid());
- EXPECT_NE(m1.metadata_header(), nullptr);
- EXPECT_NE(m1.ashmem_fd().get(), -1);
- EXPECT_EQ(m1.user_metadata_size(), sizeof(int));
+ BufferHubMetadata m1 = BufferHubMetadata::create(sizeof(int));
+ EXPECT_TRUE(m1.isValid());
+ EXPECT_NE(m1.metadataHeader(), nullptr);
+ EXPECT_NE(m1.ashmemFd().get(), -1);
+ EXPECT_EQ(m1.userMetadataSize(), sizeof(int));
- BufferHubMetadata m2 = std::move(m1);
+ BufferHubMetadata m2 = std::move(m1);
- // After the move, the metadata header (a raw pointer) should be reset in the older buffer.
- EXPECT_EQ(m1.metadata_header(), nullptr);
- EXPECT_NE(m2.metadata_header(), nullptr);
+ // After the move, the metadata header (a raw pointer) should be reset in the older buffer.
+ EXPECT_EQ(m1.metadataHeader(), nullptr);
+ EXPECT_NE(m2.metadataHeader(), nullptr);
- EXPECT_EQ(m1.ashmem_fd().get(), -1);
- EXPECT_NE(m2.ashmem_fd().get(), -1);
+ EXPECT_EQ(m1.ashmemFd().get(), -1);
+ EXPECT_NE(m2.ashmemFd().get(), -1);
- EXPECT_EQ(m1.user_metadata_size(), 0U);
- EXPECT_EQ(m2.user_metadata_size(), sizeof(int));
+ EXPECT_EQ(m1.userMetadataSize(), 0U);
+ EXPECT_EQ(m2.userMetadataSize(), sizeof(int));
- BufferHubMetadata m3{std::move(m2)};
+ BufferHubMetadata m3{std::move(m2)};
- // After the move, the metadata header (a raw pointer) should be reset in the older buffer.
- EXPECT_EQ(m2.metadata_header(), nullptr);
- EXPECT_NE(m3.metadata_header(), nullptr);
+ // After the move, the metadata header (a raw pointer) should be reset in the older buffer.
+ EXPECT_EQ(m2.metadataHeader(), nullptr);
+ EXPECT_NE(m3.metadataHeader(), nullptr);
- EXPECT_EQ(m2.ashmem_fd().get(), -1);
- EXPECT_NE(m3.ashmem_fd().get(), -1);
+ EXPECT_EQ(m2.ashmemFd().get(), -1);
+ EXPECT_NE(m3.ashmemFd().get(), -1);
- EXPECT_EQ(m2.user_metadata_size(), 0U);
- EXPECT_EQ(m3.user_metadata_size(), sizeof(int));
+ EXPECT_EQ(m2.userMetadataSize(), 0U);
+ EXPECT_EQ(m3.userMetadataSize(), sizeof(int));
}
} // namespace dvr
diff --git a/libs/ui/tests/GraphicBuffer_test.cpp b/libs/ui/tests/GraphicBuffer_test.cpp
index 5b46454..c767ce0 100644
--- a/libs/ui/tests/GraphicBuffer_test.cpp
+++ b/libs/ui/tests/GraphicBuffer_test.cpp
@@ -37,10 +37,10 @@
TEST_F(GraphicBufferTest, CreateFromBufferHubBuffer) {
std::unique_ptr<BufferHubBuffer> b1 =
- BufferHubBuffer::Create(kTestWidth, kTestHeight, kTestLayerCount, kTestFormat,
+ BufferHubBuffer::create(kTestWidth, kTestHeight, kTestLayerCount, kTestFormat,
kTestUsage, /*userMetadataSize=*/0);
ASSERT_NE(b1, nullptr);
- EXPECT_TRUE(b1->IsValid());
+ EXPECT_TRUE(b1->isValid());
sp<GraphicBuffer> gb(new GraphicBuffer(std::move(b1)));
EXPECT_TRUE(gb->isBufferHubBuffer());
@@ -61,10 +61,10 @@
TEST_F(GraphicBufferTest, BufferIdMatchesBufferHubBufferId) {
std::unique_ptr<BufferHubBuffer> b1 =
- BufferHubBuffer::Create(kTestWidth, kTestHeight, kTestLayerCount, kTestFormat,
+ BufferHubBuffer::create(kTestWidth, kTestHeight, kTestLayerCount, kTestFormat,
kTestUsage, /*userMetadataSize=*/0);
EXPECT_NE(b1, nullptr);
- EXPECT_TRUE(b1->IsValid());
+ EXPECT_TRUE(b1->isValid());
int b1_id = b1->id();
EXPECT_GE(b1_id, 0);
diff --git a/libs/vr/libbufferhub/buffer_hub-test.cpp b/libs/vr/libbufferhub/buffer_hub-test.cpp
index 527a27d..27ab024 100644
--- a/libs/vr/libbufferhub/buffer_hub-test.cpp
+++ b/libs/vr/libbufferhub/buffer_hub-test.cpp
@@ -20,12 +20,12 @@
return result; \
})()
-using android::BufferHubDefs::AnyClientAcquired;
-using android::BufferHubDefs::AnyClientGained;
-using android::BufferHubDefs::AnyClientPosted;
-using android::BufferHubDefs::IsClientAcquired;
-using android::BufferHubDefs::IsClientPosted;
-using android::BufferHubDefs::IsClientReleased;
+using android::BufferHubDefs::isAnyClientAcquired;
+using android::BufferHubDefs::isAnyClientGained;
+using android::BufferHubDefs::isAnyClientPosted;
+using android::BufferHubDefs::isClientAcquired;
+using android::BufferHubDefs::isClientPosted;
+using android::BufferHubDefs::isClientReleased;
using android::BufferHubDefs::kFirstClientBitMask;
using android::dvr::ConsumerBuffer;
using android::dvr::ProducerBuffer;
@@ -268,7 +268,7 @@
// Post in gained state should succeed.
EXPECT_EQ(0, p->PostAsync(&metadata, invalid_fence));
EXPECT_EQ(p->buffer_state(), c->buffer_state());
- EXPECT_TRUE(AnyClientPosted(p->buffer_state()));
+ EXPECT_TRUE(isAnyClientPosted(p->buffer_state()));
// Post and gain in posted state should fail.
EXPECT_EQ(-EBUSY, p->PostAsync(&metadata, invalid_fence));
@@ -280,7 +280,7 @@
EXPECT_EQ(0, c->AcquireAsync(&metadata, &invalid_fence));
EXPECT_FALSE(invalid_fence.IsValid());
EXPECT_EQ(p->buffer_state(), c->buffer_state());
- EXPECT_TRUE(AnyClientAcquired(p->buffer_state()));
+ EXPECT_TRUE(isAnyClientAcquired(p->buffer_state()));
// Acquire, post, and gain in acquired state should fail.
EXPECT_EQ(-EBUSY, c->AcquireAsync(&metadata, &invalid_fence));
@@ -304,7 +304,7 @@
EXPECT_EQ(0, p->GainAsync(&metadata, &invalid_fence));
EXPECT_FALSE(invalid_fence.IsValid());
EXPECT_EQ(p->buffer_state(), c->buffer_state());
- EXPECT_TRUE(AnyClientGained(p->buffer_state()));
+ EXPECT_TRUE(isAnyClientGained(p->buffer_state()));
// Acquire and gain in gained state should fail.
EXPECT_EQ(-EBUSY, c->AcquireAsync(&metadata, &invalid_fence));
@@ -329,7 +329,7 @@
ASSERT_TRUE(c.get() != nullptr);
ASSERT_EQ(0, p->GainAsync());
ASSERT_EQ(0, p->Post(LocalHandle()));
- ASSERT_TRUE(AnyClientPosted(p->buffer_state()));
+ ASSERT_TRUE(isAnyClientPosted(p->buffer_state()));
// Gain in posted state should only succeed with gain_posted_buffer = true.
LocalHandle invalid_fence;
@@ -346,7 +346,7 @@
ASSERT_TRUE(c.get() != nullptr);
ASSERT_EQ(0, p->GainAsync());
ASSERT_EQ(0, p->Post(LocalHandle()));
- ASSERT_TRUE(AnyClientPosted(p->buffer_state()));
+ ASSERT_TRUE(isAnyClientPosted(p->buffer_state()));
// GainAsync in posted state should only succeed with gain_posted_buffer
// equals true.
@@ -364,9 +364,9 @@
ASSERT_EQ(0, p->Post(LocalHandle()));
// Producer state bit is in released state after post, other clients shall be
// in posted state although there is no consumer of this buffer yet.
- ASSERT_TRUE(IsClientReleased(p->buffer_state(), p->client_state_mask()));
+ ASSERT_TRUE(isClientReleased(p->buffer_state(), p->client_state_mask()));
ASSERT_TRUE(p->is_released());
- ASSERT_TRUE(AnyClientPosted(p->buffer_state()));
+ ASSERT_TRUE(isAnyClientPosted(p->buffer_state()));
// Gain in released state should succeed.
LocalHandle invalid_fence;
@@ -393,14 +393,14 @@
// Post the producer should trigger all consumers to be available.
EXPECT_EQ(0, p->PostAsync(&metadata, invalid_fence));
- EXPECT_TRUE(IsClientReleased(p->buffer_state(), p->client_state_mask()));
+ EXPECT_TRUE(isClientReleased(p->buffer_state(), p->client_state_mask()));
for (size_t i = 0; i < kMaxConsumerCount; ++i) {
EXPECT_TRUE(
- IsClientPosted(cs[i]->buffer_state(), cs[i]->client_state_mask()));
+ isClientPosted(cs[i]->buffer_state(), cs[i]->client_state_mask()));
EXPECT_LT(0, RETRY_EINTR(PollBufferEvent(cs[i])));
EXPECT_EQ(0, cs[i]->AcquireAsync(&metadata, &invalid_fence));
EXPECT_TRUE(
- IsClientAcquired(p->buffer_state(), cs[i]->client_state_mask()));
+ isClientAcquired(p->buffer_state(), cs[i]->client_state_mask()));
}
// All consumers have to release before the buffer is considered to be
@@ -424,22 +424,22 @@
kWidth, kHeight, kFormat, kUsage, sizeof(uint64_t));
ASSERT_TRUE(p.get() != nullptr);
EXPECT_EQ(0, p->GainAsync());
- EXPECT_TRUE(AnyClientGained(p->buffer_state()));
+ EXPECT_TRUE(isAnyClientGained(p->buffer_state()));
std::unique_ptr<ConsumerBuffer> c =
ConsumerBuffer::Import(p->CreateConsumer());
ASSERT_TRUE(c.get() != nullptr);
- EXPECT_TRUE(AnyClientGained(c->buffer_state()));
+ EXPECT_TRUE(isAnyClientGained(c->buffer_state()));
DvrNativeBufferMetadata metadata;
LocalHandle invalid_fence;
// Post the gained buffer should signal already created consumer.
EXPECT_EQ(0, p->PostAsync(&metadata, invalid_fence));
- EXPECT_TRUE(AnyClientPosted(p->buffer_state()));
+ EXPECT_TRUE(isAnyClientPosted(p->buffer_state()));
EXPECT_LT(0, RETRY_EINTR(PollBufferEvent(c)));
EXPECT_EQ(0, c->AcquireAsync(&metadata, &invalid_fence));
- EXPECT_TRUE(AnyClientAcquired(c->buffer_state()));
+ EXPECT_TRUE(isAnyClientAcquired(c->buffer_state()));
}
TEST_F(LibBufferHubTest, TestCreateTheFirstConsumerAfterPostingBuffer) {
@@ -447,7 +447,7 @@
kWidth, kHeight, kFormat, kUsage, sizeof(uint64_t));
ASSERT_TRUE(p.get() != nullptr);
EXPECT_EQ(0, p->GainAsync());
- EXPECT_TRUE(AnyClientGained(p->buffer_state()));
+ EXPECT_TRUE(isAnyClientGained(p->buffer_state()));
DvrNativeBufferMetadata metadata;
LocalHandle invalid_fence;
@@ -462,7 +462,7 @@
std::unique_ptr<ConsumerBuffer> c =
ConsumerBuffer::Import(p->CreateConsumer());
ASSERT_TRUE(c.get() != nullptr);
- EXPECT_TRUE(IsClientPosted(c->buffer_state(), c->client_state_mask()));
+ EXPECT_TRUE(isClientPosted(c->buffer_state(), c->client_state_mask()));
EXPECT_EQ(0, c->AcquireAsync(&metadata, &invalid_fence));
}
@@ -500,7 +500,7 @@
EXPECT_TRUE(p->is_released());
EXPECT_EQ(0, p->GainAsync(&metadata, &invalid_fence));
- EXPECT_TRUE(AnyClientGained(p->buffer_state()));
+ EXPECT_TRUE(isAnyClientGained(p->buffer_state()));
}
TEST_F(LibBufferHubTest, TestWithCustomMetadata) {
diff --git a/libs/vr/libbufferhub/consumer_buffer.cpp b/libs/vr/libbufferhub/consumer_buffer.cpp
index b6ca64e..115e866 100644
--- a/libs/vr/libbufferhub/consumer_buffer.cpp
+++ b/libs/vr/libbufferhub/consumer_buffer.cpp
@@ -38,7 +38,7 @@
// The buffer can be acquired iff the buffer state for this client is posted.
uint32_t current_buffer_state =
buffer_state_->load(std::memory_order_acquire);
- if (!BufferHubDefs::IsClientPosted(current_buffer_state,
+ if (!BufferHubDefs::isClientPosted(current_buffer_state,
client_state_mask())) {
ALOGE(
"%s: Failed to acquire the buffer. The buffer is not posted, id=%d "
@@ -58,7 +58,7 @@
" when trying to acquire the buffer and modify the buffer state to "
"%" PRIx32 ". About to try again if the buffer is still posted.",
__FUNCTION__, current_buffer_state, updated_buffer_state);
- if (!BufferHubDefs::IsClientPosted(current_buffer_state,
+ if (!BufferHubDefs::isClientPosted(current_buffer_state,
client_state_mask())) {
ALOGE(
"%s: Failed to acquire the buffer. The buffer is no longer posted, "
@@ -144,7 +144,7 @@
// released state.
uint32_t current_buffer_state =
buffer_state_->load(std::memory_order_acquire);
- if (BufferHubDefs::IsClientReleased(current_buffer_state,
+ if (BufferHubDefs::isClientReleased(current_buffer_state,
client_state_mask())) {
return 0;
}
diff --git a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_defs.h b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_defs.h
index bab7367..e610e18 100644
--- a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_defs.h
+++ b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_defs.h
@@ -27,38 +27,38 @@
static constexpr uint32_t kFirstClientBitMask =
android::BufferHubDefs::kFirstClientBitMask;
-static inline bool AnyClientGained(uint32_t state) {
- return android::BufferHubDefs::AnyClientGained(state);
+static inline bool isAnyClientGained(uint32_t state) {
+ return android::BufferHubDefs::isAnyClientGained(state);
}
-static inline bool IsClientGained(uint32_t state, uint32_t client_bit_mask) {
- return android::BufferHubDefs::IsClientGained(state, client_bit_mask);
+static inline bool isClientGained(uint32_t state, uint32_t client_bit_mask) {
+ return android::BufferHubDefs::isClientGained(state, client_bit_mask);
}
-static inline bool AnyClientPosted(uint32_t state) {
- return android::BufferHubDefs::AnyClientPosted(state);
+static inline bool isAnyClientPosted(uint32_t state) {
+ return android::BufferHubDefs::isAnyClientPosted(state);
}
-static inline bool IsClientPosted(uint32_t state, uint32_t client_bit_mask) {
- return android::BufferHubDefs::IsClientPosted(state, client_bit_mask);
+static inline bool isClientPosted(uint32_t state, uint32_t client_bit_mask) {
+ return android::BufferHubDefs::isClientPosted(state, client_bit_mask);
}
-static inline bool AnyClientAcquired(uint32_t state) {
- return android::BufferHubDefs::AnyClientAcquired(state);
+static inline bool isAnyClientAcquired(uint32_t state) {
+ return android::BufferHubDefs::isAnyClientAcquired(state);
}
-static inline bool IsClientAcquired(uint32_t state, uint32_t client_bit_mask) {
- return android::BufferHubDefs::IsClientAcquired(state, client_bit_mask);
+static inline bool isClientAcquired(uint32_t state, uint32_t client_bit_mask) {
+ return android::BufferHubDefs::isClientAcquired(state, client_bit_mask);
}
-static inline bool IsClientReleased(uint32_t state, uint32_t client_bit_mask) {
- return android::BufferHubDefs::IsClientReleased(state, client_bit_mask);
+static inline bool isClientReleased(uint32_t state, uint32_t client_bit_mask) {
+ return android::BufferHubDefs::isClientReleased(state, client_bit_mask);
}
// Returns the next available buffer client's client_state_masks.
// @params union_bits. Union of all existing clients' client_state_masks.
-static inline uint32_t FindNextAvailableClientStateMask(uint32_t union_bits) {
- return android::BufferHubDefs::FindNextAvailableClientStateMask(union_bits);
+static inline uint32_t findNextAvailableClientStateMask(uint32_t union_bits) {
+ return android::BufferHubDefs::findNextAvailableClientStateMask(union_bits);
}
using MetadataHeader = android::BufferHubDefs::MetadataHeader;
diff --git a/libs/vr/libbufferhub/producer_buffer.cpp b/libs/vr/libbufferhub/producer_buffer.cpp
index edfdddf..3d88ba5 100644
--- a/libs/vr/libbufferhub/producer_buffer.cpp
+++ b/libs/vr/libbufferhub/producer_buffer.cpp
@@ -82,7 +82,7 @@
// The buffer can be posted iff the buffer state for this client is gained.
uint32_t current_buffer_state =
buffer_state_->load(std::memory_order_acquire);
- if (!BufferHubDefs::IsClientGained(current_buffer_state,
+ if (!BufferHubDefs::isClientGained(current_buffer_state,
client_state_mask())) {
ALOGE("%s: not gained, id=%d state=%" PRIx32 ".", __FUNCTION__, id(),
current_buffer_state);
@@ -103,7 +103,7 @@
"%" PRIx32
". About to try again if the buffer is still gained by this client.",
__FUNCTION__, current_buffer_state, updated_buffer_state);
- if (!BufferHubDefs::IsClientGained(current_buffer_state,
+ if (!BufferHubDefs::isClientGained(current_buffer_state,
client_state_mask())) {
ALOGE(
"%s: Failed to post the buffer. The buffer is no longer gained, "
@@ -166,14 +166,14 @@
ALOGD_IF(TRACE, "%s: buffer=%d, state=%" PRIx32 ".", __FUNCTION__, id(),
current_buffer_state);
- if (BufferHubDefs::IsClientGained(current_buffer_state,
+ if (BufferHubDefs::isClientGained(current_buffer_state,
client_state_mask())) {
ALOGV("%s: already gained id=%d.", __FUNCTION__, id());
return 0;
}
- if (BufferHubDefs::AnyClientAcquired(current_buffer_state) ||
- BufferHubDefs::AnyClientGained(current_buffer_state) ||
- (BufferHubDefs::AnyClientPosted(
+ if (BufferHubDefs::isAnyClientAcquired(current_buffer_state) ||
+ BufferHubDefs::isAnyClientGained(current_buffer_state) ||
+ (BufferHubDefs::isAnyClientPosted(
current_buffer_state &
active_clients_bit_mask_->load(std::memory_order_acquire)) &&
!gain_posted_buffer)) {
@@ -195,9 +195,9 @@
"clients.",
__FUNCTION__, current_buffer_state, updated_buffer_state);
- if (BufferHubDefs::AnyClientAcquired(current_buffer_state) ||
- BufferHubDefs::AnyClientGained(current_buffer_state) ||
- (BufferHubDefs::AnyClientPosted(
+ if (BufferHubDefs::isAnyClientAcquired(current_buffer_state) ||
+ BufferHubDefs::isAnyClientGained(current_buffer_state) ||
+ (BufferHubDefs::isAnyClientPosted(
current_buffer_state &
active_clients_bit_mask_->load(std::memory_order_acquire)) &&
!gain_posted_buffer)) {
@@ -291,7 +291,7 @@
// TODO(b/112338294) Keep here for reference. Remove it after new logic is
// written.
/* uint32_t buffer_state = buffer_state_->load(std::memory_order_acquire);
- if (!BufferHubDefs::IsClientGained(
+ if (!BufferHubDefs::isClientGained(
buffer_state, BufferHubDefs::kFirstClientStateMask)) {
// Can only detach a ProducerBuffer when it's in gained state.
ALOGW("ProducerBuffer::Detach: The buffer (id=%d, state=0x%" PRIx32
diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
index d7833f3..2d3fa4a 100644
--- a/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
+++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
@@ -532,7 +532,7 @@
Status<size_t> ProducerQueue::InsertBuffer(
const std::shared_ptr<ProducerBuffer>& buffer) {
if (buffer == nullptr ||
- !BufferHubDefs::IsClientGained(buffer->buffer_state(),
+ !BufferHubDefs::isClientGained(buffer->buffer_state(),
buffer->client_state_mask())) {
ALOGE(
"ProducerQueue::InsertBuffer: Can only insert a buffer when it's in "
@@ -638,7 +638,7 @@
static_cast<int>(*slot));
return ErrorStatus(EIO);
}
- if (!BufferHubDefs::AnyClientAcquired(buffer->buffer_state())) {
+ if (!BufferHubDefs::isAnyClientAcquired(buffer->buffer_state())) {
*slot = *iter;
unavailable_buffers_slot_.erase(iter);
unavailable_buffers_slot_.push_back(*slot);
diff --git a/opengl/libagl/Android.bp b/opengl/libagl/Android.bp
new file mode 100644
index 0000000..6ec24b3
--- /dev/null
+++ b/opengl/libagl/Android.bp
@@ -0,0 +1,99 @@
+//
+// Build the software OpenGL ES library
+//
+
+cc_defaults {
+ name: "libGLES_android_defaults",
+
+ cflags: [
+ "-DLOG_TAG=\"libagl\"",
+ "-DGL_GLEXT_PROTOTYPES",
+ "-DEGL_EGLEXT_PROTOTYPES",
+ "-fvisibility=hidden",
+ "-Wall",
+ "-Werror",
+ ],
+
+ shared_libs: [
+ "libcutils",
+ "libhardware",
+ "libutils",
+ "liblog",
+ "libpixelflinger",
+ "libETC1",
+ "libui",
+ "libnativewindow",
+ ],
+
+ // we need to access the private Bionic header <bionic_tls.h>
+ include_dirs: ["bionic/libc/private"],
+
+ arch: {
+ arm: {
+ cflags: ["-fstrict-aliasing"],
+ },
+
+ mips: {
+ cflags: [
+ "-fstrict-aliasing",
+ // The graphics code can generate division by zero
+ "-mno-check-zero-division",
+ ],
+ },
+ },
+}
+
+cc_library_shared {
+ name: "libGLES_android",
+ defaults: ["libGLES_android_defaults"],
+
+ whole_static_libs: ["libGLES_android_arm"],
+
+ srcs: [
+ "egl.cpp",
+ "state.cpp",
+ "texture.cpp",
+ "Tokenizer.cpp",
+ "TokenManager.cpp",
+ "TextureObjectManager.cpp",
+ "BufferObjectManager.cpp",
+ ],
+
+ arch: {
+ arm: {
+ srcs: [
+ "fixed_asm.S",
+ "iterators.S",
+ ],
+ },
+
+ mips: {
+ rev6: {
+ srcs: ["arch-mips/fixed_asm.S"],
+ },
+ },
+ },
+
+ relative_install_path: "egl",
+}
+
+cc_library_static {
+ name: "libGLES_android_arm",
+ defaults: ["libGLES_android_defaults"],
+
+ srcs: [
+ "array.cpp",
+ "fp.cpp",
+ "light.cpp",
+ "matrix.cpp",
+ "mipmap.cpp",
+ "primitives.cpp",
+ "vertex.cpp",
+ ],
+
+ arch: {
+ arm: {
+ instruction_set: "arm",
+ },
+ },
+}
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
deleted file mode 100644
index 15a12e4..0000000
--- a/opengl/libagl/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#
-# Build the software OpenGL ES library
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- egl.cpp \
- state.cpp \
- texture.cpp \
- Tokenizer.cpp \
- TokenManager.cpp \
- TextureObjectManager.cpp \
- BufferObjectManager.cpp \
- array.cpp.arm \
- fp.cpp.arm \
- light.cpp.arm \
- matrix.cpp.arm \
- mipmap.cpp.arm \
- primitives.cpp.arm \
- vertex.cpp.arm
-
-LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
-LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-LOCAL_CFLAGS += -fvisibility=hidden
-
-LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils liblog libpixelflinger libETC1 libui libnativewindow
-
-LOCAL_SRC_FILES_arm += fixed_asm.S iterators.S
-LOCAL_CFLAGS_arm += -fstrict-aliasing
-
-ifndef ARCH_MIPS_REV6
-LOCAL_SRC_FILES_mips += arch-mips/fixed_asm.S
-endif
-LOCAL_CFLAGS_mips += -fstrict-aliasing
-# The graphics code can generate division by zero
-LOCAL_CFLAGS_mips += -mno-check-zero-division
-
-LOCAL_CFLAGS += -Wall -Werror
-
-# we need to access the private Bionic header <bionic_tls.h>
-LOCAL_C_INCLUDES += bionic/libc/private
-
-LOCAL_MODULE_RELATIVE_PATH := egl
-LOCAL_MODULE:= libGLES_android
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/services/bufferhub/BufferHubService.cpp b/services/bufferhub/BufferHubService.cpp
index 6b802fb..90ac1c2 100644
--- a/services/bufferhub/BufferHubService.cpp
+++ b/services/bufferhub/BufferHubService.cpp
@@ -53,7 +53,7 @@
std::make_shared<BufferNode>(desc.width, desc.height, desc.layers, desc.format,
desc.usage, userMetadataSize,
BufferHubIdGenerator::getInstance().getId());
- if (node == nullptr || !node->IsValid()) {
+ if (node == nullptr || !node->isValid()) {
ALOGE("%s: creating BufferNode failed.", __FUNCTION__);
_hidl_cb(/*status=*/BufferHubStatus::ALLOCATION_FAILED, /*bufferClient=*/nullptr,
/*bufferTraits=*/{});
@@ -70,11 +70,11 @@
NATIVE_HANDLE_DECLARE_STORAGE(bufferInfoStorage, BufferHubDefs::kBufferInfoNumFds,
BufferHubDefs::kBufferInfoNumInts);
hidl_handle bufferInfo =
- buildBufferInfo(bufferInfoStorage, node->id(), node->AddNewActiveClientsBitToMask(),
- node->user_metadata_size(), node->metadata().ashmem_fd(),
+ buildBufferInfo(bufferInfoStorage, node->id(), node->addNewActiveClientsBitToMask(),
+ node->userMetadataSize(), node->metadata().ashmemFd(),
node->eventFd().get());
BufferTraits bufferTraits = {/*bufferDesc=*/description,
- /*bufferHandle=*/hidl_handle(node->buffer_handle()),
+ /*bufferHandle=*/hidl_handle(node->bufferHandle()),
/*bufferInfo=*/std::move(bufferInfo)};
_hidl_cb(/*status=*/BufferHubStatus::NO_ERROR, /*bufferClient=*/client,
@@ -141,7 +141,7 @@
}
sp<BufferClient> client = new BufferClient(*originClient);
- uint32_t clientStateMask = client->getBufferNode()->AddNewActiveClientsBitToMask();
+ uint32_t clientStateMask = client->getBufferNode()->addNewActiveClientsBitToMask();
if (clientStateMask == 0U) {
// Reach max client count
ALOGE("%s: import failed, BufferNode#%u reached maximum clients.", __FUNCTION__,
@@ -157,17 +157,17 @@
std::shared_ptr<BufferNode> node = client->getBufferNode();
HardwareBufferDescription bufferDesc;
- memcpy(&bufferDesc, &node->buffer_desc(), sizeof(HardwareBufferDescription));
+ memcpy(&bufferDesc, &node->bufferDesc(), sizeof(HardwareBufferDescription));
// Allocate memory for bufferInfo of type hidl_handle on the stack. See
// http://aosp/286282 for the usage of NATIVE_HANDLE_DECLARE_STORAGE.
NATIVE_HANDLE_DECLARE_STORAGE(bufferInfoStorage, BufferHubDefs::kBufferInfoNumFds,
BufferHubDefs::kBufferInfoNumInts);
hidl_handle bufferInfo = buildBufferInfo(bufferInfoStorage, node->id(), clientStateMask,
- node->user_metadata_size(),
- node->metadata().ashmem_fd(), node->eventFd().get());
+ node->userMetadataSize(), node->metadata().ashmemFd(),
+ node->eventFd().get());
BufferTraits bufferTraits = {/*bufferDesc=*/bufferDesc,
- /*bufferHandle=*/hidl_handle(node->buffer_handle()),
+ /*bufferHandle=*/hidl_handle(node->bufferHandle()),
/*bufferInfo=*/std::move(bufferInfo)};
_hidl_cb(/*status=*/BufferHubStatus::NO_ERROR, /*bufferClient=*/client,
@@ -231,10 +231,10 @@
for (auto iter = clientCount.begin(); iter != clientCount.end(); ++iter) {
const std::shared_ptr<BufferNode> node = std::move(iter->second.first);
const uint32_t clientCount = iter->second.second;
- AHardwareBuffer_Desc desc = node->buffer_desc();
+ AHardwareBuffer_Desc desc = node->bufferDesc();
MetadataHeader* metadataHeader =
- const_cast<BufferHubMetadata*>(&node->metadata())->metadata_header();
+ const_cast<BufferHubMetadata*>(&node->metadata())->metadataHeader();
const uint32_t state = metadataHeader->buffer_state.load(std::memory_order_acquire);
const uint64_t index = metadataHeader->queue_index;
diff --git a/services/bufferhub/BufferNode.cpp b/services/bufferhub/BufferNode.cpp
index 5106390..4f877b2 100644
--- a/services/bufferhub/BufferNode.cpp
+++ b/services/bufferhub/BufferNode.cpp
@@ -11,20 +11,19 @@
namespace V1_0 {
namespace implementation {
-void BufferNode::InitializeMetadata() {
+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.metadataHeader();
+ 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,35 +37,35 @@
// 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;
}
- InitializeMetadata();
+ initializeMetadata();
}
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);
}
@@ -78,33 +77,33 @@
}
}
-uint32_t BufferNode::GetActiveClientsBitMask() const {
- return active_clients_bit_mask_->load(std::memory_order_acquire);
+uint32_t BufferNode::getActiveClientsBitMask() const {
+ return mActiveClientsBitMask->load(std::memory_order_acquire);
}
-uint32_t BufferNode::AddNewActiveClientsBitToMask() {
- uint32_t current_active_clients_bit_mask = GetActiveClientsBitMask();
+uint32_t BufferNode::addNewActiveClientsBitToMask() {
+ 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);
+void BufferNode::removeClientsBitFromMask(const uint32_t& 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..04970fd 100644
--- a/services/bufferhub/include/bufferhub/BufferNode.h
+++ b/services/bufferhub/include/bufferhub/BufferNode.h
@@ -22,73 +22,73 @@
~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 userMetadataSize() const { return mMetadata.userMetadataSize(); }
// 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* bufferHandle() const { return mBufferHandle; }
+ const AHardwareBuffer_Desc& bufferDesc() 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.
- uint32_t GetActiveClientsBitMask() const;
+ // 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();
+ 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);
+ void removeClientsBitFromMask(const uint32_t& value);
private:
// Helper method for constructors to initialize atomic metadata header
// variables in shared memory.
- void InitializeMetadata();
+ 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
diff --git a/services/bufferhub/tests/BufferNode_test.cpp b/services/bufferhub/tests/BufferNode_test.cpp
index ccb1197..b9f1c81 100644
--- a/services/bufferhub/tests/BufferNode_test.cpp
+++ b/services/bufferhub/tests/BufferNode_test.cpp
@@ -28,7 +28,7 @@
void SetUp() override {
buffer_node =
new BufferNode(kWidth, kHeight, kLayerCount, kFormat, kUsage, kUserMetadataSize);
- ASSERT_TRUE(buffer_node->IsValid());
+ ASSERT_TRUE(buffer_node->isValid());
}
void TearDown() override {
@@ -41,65 +41,64 @@
};
TEST_F(BufferNodeTest, TestCreateBufferNode) {
- EXPECT_EQ(buffer_node->user_metadata_size(), kUserMetadataSize);
+ EXPECT_EQ(buffer_node->userMetadataSize(), kUserMetadataSize);
// Test the handle just allocated is good (i.e. able to be imported)
GraphicBufferMapper& mapper = GraphicBufferMapper::get();
const native_handle_t* outHandle;
status_t ret =
- mapper.importBuffer(buffer_node->buffer_handle(), buffer_node->buffer_desc().width,
- buffer_node->buffer_desc().height,
- buffer_node->buffer_desc().layers,
- buffer_node->buffer_desc().format, buffer_node->buffer_desc().usage,
- buffer_node->buffer_desc().stride, &outHandle);
+ mapper.importBuffer(buffer_node->bufferHandle(), buffer_node->bufferDesc().width,
+ buffer_node->bufferDesc().height, buffer_node->bufferDesc().layers,
+ buffer_node->bufferDesc().format, buffer_node->bufferDesc().usage,
+ buffer_node->bufferDesc().stride, &outHandle);
EXPECT_EQ(ret, OK);
EXPECT_THAT(outHandle, NotNull());
}
-TEST_F(BufferNodeTest, TestAddNewActiveClientsBitToMask_twoNewClients) {
- uint32_t new_client_state_mask_1 = buffer_node->AddNewActiveClientsBitToMask();
- EXPECT_EQ(buffer_node->GetActiveClientsBitMask(), new_client_state_mask_1);
+TEST_F(BufferNodeTest, TestaddNewActiveClientsBitToMask_twoNewClients) {
+ uint32_t new_client_state_mask_1 = buffer_node->addNewActiveClientsBitToMask();
+ EXPECT_EQ(buffer_node->getActiveClientsBitMask(), new_client_state_mask_1);
// Request and add a new client_state_mask again.
// Active clients bit mask should be the union of the two new
// client_state_masks.
- uint32_t new_client_state_mask_2 = buffer_node->AddNewActiveClientsBitToMask();
- EXPECT_EQ(buffer_node->GetActiveClientsBitMask(),
+ uint32_t new_client_state_mask_2 = buffer_node->addNewActiveClientsBitToMask();
+ EXPECT_EQ(buffer_node->getActiveClientsBitMask(),
new_client_state_mask_1 | new_client_state_mask_2);
}
-TEST_F(BufferNodeTest, TestAddNewActiveClientsBitToMask_32NewClients) {
+TEST_F(BufferNodeTest, TestaddNewActiveClientsBitToMask_32NewClients) {
uint32_t new_client_state_mask = 0U;
uint32_t current_mask = 0U;
uint32_t expected_mask = 0U;
for (int i = 0; i < BufferHubDefs::kMaxNumberOfClients; ++i) {
- new_client_state_mask = buffer_node->AddNewActiveClientsBitToMask();
+ new_client_state_mask = buffer_node->addNewActiveClientsBitToMask();
EXPECT_NE(new_client_state_mask, 0U);
EXPECT_FALSE(new_client_state_mask & current_mask);
expected_mask = current_mask | new_client_state_mask;
- current_mask = buffer_node->GetActiveClientsBitMask();
+ current_mask = buffer_node->getActiveClientsBitMask();
EXPECT_EQ(current_mask, expected_mask);
}
// Method should fail upon requesting for more than maximum allowable clients.
- new_client_state_mask = buffer_node->AddNewActiveClientsBitToMask();
+ new_client_state_mask = buffer_node->addNewActiveClientsBitToMask();
EXPECT_EQ(new_client_state_mask, 0U);
EXPECT_EQ(errno, E2BIG);
}
TEST_F(BufferNodeTest, TestRemoveActiveClientsBitFromMask) {
- buffer_node->AddNewActiveClientsBitToMask();
- uint32_t current_mask = buffer_node->GetActiveClientsBitMask();
- uint32_t new_client_state_mask = buffer_node->AddNewActiveClientsBitToMask();
- EXPECT_NE(buffer_node->GetActiveClientsBitMask(), current_mask);
+ buffer_node->addNewActiveClientsBitToMask();
+ uint32_t current_mask = buffer_node->getActiveClientsBitMask();
+ uint32_t new_client_state_mask = buffer_node->addNewActiveClientsBitToMask();
+ EXPECT_NE(buffer_node->getActiveClientsBitMask(), current_mask);
- buffer_node->RemoveClientsBitFromMask(new_client_state_mask);
- EXPECT_EQ(buffer_node->GetActiveClientsBitMask(), current_mask);
+ buffer_node->removeClientsBitFromMask(new_client_state_mask);
+ EXPECT_EQ(buffer_node->getActiveClientsBitMask(), current_mask);
// Remove the test_mask again to the active client bit mask should not modify
// the value of active clients bit mask.
- buffer_node->RemoveClientsBitFromMask(new_client_state_mask);
- EXPECT_EQ(buffer_node->GetActiveClientsBitMask(), current_mask);
+ buffer_node->removeClientsBitFromMask(new_client_state_mask);
+ EXPECT_EQ(buffer_node->getActiveClientsBitMask(), current_mask);
}
} // namespace
diff --git a/services/inputflinger/BlockingQueue.h b/services/inputflinger/BlockingQueue.h
index b892120..c9eb683 100644
--- a/services/inputflinger/BlockingQueue.h
+++ b/services/inputflinger/BlockingQueue.h
@@ -80,6 +80,16 @@
mQueue.clear();
};
+ /**
+ * How many elements are currently stored in the queue.
+ * Primary used for debugging.
+ * Does not block.
+ */
+ size_t size() {
+ std::scoped_lock lock(mLock);
+ return mQueue.size();
+ }
+
private:
size_t mCapacity;
/**
diff --git a/services/inputflinger/InputClassifier.cpp b/services/inputflinger/InputClassifier.cpp
index 7ade0d4..09a004c 100644
--- a/services/inputflinger/InputClassifier.cpp
+++ b/services/inputflinger/InputClassifier.cpp
@@ -19,6 +19,7 @@
#include "InputClassifier.h"
#include <algorithm>
+#include <android-base/stringprintf.h>
#include <cmath>
#include <inttypes.h>
#include <log/log.h>
@@ -26,9 +27,17 @@
#include <pthread.h>
#endif
#include <server_configurable_flags/get_flags.h>
+#include <unordered_set>
#include <android/hardware/input/classifier/1.0/IInputClassifier.h>
+#define INDENT1 " "
+#define INDENT2 " "
+#define INDENT3 " "
+#define INDENT4 " "
+#define INDENT5 " "
+
+using android::base::StringPrintf;
using android::hardware::hidl_bitfield;
using android::hardware::hidl_vec;
using namespace android::hardware::input;
@@ -646,6 +655,30 @@
mEvents.push(std::make_unique<NotifyDeviceResetArgs>(args));
}
+void MotionClassifier::dump(std::string& dump) {
+ std::scoped_lock lock(mLock);
+ std::string serviceStatus = mService->ping().isOk() ? "running" : " not responding";
+ dump += StringPrintf(INDENT2 "mService status: %s\n", serviceStatus.c_str());
+ dump += StringPrintf(INDENT2 "mEvents: %zu element(s) (max=%zu)\n",
+ mEvents.size(), MAX_EVENTS);
+ dump += INDENT2 "mClassifications, mLastDownTimes:\n";
+ dump += INDENT3 "Device Id\tClassification\tLast down time";
+ // Combine mClassifications and mLastDownTimes into a single table.
+ // Create a superset of device ids.
+ std::unordered_set<int32_t> deviceIds;
+ std::for_each(mClassifications.begin(), mClassifications.end(),
+ [&deviceIds](auto pair){ deviceIds.insert(pair.first); });
+ std::for_each(mLastDownTimes.begin(), mLastDownTimes.end(),
+ [&deviceIds](auto pair){ deviceIds.insert(pair.first); });
+ for(int32_t deviceId : deviceIds) {
+ const MotionClassification classification =
+ getValueForKey(mClassifications, deviceId, MotionClassification::NONE);
+ const nsecs_t downTime = getValueForKey(mLastDownTimes, deviceId, static_cast<nsecs_t>(0));
+ dump += StringPrintf("\n" INDENT4 "%" PRId32 "\t%s\t%" PRId64,
+ deviceId, motionClassificationToString(classification), downTime);
+ }
+}
+
// --- InputClassifier ---
InputClassifier::InputClassifier(const sp<InputListenerInterface>& listener) :
@@ -694,4 +727,16 @@
mListener->notifyDeviceReset(args);
}
+void InputClassifier::dump(std::string& dump) {
+ dump += "Input Classifier State:\n";
+
+ dump += INDENT1 "Motion Classifier:\n";
+ if (mMotionClassifier) {
+ mMotionClassifier->dump(dump);
+ } else {
+ dump += INDENT2 "<nullptr>";
+ }
+ dump += "\n";
+}
+
} // namespace android
\ No newline at end of file
diff --git a/services/inputflinger/InputClassifier.h b/services/inputflinger/InputClassifier.h
index cb46494..4b9dae2 100644
--- a/services/inputflinger/InputClassifier.h
+++ b/services/inputflinger/InputClassifier.h
@@ -70,6 +70,11 @@
virtual MotionClassification classify(const NotifyMotionArgs& args) = 0;
virtual void reset() = 0;
virtual void reset(const NotifyDeviceResetArgs& args) = 0;
+
+ /**
+ * Dump the state of the motion classifier
+ */
+ virtual void dump(std::string& dump) = 0;
};
/**
@@ -77,6 +82,12 @@
* Provides classification to events.
*/
class InputClassifierInterface : public virtual RefBase, public InputListenerInterface {
+public:
+ /**
+ * Dump the state of the input classifier.
+ * This method may be called on any thread (usually by the input manager).
+ */
+ virtual void dump(std::string& dump) = 0;
protected:
InputClassifierInterface() { }
virtual ~InputClassifierInterface() { }
@@ -110,6 +121,8 @@
virtual void reset() override;
virtual void reset(const NotifyDeviceResetArgs& args) override;
+ virtual void dump(std::string& dump) override;
+
private:
// The events that need to be sent to the HAL.
BlockingQueue<ClassifierEvent> mEvents;
@@ -186,6 +199,8 @@
virtual void notifySwitch(const NotifySwitchArgs* args) override;
virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) override;
+ virtual void dump(std::string& dump) override;
+
private:
std::unique_ptr<MotionClassifierInterface> mMotionClassifier = nullptr;
// The next stage to pass input events to
diff --git a/services/inputflinger/InputListener.cpp b/services/inputflinger/InputListener.cpp
index e537e09..a403f31 100644
--- a/services/inputflinger/InputListener.cpp
+++ b/services/inputflinger/InputListener.cpp
@@ -28,12 +28,12 @@
NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(
uint32_t sequenceNum, nsecs_t eventTime) :
- NotifyArgs(sequenceNum), eventTime(eventTime) {
+ NotifyArgs(sequenceNum, eventTime) {
}
NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(
const NotifyConfigurationChangedArgs& other) :
- NotifyArgs(other.sequenceNum), eventTime(other.eventTime) {
+ NotifyArgs(other.sequenceNum, other.eventTime) {
}
bool NotifyConfigurationChangedArgs::operator==(const NotifyConfigurationChangedArgs& rhs) const {
@@ -51,14 +51,14 @@
uint32_t source, int32_t displayId, uint32_t policyFlags,
int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode,
int32_t metaState, nsecs_t downTime) :
- NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId), source(source),
+ NotifyArgs(sequenceNum, eventTime), deviceId(deviceId), source(source),
displayId(displayId), policyFlags(policyFlags),
action(action), flags(flags), keyCode(keyCode), scanCode(scanCode),
metaState(metaState), downTime(downTime) {
}
NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other) :
- NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId),
+ NotifyArgs(other.sequenceNum, other.eventTime), deviceId(other.deviceId),
source(other.source), displayId(other.displayId), policyFlags(other.policyFlags),
action(other.action), flags(other.flags),
keyCode(other.keyCode), scanCode(other.scanCode),
@@ -95,7 +95,7 @@
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
float xPrecision, float yPrecision, nsecs_t downTime,
const std::vector<TouchVideoFrame>& videoFrames) :
- NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId), source(source),
+ NotifyArgs(sequenceNum, eventTime), deviceId(deviceId), source(source),
displayId(displayId), policyFlags(policyFlags),
action(action), actionButton(actionButton),
flags(flags), metaState(metaState), buttonState(buttonState),
@@ -110,7 +110,7 @@
}
NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) :
- NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId),
+ NotifyArgs(other.sequenceNum, other.eventTime), deviceId(other.deviceId),
source(other.source), displayId(other.displayId), policyFlags(other.policyFlags),
action(other.action), actionButton(other.actionButton), flags(other.flags),
metaState(other.metaState), buttonState(other.buttonState),
@@ -170,12 +170,12 @@
NotifySwitchArgs::NotifySwitchArgs(uint32_t sequenceNum, nsecs_t eventTime, uint32_t policyFlags,
uint32_t switchValues, uint32_t switchMask) :
- NotifyArgs(sequenceNum), eventTime(eventTime), policyFlags(policyFlags),
+ NotifyArgs(sequenceNum, eventTime), policyFlags(policyFlags),
switchValues(switchValues), switchMask(switchMask) {
}
NotifySwitchArgs::NotifySwitchArgs(const NotifySwitchArgs& other) :
- NotifyArgs(other.sequenceNum), eventTime(other.eventTime), policyFlags(other.policyFlags),
+ NotifyArgs(other.sequenceNum, other.eventTime), policyFlags(other.policyFlags),
switchValues(other.switchValues), switchMask(other.switchMask) {
}
@@ -196,11 +196,11 @@
NotifyDeviceResetArgs::NotifyDeviceResetArgs(
uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId) :
- NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId) {
+ NotifyArgs(sequenceNum, eventTime), deviceId(deviceId) {
}
NotifyDeviceResetArgs::NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) :
- NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId) {
+ NotifyArgs(other.sequenceNum, other.eventTime), deviceId(other.deviceId) {
}
bool NotifyDeviceResetArgs::operator==(const NotifyDeviceResetArgs& rhs) const {
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
index b3b9e3e..a7fd9ba 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -84,6 +84,10 @@
return mReader;
}
+sp<InputClassifierInterface> InputManager::getClassifier() {
+ return mClassifier;
+}
+
sp<InputDispatcherInterface> InputManager::getDispatcher() {
return mDispatcher;
}
diff --git a/services/inputflinger/InputManager.h b/services/inputflinger/InputManager.h
index 142ec0c..e632da3 100644
--- a/services/inputflinger/InputManager.h
+++ b/services/inputflinger/InputManager.h
@@ -90,6 +90,7 @@
virtual status_t stop();
virtual sp<InputReaderInterface> getReader();
+ virtual sp<InputClassifierInterface> getClassifier();
virtual sp<InputDispatcherInterface> getDispatcher();
virtual void setInputWindows(const Vector<InputWindowInfo>& handles);
diff --git a/services/inputflinger/include/TouchVideoDevice.h b/services/inputflinger/TouchVideoDevice.h
similarity index 96%
rename from services/inputflinger/include/TouchVideoDevice.h
rename to services/inputflinger/TouchVideoDevice.h
index 7ff2653..3d5c8c6 100644
--- a/services/inputflinger/include/TouchVideoDevice.h
+++ b/services/inputflinger/TouchVideoDevice.h
@@ -73,6 +73,8 @@
size_t readAndQueueFrames();
/**
* Return all of the queued frames, and erase them from the local buffer.
+ * The returned frames are in the order that they were received from the
+ * v4l2 device, with the oldest frame at the index 0.
*/
std::vector<TouchVideoFrame> consumeFrames();
/**
diff --git a/services/inputflinger/include/InputListener.h b/services/inputflinger/include/InputListener.h
index 13ae7dd..cd8caf7 100644
--- a/services/inputflinger/include/InputListener.h
+++ b/services/inputflinger/include/InputListener.h
@@ -32,10 +32,12 @@
/* Superclass of all input event argument objects */
struct NotifyArgs {
uint32_t sequenceNum;
+ nsecs_t eventTime;
- inline NotifyArgs() : sequenceNum(0) { }
+ inline NotifyArgs() : sequenceNum(0), eventTime(0) { }
- inline explicit NotifyArgs(uint32_t sequenceNum) : sequenceNum(sequenceNum) { }
+ inline explicit NotifyArgs(uint32_t sequenceNum, nsecs_t eventTime) :
+ sequenceNum(sequenceNum), eventTime(eventTime) { }
virtual ~NotifyArgs() { }
@@ -45,7 +47,6 @@
/* Describes a configuration change event. */
struct NotifyConfigurationChangedArgs : public NotifyArgs {
- nsecs_t eventTime;
inline NotifyConfigurationChangedArgs() { }
@@ -63,7 +64,6 @@
/* Describes a key event. */
struct NotifyKeyArgs : public NotifyArgs {
- nsecs_t eventTime;
int32_t deviceId;
uint32_t source;
int32_t displayId;
@@ -93,7 +93,6 @@
/* Describes a motion event. */
struct NotifyMotionArgs : public NotifyArgs {
- nsecs_t eventTime;
int32_t deviceId;
uint32_t source;
int32_t displayId;
@@ -146,7 +145,6 @@
/* Describes a switch event. */
struct NotifySwitchArgs : public NotifyArgs {
- nsecs_t eventTime;
uint32_t policyFlags;
uint32_t switchValues;
uint32_t switchMask;
@@ -169,7 +167,6 @@
/* Describes a device reset event, such as when a device is added,
* reconfigured, or removed. */
struct NotifyDeviceResetArgs : public NotifyArgs {
- nsecs_t eventTime;
int32_t deviceId;
inline NotifyDeviceResetArgs() { }
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 5f6d2a7..46e587d 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -681,7 +681,7 @@
}
// This gives us only the "orientation" component of the transform
- const State& s(getCurrentState());
+ const State& s(getDrawingState());
// Apply the layer's transform, followed by the display's global transform
// Here we're guaranteed that the layer's transform preserves rects
diff --git a/services/surfaceflinger/OWNERS b/services/surfaceflinger/OWNERS
index dc2b300..ce0611c 100644
--- a/services/surfaceflinger/OWNERS
+++ b/services/surfaceflinger/OWNERS
@@ -1,3 +1,4 @@
+akrulec@google.com
chaviw@google.com
lpy@google.com
marissaw@google.com
diff --git a/services/surfaceflinger/TimeStats/OWNERS b/services/surfaceflinger/TimeStats/OWNERS
new file mode 100644
index 0000000..ac02d12
--- /dev/null
+++ b/services/surfaceflinger/TimeStats/OWNERS
@@ -0,0 +1 @@
+zzyiwei@google.com
\ No newline at end of file
diff --git a/services/vr/bufferhubd/producer_channel.cpp b/services/vr/bufferhubd/producer_channel.cpp
index 164d9e6..f3e54a0 100644
--- a/services/vr/bufferhubd/producer_channel.cpp
+++ b/services/vr/bufferhubd/producer_channel.cpp
@@ -253,7 +253,7 @@
uint32_t current_active_clients_bit_mask =
active_clients_bit_mask_->load(std::memory_order_acquire);
uint32_t consumer_state_mask =
- BufferHubDefs::FindNextAvailableClientStateMask(
+ BufferHubDefs::findNextAvailableClientStateMask(
current_active_clients_bit_mask | orphaned_consumer_bit_mask_);
if (consumer_state_mask == 0U) {
ALOGE("%s: reached the maximum mumber of consumers per producer: 63.",
@@ -279,7 +279,7 @@
"condition.",
__FUNCTION__, updated_active_clients_bit_mask,
current_active_clients_bit_mask);
- consumer_state_mask = BufferHubDefs::FindNextAvailableClientStateMask(
+ consumer_state_mask = BufferHubDefs::findNextAvailableClientStateMask(
current_active_clients_bit_mask | orphaned_consumer_bit_mask_);
if (consumer_state_mask == 0U) {
ALOGE("%s: reached the maximum mumber of consumers per producer: %d.",
@@ -337,13 +337,13 @@
// consumer to a buffer that is available to producer (a.k.a a fully-released
// buffer) or a gained buffer.
if (current_buffer_state == 0U ||
- BufferHubDefs::AnyClientGained(current_buffer_state)) {
+ BufferHubDefs::isAnyClientGained(current_buffer_state)) {
return {status.take()};
}
// Signal the new consumer when adding it to a posted producer.
bool update_buffer_state = true;
- if (!BufferHubDefs::IsClientPosted(current_buffer_state,
+ if (!BufferHubDefs::isClientPosted(current_buffer_state,
consumer_state_mask)) {
uint32_t updated_buffer_state =
current_buffer_state ^
@@ -360,7 +360,7 @@
"released.",
__FUNCTION__, current_buffer_state, updated_buffer_state);
if (current_buffer_state == 0U ||
- BufferHubDefs::AnyClientGained(current_buffer_state)) {
+ BufferHubDefs::isAnyClientGained(current_buffer_state)) {
ALOGI("%s: buffer is gained or fully released, state=%" PRIx32 ".",
__FUNCTION__, current_buffer_state);
update_buffer_state = false;
@@ -371,7 +371,7 @@
(consumer_state_mask & BufferHubDefs::kHighBitsMask);
}
}
- if (update_buffer_state || BufferHubDefs::IsClientPosted(
+ if (update_buffer_state || BufferHubDefs::isClientPosted(
buffer_state_->load(std::memory_order_acquire),
consumer_state_mask)) {
consumer->OnProducerPosted();
@@ -457,7 +457,7 @@
buffer_id());
uint32_t buffer_state = buffer_state_->load(std::memory_order_acquire);
- if (!BufferHubDefs::IsClientGained(
+ if (!BufferHubDefs::isClientGained(
buffer_state, BufferHubDefs::kFirstClientStateMask)) {
// Can only detach a ProducerBuffer when it's in gained state.
ALOGW(
@@ -616,9 +616,9 @@
const uint32_t current_buffer_state =
buffer_state_->load(std::memory_order_acquire);
- if (BufferHubDefs::IsClientPosted(current_buffer_state,
+ if (BufferHubDefs::isClientPosted(current_buffer_state,
consumer_state_mask) ||
- BufferHubDefs::IsClientAcquired(current_buffer_state,
+ BufferHubDefs::isClientAcquired(current_buffer_state,
consumer_state_mask)) {
// The consumer client is being destoryed without releasing. This could
// happen in corner cases when the consumer crashes. Here we mark it
@@ -627,9 +627,9 @@
return;
}
- if (BufferHubDefs::IsClientReleased(current_buffer_state,
+ if (BufferHubDefs::isClientReleased(current_buffer_state,
consumer_state_mask) ||
- BufferHubDefs::AnyClientGained(current_buffer_state)) {
+ BufferHubDefs::isAnyClientGained(current_buffer_state)) {
// The consumer is being close while it is suppose to signal a release
// fence. Signal the dummy fence here.
if (fence_state_->load(std::memory_order_acquire) & consumer_state_mask) {
diff --git a/services/vr/bufferhubd/producer_queue_channel.cpp b/services/vr/bufferhubd/producer_queue_channel.cpp
index 6b33f50..004dc7c 100644
--- a/services/vr/bufferhubd/producer_queue_channel.cpp
+++ b/services/vr/bufferhubd/producer_queue_channel.cpp
@@ -323,7 +323,7 @@
// memory to indicate which client is the last producer of the buffer.
// Currently, the first client is the only producer to the buffer.
// Thus, it checks whether the first client gains the buffer below.
- if (!BufferHubDefs::IsClientGained(buffer_state,
+ if (!BufferHubDefs::isClientGained(buffer_state,
BufferHubDefs::kFirstClientBitMask)) {
// Rejects the request if the requested buffer is not in Gained state.
ALOGE(