diff options
| -rw-r--r-- | libs/ui/BufferHubBuffer.cpp | 4 | ||||
| -rw-r--r-- | libs/ui/BufferHubMetadata.cpp | 5 | ||||
| -rw-r--r-- | libs/ui/include/ui/BufferHubDefs.h | 162 | ||||
| -rw-r--r-- | libs/ui/include/ui/BufferHubMetadata.h | 30 | ||||
| -rw-r--r-- | libs/ui/tests/Android.bp | 3 | ||||
| -rw-r--r-- | libs/ui/tests/BufferHubMetadata_test.cpp | 2 | ||||
| -rw-r--r-- | libs/vr/libbufferhub/include/private/dvr/buffer_hub_defs.h | 124 | ||||
| -rw-r--r-- | libs/vr/libdvr/include/dvr/dvr_api.h | 1 | ||||
| -rw-r--r-- | services/bufferhub/Android.bp | 4 | ||||
| -rw-r--r-- | services/bufferhub/BufferClient.cpp | 1 | ||||
| -rw-r--r-- | services/bufferhub/BufferNode.cpp | 10 | ||||
| -rw-r--r-- | services/bufferhub/include/bufferhub/BufferNode.h | 1 | ||||
| -rw-r--r-- | services/bufferhub/tests/Android.bp | 4 | ||||
| -rw-r--r-- | services/bufferhub/tests/BufferNode_test.cpp | 7 |
14 files changed, 207 insertions, 151 deletions
diff --git a/libs/ui/BufferHubBuffer.cpp b/libs/ui/BufferHubBuffer.cpp index 3816c1bc4f..36eaed93ad 100644 --- a/libs/ui/BufferHubBuffer.cpp +++ b/libs/ui/BufferHubBuffer.cpp @@ -40,6 +40,7 @@ #include <android-base/unique_fd.h> #include <ui/BufferHubBuffer.h> +#include <ui/BufferHubDefs.h> using android::base::unique_fd; using android::dvr::BufferTraits; @@ -69,7 +70,6 @@ using dvr::BufferHubDefs::IsClientGained; using dvr::BufferHubDefs::IsClientPosted; using dvr::BufferHubDefs::IsClientReleased; using dvr::BufferHubDefs::kHighBitsMask; -using dvr::BufferHubDefs::kMetadataHeaderSize; } // namespace @@ -161,7 +161,7 @@ int BufferHubBuffer::ImportGraphicBuffer() { } size_t metadataSize = static_cast<size_t>(bufferTraits.metadata_size()); - if (metadataSize < kMetadataHeaderSize) { + if (metadataSize < BufferHubDefs::kMetadataHeaderSize) { ALOGE("BufferHubBuffer::ImportGraphicBuffer: metadata too small: %zu", metadataSize); return -EINVAL; } diff --git a/libs/ui/BufferHubMetadata.cpp b/libs/ui/BufferHubMetadata.cpp index 18d9a2c963..816707db9d 100644 --- a/libs/ui/BufferHubMetadata.cpp +++ b/libs/ui/BufferHubMetadata.cpp @@ -16,6 +16,7 @@ #include <errno.h> #include <sys/mman.h> +#include <limits> #include <cutils/ashmem.h> #include <log/log.h> @@ -29,8 +30,8 @@ static const int kAshmemProt = PROT_READ | PROT_WRITE; } // namespace -using dvr::BufferHubDefs::kMetadataHeaderSize; -using dvr::BufferHubDefs::MetadataHeader; +using BufferHubDefs::kMetadataHeaderSize; +using BufferHubDefs::MetadataHeader; /* static */ BufferHubMetadata BufferHubMetadata::Create(size_t userMetadataSize) { diff --git a/libs/ui/include/ui/BufferHubDefs.h b/libs/ui/include/ui/BufferHubDefs.h new file mode 100644 index 0000000000..ef6668bd76 --- /dev/null +++ b/libs/ui/include/ui/BufferHubDefs.h @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_BUFFER_HUB_DEFS_H_ +#define ANDROID_BUFFER_HUB_DEFS_H_ + +#include <atomic> + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpacked" +// TODO(b/118893702): remove dependency once DvrNativeBufferMetadata moved out of libdvr +#include <dvr/dvr_api.h> +#pragma clang diagnostic pop + +namespace android { + +namespace BufferHubDefs { + +// Single buffer clients (up to 32) ownership signal. +// 64-bit atomic unsigned int. +// Each client takes 2 bits. The first bit locates in the first 32 bits of +// buffer_state; the second bit locates in the last 32 bits of buffer_state. +// Client states: +// Gained state 11. Exclusive write state. +// Posted state 10. +// Acquired state 01. Shared read state. +// Released state 00. +// +// MSB LSB +// | | +// v v +// [C31|...|C1|C0|C31| ... |C1|C0] + +// Maximum number of clients a buffer can have. +static constexpr int kMaxNumberOfClients = 32; + +// Definition of bit masks. +// MSB LSB +// | kHighBitsMask | kLowbitsMask | +// v v v +// [b63| ... |b32|b31| ... |b0] + +// The location of lower 32 bits in the 64-bit buffer state. +static constexpr uint64_t kLowbitsMask = (1ULL << kMaxNumberOfClients) - 1ULL; + +// The location of higher 32 bits in the 64-bit buffer state. +static constexpr uint64_t kHighBitsMask = ~kLowbitsMask; + +// The client bit mask of the first client. +static constexpr uint64_t kFirstClientBitMask = (1ULL << kMaxNumberOfClients) + 1ULL; + +// Returns true if any of the client is in gained state. +static inline bool AnyClientGained(uint64_t state) { + uint64_t high_bits = state >> kMaxNumberOfClients; + uint64_t low_bits = state & kLowbitsMask; + return high_bits == low_bits && low_bits != 0ULL; +} + +// Returns true if the input client is in gained state. +static inline bool IsClientGained(uint64_t state, uint64_t client_bit_mask) { + return state == client_bit_mask; +} + +// Returns true if any of the client is in posted state. +static inline bool AnyClientPosted(uint64_t state) { + uint64_t high_bits = state >> kMaxNumberOfClients; + uint64_t low_bits = state & kLowbitsMask; + uint64_t posted_or_acquired = high_bits ^ low_bits; + return posted_or_acquired & high_bits; +} + +// Returns true if the input client is in posted state. +static inline bool IsClientPosted(uint64_t state, uint64_t client_bit_mask) { + uint64_t client_bits = state & client_bit_mask; + if (client_bits == 0ULL) return false; + uint64_t low_bits = client_bits & kLowbitsMask; + return low_bits == 0ULL; +} + +// Return true if any of the client is in acquired state. +static inline bool AnyClientAcquired(uint64_t state) { + uint64_t high_bits = state >> kMaxNumberOfClients; + uint64_t low_bits = state & kLowbitsMask; + uint64_t posted_or_acquired = high_bits ^ low_bits; + return posted_or_acquired & low_bits; +} + +// Return true if the input client is in acquired state. +static inline bool IsClientAcquired(uint64_t state, uint64_t client_bit_mask) { + uint64_t client_bits = state & client_bit_mask; + if (client_bits == 0ULL) return false; + uint64_t high_bits = client_bits & kHighBitsMask; + return high_bits == 0ULL; +} + +// Returns true if all clients are in released state. +static inline bool IsBufferReleased(uint64_t state) { + return state == 0ULL; +} + +// Returns true if the input client is in released state. +static inline bool IsClientReleased(uint64_t state, uint64_t client_bit_mask) { + return (state & client_bit_mask) == 0ULL; +} + +// Returns the next available buffer client's client_state_masks. +// @params union_bits. Union of all existing clients' client_state_masks. +static inline uint64_t FindNextAvailableClientStateMask(uint64_t union_bits) { + uint64_t low_union = union_bits & kLowbitsMask; + if (low_union == kLowbitsMask) return 0ULL; + uint64_t incremented = low_union + 1ULL; + uint64_t difference = incremented ^ low_union; + uint64_t new_low_bit = (difference + 1ULL) >> 1; + return new_low_bit + (new_low_bit << kMaxNumberOfClients); +} + +struct __attribute__((aligned(8))) MetadataHeader { + // Internal data format, which can be updated as long as the size, padding and field alignment + // of the struct is consistent within the same ABI. As this part is subject for future updates, + // it's not stable cross Android version, so don't have it visible from outside of the Android + // platform (include Apps and vendor HAL). + + // Every client takes up one bit from the higher 32 bits and one bit from the lower 32 bits in + // buffer_state. + std::atomic<uint64_t> buffer_state; + + // Every client takes up one bit in fence_state. Only the lower 32 bits are valid. The upper 32 + // bits are there for easier manipulation, but the value should be ignored. + std::atomic<uint64_t> fence_state; + + // Every client takes up one bit from the higher 32 bits and one bit from the lower 32 bits in + // active_clients_bit_mask. + std::atomic<uint64_t> active_clients_bit_mask; + + // The index of the buffer queue where the buffer belongs to. + uint64_t queue_index; + + // Public data format, which should be updated with caution. See more details in dvr_api.h + DvrNativeBufferMetadata metadata; +}; + +static_assert(sizeof(MetadataHeader) == 136, "Unexpected MetadataHeader size"); +static constexpr size_t kMetadataHeaderSize = sizeof(MetadataHeader); + +} // namespace BufferHubDefs + +} // namespace android + +#endif // ANDROID_BUFFER_HUB_DEFS_H_ diff --git a/libs/ui/include/ui/BufferHubMetadata.h b/libs/ui/include/ui/BufferHubMetadata.h index 4261971f55..212189497a 100644 --- a/libs/ui/include/ui/BufferHubMetadata.h +++ b/libs/ui/include/ui/BufferHubMetadata.h @@ -17,26 +17,8 @@ #ifndef ANDROID_BUFFER_HUB_METADATA_H_ #define ANDROID_BUFFER_HUB_METADATA_H_ -// We would eliminate the clang warnings introduced by libdpx. -// TODO(b/112338294): Remove those once BufferHub moved to use Binder -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" -#pragma clang diagnostic ignored "-Wdouble-promotion" -#pragma clang diagnostic ignored "-Wgnu-case-range" -#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" -#pragma clang diagnostic ignored "-Winconsistent-missing-destructor-override" -#pragma clang diagnostic ignored "-Wnested-anon-types" -#pragma clang diagnostic ignored "-Wpacked" -#pragma clang diagnostic ignored "-Wshadow" -#pragma clang diagnostic ignored "-Wsign-conversion" -#pragma clang diagnostic ignored "-Wswitch-enum" -#pragma clang diagnostic ignored "-Wundefined-func-template" -#pragma clang diagnostic ignored "-Wunused-template" -#pragma clang diagnostic ignored "-Wweak-vtables" -#include <private/dvr/buffer_hub_defs.h> -#pragma clang diagnostic pop - #include <android-base/unique_fd.h> +#include <ui/BufferHubDefs.h> namespace android { @@ -84,23 +66,21 @@ public: bool IsValid() const { return mAshmemFd.get() != -1 && mMetadataHeader != nullptr; } size_t user_metadata_size() const { return mUserMetadataSize; } - size_t metadata_size() const { - return mUserMetadataSize + dvr::BufferHubDefs::kMetadataHeaderSize; - } + size_t metadata_size() const { return mUserMetadataSize + BufferHubDefs::kMetadataHeaderSize; } const unique_fd& ashmem_fd() const { return mAshmemFd; } - dvr::BufferHubDefs::MetadataHeader* metadata_header() { return mMetadataHeader; } + BufferHubDefs::MetadataHeader* metadata_header() { return mMetadataHeader; } private: BufferHubMetadata(size_t userMetadataSize, unique_fd ashmemFd, - dvr::BufferHubDefs::MetadataHeader* metadataHeader); + BufferHubDefs::MetadataHeader* metadataHeader); BufferHubMetadata(const BufferHubMetadata&) = delete; void operator=(const BufferHubMetadata&) = delete; size_t mUserMetadataSize = 0; unique_fd mAshmemFd; - dvr::BufferHubDefs::MetadataHeader* mMetadataHeader = nullptr; + BufferHubDefs::MetadataHeader* mMetadataHeader = nullptr; }; } // namespace android diff --git a/libs/ui/tests/Android.bp b/libs/ui/tests/Android.bp index 18bbb3e876..c0f4c8916c 100644 --- a/libs/ui/tests/Android.bp +++ b/libs/ui/tests/Android.bp @@ -73,10 +73,9 @@ cc_test { cc_test { name: "BufferHubMetadata_test", - header_libs: ["libbufferhub_headers", "libdvr_headers"], + header_libs: ["libdvr_headers"], shared_libs: [ "libbase", - "libpdx_default_transport", "libui", "libutils", ], diff --git a/libs/ui/tests/BufferHubMetadata_test.cpp b/libs/ui/tests/BufferHubMetadata_test.cpp index 14422bf987..11f8e57adc 100644 --- a/libs/ui/tests/BufferHubMetadata_test.cpp +++ b/libs/ui/tests/BufferHubMetadata_test.cpp @@ -17,7 +17,7 @@ #include <gtest/gtest.h> #include <ui/BufferHubMetadata.h> -using android::dvr::BufferHubDefs::IsBufferReleased; +using android::BufferHubDefs::IsBufferReleased; namespace android { namespace dvr { 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 400def7341..2de36f26a6 100644 --- a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_defs.h +++ b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_defs.h @@ -8,8 +8,7 @@ #include <pdx/rpc/remote_method.h> #include <pdx/rpc/serializable.h> #include <private/dvr/native_handle_wrapper.h> - -#include <atomic> +#include <ui/BufferHubDefs.h> namespace android { namespace dvr { @@ -20,136 +19,55 @@ static constexpr uint32_t kMetadataFormat = HAL_PIXEL_FORMAT_BLOB; static constexpr uint32_t kMetadataUsage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN; -// Single buffer clients (up to 32) ownership signal. -// 64-bit atomic unsigned int. -// Each client takes 2 bits. The first bit locates in the first 32 bits of -// buffer_state; the second bit locates in the last 32 bits of buffer_state. -// Client states: -// Gained state 11. Exclusive write state. -// Posted state 10. -// Acquired state 01. Shared read state. -// Released state 00. -// -// MSB LSB -// | | -// v v -// [C31|...|C1|C0|C31| ... |C1|C0] - -// Maximum number of clients a buffer can have. -static constexpr int kMaxNumberOfClients = 32; - -// Definition of bit masks. -// MSB LSB -// | kHighBitsMask | kLowbitsMask | -// v v v -// [b63| ... |b32|b31| ... |b0] - -// The location of lower 32 bits in the 64-bit buffer state. -static constexpr uint64_t kLowbitsMask = (1ULL << kMaxNumberOfClients) - 1ULL; - -// The location of higher 32 bits in the 64-bit buffer state. -static constexpr uint64_t kHighBitsMask = ~kLowbitsMask; - -// The client bit mask of the first client. +// See more details in libs/ui/include/ui/BufferHubDefs.h +static constexpr int kMaxNumberOfClients = + android::BufferHubDefs::kMaxNumberOfClients; +static constexpr uint64_t kLowbitsMask = android::BufferHubDefs::kLowbitsMask; +static constexpr uint64_t kHighBitsMask = android::BufferHubDefs::kHighBitsMask; static constexpr uint64_t kFirstClientBitMask = - (1ULL << kMaxNumberOfClients) + 1ULL; + android::BufferHubDefs::kFirstClientBitMask; -// Returns true if any of the client is in gained state. static inline bool AnyClientGained(uint64_t state) { - uint64_t high_bits = state >> kMaxNumberOfClients; - uint64_t low_bits = state & kLowbitsMask; - return high_bits == low_bits && low_bits != 0ULL; + return android::BufferHubDefs::AnyClientGained(state); } -// Returns true if the input client is in gained state. static inline bool IsClientGained(uint64_t state, uint64_t client_bit_mask) { - return state == client_bit_mask; + return android::BufferHubDefs::IsClientGained(state, client_bit_mask); } -// Returns true if any of the client is in posted state. static inline bool AnyClientPosted(uint64_t state) { - uint64_t high_bits = state >> kMaxNumberOfClients; - uint64_t low_bits = state & kLowbitsMask; - uint64_t posted_or_acquired = high_bits ^ low_bits; - return posted_or_acquired & high_bits; + return android::BufferHubDefs::AnyClientPosted(state); } -// Returns true if the input client is in posted state. static inline bool IsClientPosted(uint64_t state, uint64_t client_bit_mask) { - uint64_t client_bits = state & client_bit_mask; - if (client_bits == 0ULL) - return false; - uint64_t low_bits = client_bits & kLowbitsMask; - return low_bits == 0ULL; + return android::BufferHubDefs::IsClientPosted(state, client_bit_mask); } -// Return true if any of the client is in acquired state. static inline bool AnyClientAcquired(uint64_t state) { - uint64_t high_bits = state >> kMaxNumberOfClients; - uint64_t low_bits = state & kLowbitsMask; - uint64_t posted_or_acquired = high_bits ^ low_bits; - return posted_or_acquired & low_bits; + return android::BufferHubDefs::AnyClientAcquired(state); } -// Return true if the input client is in acquired state. static inline bool IsClientAcquired(uint64_t state, uint64_t client_bit_mask) { - uint64_t client_bits = state & client_bit_mask; - if (client_bits == 0ULL) - return false; - uint64_t high_bits = client_bits & kHighBitsMask; - return high_bits == 0ULL; + return android::BufferHubDefs::IsClientAcquired(state, client_bit_mask); } -// Returns true if all clients are in released state. -static inline bool IsBufferReleased(uint64_t state) { return state == 0ULL; } +static inline bool IsBufferReleased(uint64_t state) { + return android::BufferHubDefs::IsBufferReleased(state); +} -// Returns true if the input client is in released state. static inline bool IsClientReleased(uint64_t state, uint64_t client_bit_mask) { - return (state & client_bit_mask) == 0ULL; + 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 uint64_t FindNextAvailableClientStateMask(uint64_t union_bits) { - uint64_t low_union = union_bits & kLowbitsMask; - if (low_union == kLowbitsMask) - return 0ULL; - uint64_t incremented = low_union + 1ULL; - uint64_t difference = incremented ^ low_union; - uint64_t new_low_bit = (difference + 1ULL) >> 1; - return new_low_bit + (new_low_bit << kMaxNumberOfClients); + return android::BufferHubDefs::FindNextAvailableClientStateMask(union_bits); } -struct __attribute__((packed, aligned(8))) MetadataHeader { - // Internal data format, which can be updated as long as the size, padding and - // field alignment of the struct is consistent within the same ABI. As this - // part is subject for future updates, it's not stable cross Android version, - // so don't have it visible from outside of the Android platform (include Apps - // and vendor HAL). - - // Every client takes up one bit from the higher 32 bits and one bit from the - // lower 32 bits in buffer_state. - std::atomic<uint64_t> buffer_state; - - // Every client takes up one bit in fence_state. Only the lower 32 bits are - // valid. The upper 32 bits are there for easier manipulation, but the value - // should be ignored. - std::atomic<uint64_t> fence_state; - - // Every client takes up one bit from the higher 32 bits and one bit from the - // lower 32 bits in active_clients_bit_mask. - std::atomic<uint64_t> active_clients_bit_mask; - - // The index of the buffer queue where the buffer belongs to. - uint64_t queue_index; - - // Public data format, which should be updated with caution. See more details - // in dvr_api.h - DvrNativeBufferMetadata metadata; -}; - -static_assert(sizeof(MetadataHeader) == 136, "Unexpected MetadataHeader size"); -static constexpr size_t kMetadataHeaderSize = sizeof(MetadataHeader); +using MetadataHeader = android::BufferHubDefs::MetadataHeader; +static constexpr size_t kMetadataHeaderSize = + android::BufferHubDefs::kMetadataHeaderSize; } // namespace BufferHubDefs diff --git a/libs/vr/libdvr/include/dvr/dvr_api.h b/libs/vr/libdvr/include/dvr/dvr_api.h index fef8512266..a204f62fff 100644 --- a/libs/vr/libdvr/include/dvr/dvr_api.h +++ b/libs/vr/libdvr/include/dvr/dvr_api.h @@ -412,6 +412,7 @@ typedef int (*DvrTrackingSensorsStopPtr)(DvrTrackingSensors* sensors); // existing data members. If new fields need to be added, please take extra care // to make sure that new data field is padded properly the size of the struct // stays same. +// TODO(b/118893702): move the definition to libnativewindow or libui struct ALIGNED_DVR_STRUCT(8) DvrNativeBufferMetadata { #ifdef __cplusplus DvrNativeBufferMetadata() diff --git a/services/bufferhub/Android.bp b/services/bufferhub/Android.bp index f9aaa2050f..72d210cbb0 100644 --- a/services/bufferhub/Android.bp +++ b/services/bufferhub/Android.bp @@ -29,10 +29,8 @@ cc_library_shared { "BufferNode.cpp", ], header_libs: [ - "libbufferhub_headers", "libdvr_headers", "libnativewindow_headers", - "libpdx_headers", ], shared_libs: [ "android.frameworks.bufferhub@1.0", @@ -56,10 +54,8 @@ cc_binary { "main_bufferhub.cpp" ], header_libs: [ - "libbufferhub_headers", "libdvr_headers", "libnativewindow_headers", - "libpdx_headers", ], shared_libs: [ "android.frameworks.bufferhub@1.0", diff --git a/services/bufferhub/BufferClient.cpp b/services/bufferhub/BufferClient.cpp index 745951745a..e312011696 100644 --- a/services/bufferhub/BufferClient.cpp +++ b/services/bufferhub/BufferClient.cpp @@ -17,6 +17,7 @@ #include <bufferhub/BufferClient.h> #include <bufferhub/BufferHubService.h> #include <hidl/HidlSupport.h> +#include <log/log.h> namespace android { namespace frameworks { diff --git a/services/bufferhub/BufferNode.cpp b/services/bufferhub/BufferNode.cpp index ec84849e22..4bad829210 100644 --- a/services/bufferhub/BufferNode.cpp +++ b/services/bufferhub/BufferNode.cpp @@ -2,7 +2,6 @@ #include <bufferhub/BufferHubService.h> #include <bufferhub/BufferNode.h> -#include <private/dvr/buffer_hub_defs.h> #include <ui/GraphicBufferAllocator.h> namespace android { @@ -14,7 +13,7 @@ namespace implementation { void BufferNode::InitializeMetadata() { // Using placement new here to reuse shared memory instead of new allocation // Initialize the atomic variables to zero. - dvr::BufferHubDefs::MetadataHeader* metadata_header = metadata_.metadata_header(); + BufferHubDefs::MetadataHeader* metadata_header = metadata_.metadata_header(); buffer_state_ = new (&metadata_header->buffer_state) std::atomic<uint64_t>(0); fence_state_ = new (&metadata_header->fence_state) std::atomic<uint64_t>(0); active_clients_bit_mask_ = @@ -84,10 +83,11 @@ uint64_t BufferNode::AddNewActiveClientsBitToMask() { uint64_t client_state_mask = 0ULL; uint64_t updated_active_clients_bit_mask = 0ULL; do { - client_state_mask = dvr::BufferHubDefs::FindNextAvailableClientStateMask( - current_active_clients_bit_mask); + client_state_mask = + BufferHubDefs::FindNextAvailableClientStateMask(current_active_clients_bit_mask); if (client_state_mask == 0ULL) { - ALOGE("%s: reached the maximum number of channels per buffer node: 32.", __FUNCTION__); + ALOGE("%s: reached the maximum number of channels per buffer node: %d.", __FUNCTION__, + BufferHubDefs::kMaxNumberOfClients); errno = E2BIG; return 0ULL; } diff --git a/services/bufferhub/include/bufferhub/BufferNode.h b/services/bufferhub/include/bufferhub/BufferNode.h index 94ef505d41..02bb5af0e0 100644 --- a/services/bufferhub/include/bufferhub/BufferNode.h +++ b/services/bufferhub/include/bufferhub/BufferNode.h @@ -3,6 +3,7 @@ #include <android/hardware_buffer.h> #include <bufferhub/BufferHubIdGenerator.h> +#include <cutils/native_handle.h> #include <ui/BufferHubMetadata.h> namespace android { diff --git a/services/bufferhub/tests/Android.bp b/services/bufferhub/tests/Android.bp index 39678865cb..bf65469784 100644 --- a/services/bufferhub/tests/Android.bp +++ b/services/bufferhub/tests/Android.bp @@ -7,10 +7,8 @@ cc_test { "-DATRACE_TAG=ATRACE_TAG_GRAPHICS", ], header_libs: [ - "libbufferhub_headers", "libdvr_headers", "libnativewindow_headers", - "libpdx_headers", ], shared_libs: [ "libbufferhubservice", @@ -19,8 +17,6 @@ cc_test { static_libs: [ "libgmock", ], - // TODO(b/117568153): Temporarily opt out using libcrt. - no_libcrt: true, } cc_test { diff --git a/services/bufferhub/tests/BufferNode_test.cpp b/services/bufferhub/tests/BufferNode_test.cpp index df31d78b89..8555eb7800 100644 --- a/services/bufferhub/tests/BufferNode_test.cpp +++ b/services/bufferhub/tests/BufferNode_test.cpp @@ -1,7 +1,9 @@ -#include <bufferhub/BufferNode.h> #include <errno.h> + +#include <bufferhub/BufferNode.h> #include <gmock/gmock.h> #include <gtest/gtest.h> +#include <ui/BufferHubDefs.h> #include <ui/GraphicBufferMapper.h> namespace android { @@ -20,7 +22,6 @@ const uint32_t kLayerCount = 1; const uint32_t kFormat = 1; const uint64_t kUsage = 0; const size_t kUserMetadataSize = 0; -const size_t kMaxClientsCount = dvr::BufferHubDefs::kMaxNumberOfClients; class BufferNodeTest : public ::testing::Test { protected: @@ -71,7 +72,7 @@ TEST_F(BufferNodeTest, TestAddNewActiveClientsBitToMask_32NewClients) { uint64_t current_mask = 0ULL; uint64_t expected_mask = 0ULL; - for (int i = 0; i < kMaxClientsCount; ++i) { + for (int i = 0; i < BufferHubDefs::kMaxNumberOfClients; ++i) { new_client_state_mask = buffer_node->AddNewActiveClientsBitToMask(); EXPECT_NE(new_client_state_mask, 0); EXPECT_FALSE(new_client_state_mask & current_mask); |