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>
This commit is contained in:
commit
3c3a857928
2 changed files with 26 additions and 12 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue