From 872cc0af1a7082c6b420864b7ff52e34e6101f84 Mon Sep 17 00:00:00 2001 From: ramindani Date: Tue, 29 Jun 2021 00:32:43 +0000 Subject: [PATCH] Add VTS test for YCbCr_P010 to denote that YCbCr_P010 is supported in Gralloc BUG: 181069130 Test: atest VtsHalGraphicsMapperV3_0TargetTest Change-Id: I43737dcbb530c0c4018b9609434eef38d8daa887 --- .../VtsHalGraphicsMapperV3_0TargetTest.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/graphics/mapper/3.0/vts/functional/VtsHalGraphicsMapperV3_0TargetTest.cpp b/graphics/mapper/3.0/vts/functional/VtsHalGraphicsMapperV3_0TargetTest.cpp index 4187dd1354..6c90af407a 100644 --- a/graphics/mapper/3.0/vts/functional/VtsHalGraphicsMapperV3_0TargetTest.cpp +++ b/graphics/mapper/3.0/vts/functional/VtsHalGraphicsMapperV3_0TargetTest.cpp @@ -326,6 +326,39 @@ TEST_P(GraphicsMapperHidlTest, LockUnlockBasic) { } } +/** + * Test IMapper::lockYCbCr. This locks a YCbCr_P010 buffer and verifies that it's initialized. + */ +TEST_P(GraphicsMapperHidlTest, LockYCbCrP010) { + auto info = mDummyDescriptorInfo; + info.format = PixelFormat::YCBCR_P010; + + const native_handle_t* bufferHandle; + uint32_t stride; + ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(info, true, &stride)); + + ASSERT_NE(nullptr, bufferHandle); + + const IMapper::Rect region{0, 0, static_cast(info.width), + static_cast(info.height)}; + int fence = -1; + YCbCrLayout y_cb_cr_layout{}; + // lock buffer + ASSERT_NO_FATAL_FAILURE(y_cb_cr_layout = + mGralloc->lockYCbCr(bufferHandle, info.usage, region, fence)); + + ASSERT_NE(nullptr, &y_cb_cr_layout); + EXPECT_EQ(stride, info.width); + EXPECT_EQ(y_cb_cr_layout.yStride, info.height * 2); + EXPECT_EQ(y_cb_cr_layout.cStride, y_cb_cr_layout.yStride); + EXPECT_EQ(4, y_cb_cr_layout.chromaStep); + + ASSERT_NO_FATAL_FAILURE(fence = mGralloc->unlock(bufferHandle)); + if (fence >= 0) { + close(fence); + } +} + /** * Test IMapper::lockYCbCr. This locks a YV12 buffer, and makes sure we can * write to and read from it.