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

Commit 4f55f166 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

libui: use IMapper::createDescriptor_2_1

Update using's in Gralloc2.h to be based on common@1.1 and
mapper@2.1.  Use IMapper::createDescriptor_2_1 when it is available.

Test: manual
Change-Id: Id4f805a93a5e9a6cde9ecece7dd4954dec337060
parent c6d738a3
Loading
Loading
Loading
Loading
+26 −23
Original line number Diff line number Diff line
@@ -57,8 +57,7 @@ uint64_t getValid11UsageBits() {
        for (const auto bit : hardware::hidl_enum_iterator<BufferUsage>()) {
            bits = bits | bit;
        }
        // Return only the overlapping bits.
        return bits & ~getValid10UsageBits();
        return bits;
    }();
    return valid11UsageBits;
}
@@ -71,7 +70,7 @@ void Mapper::preload() {

Mapper::Mapper()
{
    mMapper = IMapper::getService();
    mMapper = hardware::graphics::mapper::V2_0::IMapper::getService();
    if (mMapper == nullptr) {
        LOG_ALWAYS_FATAL("gralloc-mapper is missing");
    }
@@ -80,7 +79,7 @@ Mapper::Mapper()
    }

    // IMapper 2.1 is optional
    mMapperV2_1 = hardware::graphics::mapper::V2_1::IMapper::castFrom(mMapper);
    mMapperV2_1 = IMapper::castFrom(mMapper);
}

Gralloc2::Error Mapper::validateBufferDescriptorInfo(
@@ -102,22 +101,12 @@ Error Mapper::createDescriptor(
        const IMapper::BufferDescriptorInfo& descriptorInfo,
        BufferDescriptor* outDescriptor) const
{
    Error error;

    if (descriptorInfo.usage & getValid11UsageBits()) {
        // TODO(b/66900669): Use mMapperV2_1->createDescriptorV2_1().
        ALOGW("full support for new usage bits is unimplemented 0x%" PRIx64,
              descriptorInfo.usage & getValid11UsageBits());
        return Error::BAD_VALUE;
    }

    error = validateBufferDescriptorInfo(descriptorInfo);
    Error error = validateBufferDescriptorInfo(descriptorInfo);
    if (error != Error::NONE) {
        return error;
    }

    auto ret = mMapper->createDescriptor(descriptorInfo,
            [&](const auto& tmpError, const auto& tmpDescriptor)
    auto hidl_cb = [&](const auto& tmpError, const auto& tmpDescriptor)
                   {
                       error = tmpError;
                       if (error != Error::NONE) {
@@ -125,7 +114,21 @@ Error Mapper::createDescriptor(
                       }

                       *outDescriptor = tmpDescriptor;
            });
                   };

    hardware::Return<void> ret;
    if (mMapperV2_1 != nullptr) {
        ret = mMapperV2_1->createDescriptor_2_1(descriptorInfo, hidl_cb);
    } else {
        const hardware::graphics::mapper::V2_0::IMapper::BufferDescriptorInfo info = {
            descriptorInfo.width,
            descriptorInfo.height,
            descriptorInfo.layerCount,
            static_cast<hardware::graphics::common::V1_0::PixelFormat>(descriptorInfo.format),
            descriptorInfo.usage,
        };
        ret = mMapper->createDescriptor(info, hidl_cb);
    }

    return (ret.isOk()) ? error : kTransactionError;
}
+4 −4
Original line number Diff line number Diff line
@@ -30,11 +30,11 @@ namespace android {
namespace Gralloc2 {

using hardware::graphics::allocator::V2_0::IAllocator;
using hardware::graphics::common::V1_0::PixelFormat;
using hardware::graphics::common::V1_1::BufferUsage;
using hardware::graphics::common::V1_1::PixelFormat;
using hardware::graphics::mapper::V2_1::IMapper;
using hardware::graphics::mapper::V2_0::BufferDescriptor;
using hardware::graphics::mapper::V2_0::Error;
using hardware::graphics::mapper::V2_0::IMapper;
using hardware::graphics::mapper::V2_0::YCbCrLayout;

// A wrapper to IMapper
@@ -85,8 +85,8 @@ private:
    Error validateBufferDescriptorInfo(
            const IMapper::BufferDescriptorInfo& descriptorInfo) const;

    sp<IMapper> mMapper;
    sp<hardware::graphics::mapper::V2_1::IMapper> mMapperV2_1;
    sp<hardware::graphics::mapper::V2_0::IMapper> mMapper;
    sp<IMapper> mMapperV2_1;
};

// A wrapper to IAllocator