diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-12 02:08:14 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-12 02:08:14 +0000 |
commit | 0d81102b80fc4512f40f81a390dd0569709b13a2 (patch) | |
tree | eb163ec9a2cb061d1fa6a937aca28592fb84f2b9 | |
parent | b4852c455be544a7d5bfa8f5cc7e67beef3b4acd (diff) | |
parent | 3c3a8579282a4429796b3fd1d4cdceed637cb010 (diff) | |
download | minigbm-android14-qpr2-s2-release.tar.gz |
Snap for 11206181 from 3c3a8579282a4429796b3fd1d4cdceed637cb010 to 24Q1-releaseandroid-14.0.0_r37android-14.0.0_r36android-14.0.0_r35android-14.0.0_r34android-14.0.0_r33android-14.0.0_r32android-14.0.0_r31android-14.0.0_r30android-14.0.0_r29android14-qpr2-s5-releaseandroid14-qpr2-s4-releaseandroid14-qpr2-s3-releaseandroid14-qpr2-s2-releaseandroid14-qpr2-s1-releaseandroid14-qpr2-release
Change-Id: I623a6bc4adfbaf0f00d52e62b429e62b018ac6c9
-rw-r--r-- | cros_gralloc/aidl/Allocator.cpp | 31 | ||||
-rw-r--r-- | cros_gralloc/aidl/Allocator.h | 7 |
2 files changed, 26 insertions, 12 deletions
diff --git a/cros_gralloc/aidl/Allocator.cpp b/cros_gralloc/aidl/Allocator.cpp index 2ea5a0d..89c439e 100644 --- a/cros_gralloc/aidl/Allocator.cpp +++ b/cros_gralloc/aidl/Allocator.cpp @@ -19,6 +19,8 @@ using aidl::android::hardware::common::NativeHandle; using BufferDescriptorInfoV4 = android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo; +static const std::string STANDARD_METADATA_DATASPACE = "android.hardware.graphics.common.Dataspace"; + namespace aidl::android::hardware::graphics::allocator::impl { namespace { @@ -36,7 +38,8 @@ bool Allocator::init() { // TODO(natsu): deduplicate with CrosGralloc4Allocator after the T release. ndk::ScopedAStatus Allocator::initializeMetadata( cros_gralloc_handle_t crosHandle, - const struct cros_gralloc_buffer_descriptor& crosDescriptor) { + const struct cros_gralloc_buffer_descriptor& crosDescriptor, + Dataspace initialDataspace) { if (!mDriver) { ALOGE("Failed to initializeMetadata. Driver is uninitialized.\n"); return ToBinderStatus(AllocationError::NO_RESOURCES); @@ -59,7 +62,7 @@ ndk::ScopedAStatus Allocator::initializeMetadata( snprintf(crosMetadata->name, CROS_GRALLOC4_METADATA_MAX_NAME_SIZE, "%s", crosDescriptor.name.c_str()); - crosMetadata->dataspace = common::Dataspace::UNKNOWN; + crosMetadata->dataspace = initialDataspace; crosMetadata->blendMode = common::BlendMode::INVALID; return ndk::ScopedAStatus::ok(); @@ -110,7 +113,7 @@ ndk::ScopedAStatus Allocator::allocate(const std::vector<uint8_t>& descriptor, i } ndk::ScopedAStatus Allocator::allocate(const BufferDescriptorInfoV4& descriptor, int32_t* outStride, - native_handle_t** outHandle) { + native_handle_t** outHandle, Dataspace initialDataspace) { if (!mDriver) { ALOGE("Failed to allocate. Driver is uninitialized.\n"); return ToBinderStatus(AllocationError::NO_RESOURCES); @@ -141,7 +144,7 @@ ndk::ScopedAStatus Allocator::allocate(const BufferDescriptorInfoV4& descriptor, cros_gralloc_handle_t crosHandle = cros_gralloc_convert_handle(handle); - auto status = initializeMetadata(crosHandle, crosDescriptor); + auto status = initializeMetadata(crosHandle, crosDescriptor, initialDataspace); if (!status.isOk()) { ALOGE("Failed to allocate. Failed to initialize gralloc buffer metadata."); releaseBufferAndHandle(handle); @@ -173,8 +176,13 @@ ndk::ScopedAStatus Allocator::allocate2(const BufferDescriptorInfo& descriptor, return ToBinderStatus(AllocationError::NO_RESOURCES); } - if (!descriptor.additionalOptions.empty()) { - return ToBinderStatus(AllocationError::UNSUPPORTED); + Dataspace initialDataspace = Dataspace::UNKNOWN; + + for (const auto& option : descriptor.additionalOptions) { + if (option.name != STANDARD_METADATA_DATASPACE) { + return ToBinderStatus(AllocationError::UNSUPPORTED); + } + initialDataspace = static_cast<Dataspace>(option.value); } BufferDescriptorInfoV4 descriptionV4 = convertAidlToIMapperV4Descriptor(descriptor); @@ -183,7 +191,8 @@ ndk::ScopedAStatus Allocator::allocate2(const BufferDescriptorInfo& descriptor, handles.resize(count, nullptr); for (int32_t i = 0; i < count; i++) { - ndk::ScopedAStatus status = allocate(descriptionV4, &outResult->stride, &handles[i]); + ndk::ScopedAStatus status = allocate(descriptionV4, &outResult->stride, &handles[i], + initialDataspace); if (!status.isOk()) { for (int32_t j = 0; j < i; j++) { releaseBufferAndHandle(handles[j]); @@ -209,9 +218,11 @@ ndk::ScopedAStatus Allocator::isSupported(const BufferDescriptorInfo& descriptor return ToBinderStatus(AllocationError::NO_RESOURCES); } - if (!descriptor.additionalOptions.empty()) { - *outResult = false; - return ndk::ScopedAStatus::ok(); + for (const auto& option : descriptor.additionalOptions) { + if (option.name != STANDARD_METADATA_DATASPACE) { + *outResult = false; + return ndk::ScopedAStatus::ok(); + } } struct cros_gralloc_buffer_descriptor crosDescriptor; diff --git a/cros_gralloc/aidl/Allocator.h b/cros_gralloc/aidl/Allocator.h index ea11eaf..85a13cd 100644 --- a/cros_gralloc/aidl/Allocator.h +++ b/cros_gralloc/aidl/Allocator.h @@ -38,14 +38,17 @@ class Allocator : public BnAllocator { ndk::SpAIBinder createBinder() override; private: + using Dataspace = aidl::android::hardware::graphics::common::Dataspace; ndk::ScopedAStatus allocate( const ::android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo& descriptor, - int32_t* outStride, native_handle_t** outHandle); + int32_t* outStride, native_handle_t** outHandle, + Dataspace initialDataspace = Dataspace::UNKNOWN); ndk::ScopedAStatus initializeMetadata( cros_gralloc_handle_t crosHandle, - const struct cros_gralloc_buffer_descriptor& crosDescriptor); + const struct cros_gralloc_buffer_descriptor& crosDescriptor, + Dataspace initialDataspace); void releaseBufferAndHandle(native_handle_t* handle); |