Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 448369c9 authored by Yichi Chen's avatar Yichi Chen
Browse files

gralloc4-vts: Correct the ownership of fence fd

Gralloc::lock takes the ownership of acquireFence and closes the fence
by itself. The patch changes the behavior of fence to transfer the
ownership by unique_fd::release.

Bug: 157534008
Test: VtsHalGraphicsMapperV4_0TargetTest
Change-Id: Ie4ee9cd9c3b148cab9187fa07a4e52cbf9ad798a
parent ad15d6c0
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -587,8 +587,8 @@ TEST_P(GraphicsMapperHidlTest, LockUnlockBasic) {
                               static_cast<int32_t>(info.height)};
    unique_fd fence;
    uint8_t* data;
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(
                                    mGralloc->lock(bufferHandle, info.usage, region, fence.get())));
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(bufferHandle, info.usage,
                                                                        region, fence.release())));

    // RGBA_8888
    fillRGBA8888(data, info.height, stride * 4, info.width * 4);
@@ -596,8 +596,8 @@ TEST_P(GraphicsMapperHidlTest, LockUnlockBasic) {
    ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle)));

    // lock again for reading
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(
                                    mGralloc->lock(bufferHandle, info.usage, region, fence.get())));
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(bufferHandle, info.usage,
                                                                        region, fence.release())));

    ASSERT_NO_FATAL_FAILURE(
            verifyRGBA8888(bufferHandle, data, info.height, stride * 4, info.width * 4));
@@ -627,8 +627,8 @@ TEST_P(GraphicsMapperHidlTest, Lock_YCRCB_420_SP) {
    unique_fd fence;
    uint8_t* data;

    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(
                                    mGralloc->lock(bufferHandle, info.usage, region, fence.get())));
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(bufferHandle, info.usage,
                                                                        region, fence.release())));

    android_ycbcr yCbCr;
    int64_t hSubsampling = 0;
@@ -650,8 +650,8 @@ TEST_P(GraphicsMapperHidlTest, Lock_YCRCB_420_SP) {
    ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle)));

    // lock again for reading
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(
                                    mGralloc->lock(bufferHandle, info.usage, region, fence.get())));
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(bufferHandle, info.usage,
                                                                        region, fence.release())));

    ASSERT_NO_FATAL_FAILURE(
            getAndroidYCbCr(bufferHandle, data, &yCbCr, &hSubsampling, &vSubsampling));
@@ -676,8 +676,8 @@ TEST_P(GraphicsMapperHidlTest, Lock_YV12) {
    unique_fd fence;
    uint8_t* data;

    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(
                                    mGralloc->lock(bufferHandle, info.usage, region, fence.get())));
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(bufferHandle, info.usage,
                                                                        region, fence.release())));

    android_ycbcr yCbCr;
    int64_t hSubsampling = 0;
@@ -699,8 +699,8 @@ TEST_P(GraphicsMapperHidlTest, Lock_YV12) {
    ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle)));

    // lock again for reading
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(
                                    mGralloc->lock(bufferHandle, info.usage, region, fence.get())));
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(bufferHandle, info.usage,
                                                                        region, fence.release())));

    ASSERT_NO_FATAL_FAILURE(
            getAndroidYCbCr(bufferHandle, data, &yCbCr, &hSubsampling, &vSubsampling));
@@ -725,8 +725,8 @@ TEST_P(GraphicsMapperHidlTest, Lock_YCBCR_420_888) {
    unique_fd fence;
    uint8_t* data;

    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(
                                    mGralloc->lock(bufferHandle, info.usage, region, fence.get())));
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(bufferHandle, info.usage,
                                                                        region, fence.release())));

    android_ycbcr yCbCr;
    int64_t hSubsampling = 0;
@@ -743,8 +743,8 @@ TEST_P(GraphicsMapperHidlTest, Lock_YCBCR_420_888) {
    ASSERT_NO_FATAL_FAILURE(fence.reset(mGralloc->unlock(bufferHandle)));

    // lock again for reading
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(
                                    mGralloc->lock(bufferHandle, info.usage, region, fence.get())));
    ASSERT_NO_FATAL_FAILURE(data = static_cast<uint8_t*>(mGralloc->lock(bufferHandle, info.usage,
                                                                        region, fence.release())));

    ASSERT_NO_FATAL_FAILURE(
            getAndroidYCbCr(bufferHandle, data, &yCbCr, &hSubsampling, &vSubsampling));
@@ -771,7 +771,7 @@ TEST_P(GraphicsMapperHidlTest, Lock_RAW10) {
                               static_cast<int32_t>(info.height)};
    unique_fd fence;

    ASSERT_NO_FATAL_FAILURE(mGralloc->lock(bufferHandle, info.usage, region, fence.get()));
    ASSERT_NO_FATAL_FAILURE(mGralloc->lock(bufferHandle, info.usage, region, fence.release()));

    hidl_vec<uint8_t> vec;
    ASSERT_EQ(Error::NONE, mGralloc->get(bufferHandle, gralloc4::MetadataType_PlaneLayouts, &vec));
@@ -813,7 +813,7 @@ TEST_P(GraphicsMapperHidlTest, Lock_RAW12) {
                               static_cast<int32_t>(info.height)};
    unique_fd fence;

    ASSERT_NO_FATAL_FAILURE(mGralloc->lock(bufferHandle, info.usage, region, fence.get()));
    ASSERT_NO_FATAL_FAILURE(mGralloc->lock(bufferHandle, info.usage, region, fence.release()));

    hidl_vec<uint8_t> vec;
    ASSERT_EQ(Error::NONE, mGralloc->get(bufferHandle, gralloc4::MetadataType_PlaneLayouts, &vec));