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

Commit be270cbe authored by Presubmit Automerger Backend's avatar Presubmit Automerger Backend
Browse files

[automerge] Allow old gralloc implementations to skip P010 support. 2p: 18339992

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/17573261

Bug: 220360702
Change-Id: I8720854b277801d0feb51fe95be0ca0542e03524
parents 42d696d6 18339992
Loading
Loading
Loading
Loading
+26 −16
Original line number Original line Diff line number Diff line
@@ -14,7 +14,9 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include <android-base/properties.h>
#include <mapper-vts/3.0/MapperVts.h>
#include <mapper-vts/3.0/MapperVts.h>
#include "gtest/gtest.h"


namespace android {
namespace android {
namespace hardware {
namespace hardware {
@@ -96,14 +98,22 @@ std::vector<const native_handle_t*> Gralloc::allocate(const BufferDescriptor& de
    mAllocator->allocate(
    mAllocator->allocate(
            descriptor, count,
            descriptor, count,
            [&](const auto& tmpError, const auto& tmpStride, const auto& tmpBuffers) {
            [&](const auto& tmpError, const auto& tmpStride, const auto& tmpBuffers) {
            ASSERT_EQ(Error::NONE, tmpError) << "failed to allocate buffers";
                if (tmpError != Error::NONE) {
                    if (base::GetIntProperty("ro.vendor.build.version.sdk", 0, 0, INT_MAX) < 33) {
                        GTEST_SKIP() << "Old vendor grallocs may not support P010";
                    } else {
                        GTEST_FAIL() << "failed to allocate buffers";
                    }
                }
                ASSERT_EQ(count, tmpBuffers.size()) << "invalid buffer array";
                ASSERT_EQ(count, tmpBuffers.size()) << "invalid buffer array";


                for (uint32_t i = 0; i < count; i++) {
                for (uint32_t i = 0; i < count; i++) {
                    if (import) {
                    if (import) {
                    ASSERT_NO_FATAL_FAILURE(bufferHandles.push_back(importBuffer(tmpBuffers[i])));
                        ASSERT_NO_FATAL_FAILURE(
                                bufferHandles.push_back(importBuffer(tmpBuffers[i])));
                    } else {
                    } else {
                    ASSERT_NO_FATAL_FAILURE(bufferHandles.push_back(cloneBuffer(tmpBuffers[i])));
                        ASSERT_NO_FATAL_FAILURE(
                                bufferHandles.push_back(cloneBuffer(tmpBuffers[i])));
                    }
                    }
                }
                }


@@ -127,7 +137,7 @@ const native_handle_t* Gralloc::allocate(const IMapper::BufferDescriptorInfo& de
    }
    }


    auto buffers = allocate(descriptor, 1, import, outStride);
    auto buffers = allocate(descriptor, 1, import, outStride);
    if (::testing::Test::HasFatalFailure()) {
    if (::testing::Test::HasFatalFailure() || ::testing::Test::IsSkipped()) {
        return nullptr;
        return nullptr;
    }
    }


+4 −0
Original line number Original line Diff line number Diff line
@@ -337,6 +337,10 @@ TEST_P(GraphicsMapperHidlTest, LockYCbCrP010) {
    uint32_t stride;
    uint32_t stride;
    ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(info, true, &stride));
    ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(info, true, &stride));


    if (::testing::Test::IsSkipped()) {
        GTEST_SKIP();
    }

    ASSERT_NE(nullptr, bufferHandle);
    ASSERT_NE(nullptr, bufferHandle);


    const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
    const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
+10 −6
Original line number Original line Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include <android-base/properties.h>
#include <gralloctypes/Gralloc4.h>
#include <gralloctypes/Gralloc4.h>
#include <mapper-vts/4.0/MapperVts.h>
#include <mapper-vts/4.0/MapperVts.h>


@@ -95,7 +96,14 @@ std::vector<const native_handle_t*> Gralloc::allocate(const BufferDescriptor& de
                                 return;
                                 return;
                             }
                             }


                             ASSERT_EQ(Error::NONE, tmpError) << "failed to allocate buffers";
                             if (tmpError != Error::NONE) {
                                 if (base::GetIntProperty("ro.vendor.build.version.sdk", 0, 0,
                                                          INT_MAX) < 33) {
                                     GTEST_SKIP() << "Old vendor grallocs may not support P010";
                                 } else {
                                     GTEST_FAIL() << "failed to allocate buffers";
                                 }
                             }
                             ASSERT_EQ(count, tmpBuffers.size()) << "invalid buffer array";
                             ASSERT_EQ(count, tmpBuffers.size()) << "invalid buffer array";


                             for (uint32_t i = 0; i < count; i++) {
                             for (uint32_t i = 0; i < count; i++) {
@@ -133,11 +141,7 @@ const native_handle_t* Gralloc::allocate(const IMapper::BufferDescriptorInfo& de
    }
    }


    auto buffers = allocate(descriptor, 1, import, tolerance, outStride);
    auto buffers = allocate(descriptor, 1, import, tolerance, outStride);
    if (::testing::Test::HasFatalFailure()) {
    if (::testing::Test::HasFatalFailure() || ::testing::Test::IsSkipped() || buffers.size() != 1) {
        return nullptr;
    }

    if (buffers.size() != 1) {
        return nullptr;
        return nullptr;
    }
    }
    return buffers[0];
    return buffers[0];
+6 −3
Original line number Original line Diff line number Diff line
@@ -999,10 +999,13 @@ TEST_P(GraphicsMapperHidlTest, Lock_YCBCR_P010) {
    auto info = mDummyDescriptorInfo;
    auto info = mDummyDescriptorInfo;
    info.format = PixelFormat::YCBCR_P010;
    info.format = PixelFormat::YCBCR_P010;


    const native_handle_t* bufferHandle;
    uint32_t stride;
    uint32_t stride;
    ASSERT_NO_FATAL_FAILURE(
    const native_handle_t* bufferHandle =
            bufferHandle = mGralloc->allocate(info, true, Tolerance::kToleranceStrict, &stride));
            mGralloc->allocate(info, true, Tolerance::kToleranceStrict, &stride);

    if (::testing::Test::IsSkipped()) {
        GTEST_SKIP();
    }


    const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
    const IMapper::Rect region{0, 0, static_cast<int32_t>(info.width),
                               static_cast<int32_t>(info.height)};
                               static_cast<int32_t>(info.height)};