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

Commit 660dc755 authored by Valerie Hau's avatar Valerie Hau Committed by Android (Google) Code Review
Browse files

Merge "Adding isSupported HIDL Mapper function support to framework"

parents aa8756d2 ddbfaeb7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -351,6 +351,12 @@ int Gralloc2Mapper::unlock(buffer_handle_t bufferHandle) const {
    return releaseFence;
}

status_t Gralloc2Mapper::isSupported(uint32_t /*width*/, uint32_t /*height*/,
                                     android::PixelFormat /*format*/, uint32_t /*layerCount*/,
                                     uint64_t /*usage*/, bool* /*outSupported*/) const {
    return INVALID_OPERATION;
}

Gralloc2Allocator::Gralloc2Allocator(const Gralloc2Mapper& mapper) : mMapper(mapper) {
    mAllocator = IAllocator::getService();
    if (mAllocator == nullptr) {
+30 −0
Original line number Diff line number Diff line
@@ -314,6 +314,36 @@ int Gralloc3Mapper::unlock(buffer_handle_t bufferHandle) const {
    return releaseFence;
}

status_t Gralloc3Mapper::isSupported(uint32_t width, uint32_t height, android::PixelFormat format,
                                     uint32_t layerCount, uint64_t usage,
                                     bool* outSupported) const {
    IMapper::BufferDescriptorInfo descriptorInfo;
    sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo);

    Error error;
    auto ret = mMapper->isSupported(descriptorInfo,
                                    [&](const auto& tmpError, const auto& tmpSupported) {
                                        error = tmpError;
                                        if (error != Error::NONE) {
                                            return;
                                        }
                                        if (outSupported) {
                                            *outSupported = tmpSupported;
                                        }
                                    });

    if (!ret.isOk()) {
        error = kTransactionError;
    }

    if (error != Error::NONE) {
        ALOGE("isSupported(%u, %u, %d, %u, ...) failed with %d", width, height, format, layerCount,
              error);
    }

    return static_cast<status_t>(error);
}

Gralloc3Allocator::Gralloc3Allocator(const Gralloc3Mapper& mapper) : mMapper(mapper) {
    mAllocator = IAllocator::getService();
    if (mAllocator == nullptr) {
+7 −0
Original line number Diff line number Diff line
@@ -344,6 +344,13 @@ status_t GraphicBuffer::unlockAsync(int *fenceFd)
    return res;
}

status_t GraphicBuffer::isSupported(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
                                    uint32_t inLayerCount, uint64_t inUsage,
                                    bool* outSupported) const {
    return mBufferMapper.isSupported(inWidth, inHeight, inFormat, inLayerCount, inUsage,
                                     outSupported);
}

size_t GraphicBuffer::getFlattenedSize() const {
    return static_cast<size_t>(13 + (handle ? mTransportNumInts : 0)) * sizeof(int);
}
+5 −0
Original line number Diff line number Diff line
@@ -161,5 +161,10 @@ status_t GraphicBufferMapper::unlockAsync(buffer_handle_t handle, int *fenceFd)
    return NO_ERROR;
}

status_t GraphicBufferMapper::isSupported(uint32_t width, uint32_t height,
                                          android::PixelFormat format, uint32_t layerCount,
                                          uint64_t usage, bool* outSupported) {
    return mMapper->isSupported(width, height, format, layerCount, usage, outSupported);
}
// ---------------------------------------------------------------------------
}; // namespace android
+9 −0
Original line number Diff line number Diff line
@@ -67,6 +67,15 @@ public:
    // unlock returns a fence sync object (or -1) and the fence sync object is
    // owned by the caller
    virtual int unlock(buffer_handle_t bufferHandle) const = 0;

    // isSupported queries whether or not a buffer with the given width, height,
    // format, layer count, and usage can be allocated on the device.  If
    // *outSupported is set to true, a buffer with the given specifications may be successfully
    // allocated if resources are available.  If false, a buffer with the given specifications will
    // never successfully allocate on this device. Note that this function is not guaranteed to be
    // supported on all devices, in which case a status_t of INVALID_OPERATION will be returned.
    virtual status_t isSupported(uint32_t width, uint32_t height, android::PixelFormat format,
                                 uint32_t layerCount, uint64_t usage, bool* outSupported) const = 0;
};

// A wrapper to IAllocator
Loading