From 0809466b61f72960cdfbd0d6b969667f031525de Mon Sep 17 00:00:00 2001 From: Yichi Chen Date: Wed, 27 May 2020 16:29:56 +0800 Subject: [PATCH 1/3] gralloc4-vts: Test layout and component info of RAW10 To ensure the correctness of the plane layout and layout component on RAW10 format, the patch creates the test case to check corresponding data. Bug: 157534008 Test: VtsHalGraphicsMapperV4_0TargetTest Change-Id: Ie504e687e149ee4f4fb3f715ee0de7d7ec31952a --- .../VtsHalGraphicsMapperV4_0TargetTest.cpp | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp index 529fb1817a..f0153ba4ed 100644 --- a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp +++ b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp @@ -605,6 +605,9 @@ TEST_P(GraphicsMapperHidlTest, LockUnlockBasic) { ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle))); } +/** + * Test multiple operations associated with different color formats + */ TEST_P(GraphicsMapperHidlTest, Lock_YCRCB_420_SP) { auto info = mDummyDescriptorInfo; info.format = PixelFormat::YCRCB_420_SP; @@ -751,6 +754,48 @@ TEST_P(GraphicsMapperHidlTest, Lock_YCBCR_420_888) { ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle))); } +TEST_P(GraphicsMapperHidlTest, Lock_RAW10) { + auto info = mDummyDescriptorInfo; + info.format = PixelFormat::RAW10; + + const native_handle_t* bufferHandle; + uint32_t stride; + ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate( + info, true, Tolerance::kToleranceUnSupported, &stride)); + if (bufferHandle == nullptr) { + GTEST_SUCCEED() << "RAW10 format is unsupported"; + return; + } + + const IMapper::Rect region{0, 0, static_cast(info.width), + static_cast(info.height)}; + unique_fd fence; + + ASSERT_NO_FATAL_FAILURE(mGralloc->lock(bufferHandle, info.usage, region, fence.get())); + + hidl_vec vec; + ASSERT_EQ(Error::NONE, mGralloc->get(bufferHandle, gralloc4::MetadataType_PlaneLayouts, &vec)); + std::vector planeLayouts; + ASSERT_EQ(NO_ERROR, gralloc4::decodePlaneLayouts(vec, &planeLayouts)); + + ASSERT_EQ(1, planeLayouts.size()); + auto planeLayout = planeLayouts[0]; + + EXPECT_EQ(0, planeLayout.sampleIncrementInBits); + EXPECT_EQ(1, planeLayout.horizontalSubsampling); + EXPECT_EQ(1, planeLayout.verticalSubsampling); + + ASSERT_EQ(1, planeLayout.components.size()); + auto planeLayoutComponent = planeLayout.components[0]; + + EXPECT_EQ(PlaneLayoutComponentType::RAW, + static_cast(planeLayoutComponent.type.value)); + EXPECT_EQ(0, planeLayoutComponent.offsetInBits % 8); + EXPECT_EQ(-1, planeLayoutComponent.sizeInBits); + + ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle))); +} + /** * Test IMapper::unlock with bad access region */ From 26ddd0125ceb2b29b40104068cce6203181ea219 Mon Sep 17 00:00:00 2001 From: layog Date: Wed, 3 Jun 2020 17:04:18 +0800 Subject: [PATCH 2/3] gralloc4-vts: Test layout and component info of RAW12 Bug: 157534008 Test: VtsHalGraphicsMapperV4_0TargetTest Change-Id: I3441e630b18f3d6e0f5cbcecf8a54dc1b42faa84 --- .../VtsHalGraphicsMapperV4_0TargetTest.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp index f0153ba4ed..1343cc0488 100644 --- a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp +++ b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp @@ -796,6 +796,48 @@ TEST_P(GraphicsMapperHidlTest, Lock_RAW10) { ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle))); } +TEST_P(GraphicsMapperHidlTest, Lock_RAW12) { + auto info = mDummyDescriptorInfo; + info.format = PixelFormat::RAW12; + + const native_handle_t* bufferHandle; + uint32_t stride; + ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate( + info, true, Tolerance::kToleranceUnSupported, &stride)); + if (bufferHandle == nullptr) { + GTEST_SUCCEED() << "RAW12 format is unsupported"; + return; + } + + const IMapper::Rect region{0, 0, static_cast(info.width), + static_cast(info.height)}; + unique_fd fence; + + ASSERT_NO_FATAL_FAILURE(mGralloc->lock(bufferHandle, info.usage, region, fence.get())); + + hidl_vec vec; + ASSERT_EQ(Error::NONE, mGralloc->get(bufferHandle, gralloc4::MetadataType_PlaneLayouts, &vec)); + std::vector planeLayouts; + ASSERT_EQ(NO_ERROR, gralloc4::decodePlaneLayouts(vec, &planeLayouts)); + + ASSERT_EQ(1, planeLayouts.size()); + auto planeLayout = planeLayouts[0]; + + EXPECT_EQ(0, planeLayout.sampleIncrementInBits); + EXPECT_EQ(1, planeLayout.horizontalSubsampling); + EXPECT_EQ(1, planeLayout.verticalSubsampling); + + ASSERT_EQ(1, planeLayout.components.size()); + auto planeLayoutComponent = planeLayout.components[0]; + + EXPECT_EQ(PlaneLayoutComponentType::RAW, + static_cast(planeLayoutComponent.type.value)); + EXPECT_EQ(0, planeLayoutComponent.offsetInBits % 8); + EXPECT_EQ(-1, planeLayoutComponent.sizeInBits); + + ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle))); +} + /** * Test IMapper::unlock with bad access region */ From 35d97d5417c0789a9337dbbdf6cd290e9d308b3e Mon Sep 17 00:00:00 2001 From: Yichi Chen Date: Tue, 2 Jun 2020 20:15:37 +0800 Subject: [PATCH 3/3] gralloc4-vts: Test metadata is consistent in cloned buffers GetMetadataClonedHandle checks the metadata can be gotten after a native handle is cloned. SetMetadataClonedHandle checks the metadata can be set on a cloned native handle. Bug: 155224585 Test: VtsHalGraphicsMapperV4_0TargetTest Change-Id: Ic0d7b4d21a64822f2f1dbeca8d48c450711ed494 --- .../VtsHalGraphicsMapperV4_0TargetTest.cpp | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp index 1343cc0488..6df7f8d406 100644 --- a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp +++ b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp @@ -1793,6 +1793,84 @@ TEST_P(GraphicsMapperHidlTest, SetMetadataNullBuffer) { mGralloc->set(bufferHandle, gralloc4::MetadataType_Smpte2094_40, vec)); } +/** + * Test get::metadata with cloned native_handle + */ +TEST_P(GraphicsMapperHidlTest, GetMetadataClonedHandle) { + const native_handle_t* bufferHandle = nullptr; + ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true)); + + const auto dataspace = Dataspace::SRGB_LINEAR; + { + hidl_vec metadata; + ASSERT_EQ(NO_ERROR, gralloc4::encodeDataspace(dataspace, &metadata)); + + Error err = mGralloc->set(bufferHandle, gralloc4::MetadataType_Dataspace, metadata); + if (err == Error::UNSUPPORTED) { + GTEST_SUCCEED() << "setting this metadata is unsupported"; + return; + } + ASSERT_EQ(Error::NONE, err); + } + + const native_handle_t* importedHandle; + { + auto clonedHandle = native_handle_clone(bufferHandle); + ASSERT_NO_FATAL_FAILURE(importedHandle = mGralloc->importBuffer(clonedHandle)); + native_handle_close(clonedHandle); + native_handle_delete(clonedHandle); + } + + Dataspace realSpace = Dataspace::UNKNOWN; + { + hidl_vec metadata; + ASSERT_EQ(Error::NONE, + mGralloc->get(importedHandle, gralloc4::MetadataType_Dataspace, &metadata)); + ASSERT_NO_FATAL_FAILURE(gralloc4::decodeDataspace(metadata, &realSpace)); + } + + EXPECT_EQ(dataspace, realSpace); +} + +/** + * Test set::metadata with cloned native_handle + */ +TEST_P(GraphicsMapperHidlTest, SetMetadataClonedHandle) { + const native_handle_t* bufferHandle = nullptr; + ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true)); + + const native_handle_t* importedHandle; + { + auto clonedHandle = native_handle_clone(bufferHandle); + ASSERT_NO_FATAL_FAILURE(importedHandle = mGralloc->importBuffer(clonedHandle)); + native_handle_close(clonedHandle); + native_handle_delete(clonedHandle); + } + + const auto dataspace = Dataspace::SRGB_LINEAR; + { + hidl_vec metadata; + ASSERT_EQ(NO_ERROR, gralloc4::encodeDataspace(dataspace, &metadata)); + + Error err = mGralloc->set(importedHandle, gralloc4::MetadataType_Dataspace, metadata); + if (err == Error::UNSUPPORTED) { + GTEST_SUCCEED() << "setting this metadata is unsupported"; + return; + } + ASSERT_EQ(Error::NONE, err); + } + + Dataspace realSpace = Dataspace::UNKNOWN; + { + hidl_vec metadata; + ASSERT_EQ(Error::NONE, + mGralloc->get(bufferHandle, gralloc4::MetadataType_Dataspace, &metadata)); + ASSERT_NO_FATAL_FAILURE(gralloc4::decodeDataspace(metadata, &realSpace)); + } + + EXPECT_EQ(dataspace, realSpace); +} + /** * Test IMapper::set(metadata) for constant metadata */