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

Commit a2414f06 authored by Valerie Hau's avatar Valerie Hau
Browse files

Adding support for Hal query in AHardwareBuffer isSupported

Bug: 120440873
Test: Build, boot, AHardwareBufferGLTest cts test
Change-Id: I980f621598214ca514f02fc2d9861dfb3fa3bb12
parent e34aa616
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -263,8 +263,17 @@ int AHardwareBuffer_isSupported(const AHardwareBuffer_Desc* desc) {
    if (!desc) return 0;
    if (!AHardwareBuffer_isValidDescription(desc, /*log=*/false)) return 0;

    // Make a trial allocation.
    // TODO(b/115660272): add implementation that uses a HAL query.
    bool supported = false;
    GraphicBuffer* gBuffer = new GraphicBuffer();
    status_t err = gBuffer->isSupported(desc->width, desc->height, desc->format, desc->layers,
                                        desc->usage, &supported);

    if (err == NO_ERROR) {
        return supported;
    }

    // function isSupported is not implemented on device or an error occurred during HAL
    // query.  Make a trial allocation.
    AHardwareBuffer_Desc trialDesc = *desc;
    trialDesc.width = 4;
    trialDesc.height = desc->format == AHARDWAREBUFFER_FORMAT_BLOB ? 1 : 4;