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

Commit 755ca9b4 authored by Jiwen 'Steve' Cai's avatar Jiwen 'Steve' Cai
Browse files

Use gralloc0 usage to init BufferItemConsumer

BufferItemConsumer is expecting gralloc0 usage, use
android_convertGralloc1To0Usage.

Also one minor log change: during acquireImageLocked, turn off the
warning when accquired buffer has different dimension than originally
configured on ImageReader. It is actually a legal operation for
IGraphicBufferProducer to change buffers dimension dynamically.

Bug: 35114769
Test: AImageReaderCts now passes with CPU_READ_OFTEN case.
Change-Id: I32015148437be56242a46c8e20ca33497e182ac2
parent 58a220fe
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@ LOCAL_CFLAGS += -fvisibility=hidden -D EXPORT='__attribute__ ((visibility ("defa

LOCAL_CFLAGS += -Werror -Wall

LOCAL_STATIC_LIBRARIES := \
    libgrallocusage \

LOCAL_SHARED_LIBRARIES := \
    libbinder \
    libmedia \
+6 −6
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <android_media_Utils.h>
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>
#include <grallocusage/GrallocUsageConversion.h>

using namespace android;

@@ -260,7 +261,8 @@ AImageReader::init() {
    uint64_t consumerUsage;
    android_hardware_HardwareBuffer_convertToGrallocUsageBits(
            &producerUsage, &consumerUsage, mUsage0, mUsage1);
    mHalUsage = consumerUsage;
    // Strip out producerUsage here.
    mHalUsage = android_convertGralloc1To0Usage(0, consumerUsage);

    sp<IGraphicBufferProducer> gbProducer;
    sp<IGraphicBufferConsumer> gbConsumer;
@@ -411,11 +413,9 @@ AImageReader::acquireImageLocked(/*out*/AImage** image, /*out*/int* acquireFence
        }

        // Check if the producer buffer configurations match what ImageReader configured.
        if ((bufferFmt != HAL_PIXEL_FORMAT_BLOB) && (readerFmt != HAL_PIXEL_FORMAT_BLOB) &&
                (readerWidth != bufferWidth || readerHeight != bufferHeight)) {
            ALOGW("%s: Buffer size: %dx%d, doesn't match AImageReader configured size: %dx%d",
        ALOGV_IF(readerWidth != bufferWidth || readerHeight != bufferHeight,
                "%s: Buffer size: %dx%d, doesn't match AImageReader configured size: %dx%d",
                __FUNCTION__, bufferWidth, bufferHeight, readerWidth, readerHeight);
        }

        // Check if the buffer usage is a super set of reader's usage bits, aka all usage bits that
        // ImageReader requested has been supported from the producer side.