diff options
author | John Reck <jreck@google.com> | 2023-12-11 18:10:39 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-12-11 18:10:39 +0000 |
commit | 3c3a8579282a4429796b3fd1d4cdceed637cb010 (patch) | |
tree | eb163ec9a2cb061d1fa6a937aca28592fb84f2b9 | |
parent | 63bbd26d4d7be2fe3b362d2c4fc1538b9976b1ec (diff) | |
parent | 936378aa49caecf8b63de7f6171f7367dab3be6b (diff) | |
download | minigbm-3c3a8579282a4429796b3fd1d4cdceed637cb010.tar.gz |
Merge "Support an additional option to initialize the dataspace" into main am: c0d35dea72 am: 3bf344f827 am: 936378aa49
Original change: https://android-review.googlesource.com/c/platform/external/minigbm/+/2864908
Change-Id: Ic0deff9919736b28b1547e380a4dab82a052faef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-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); |