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

Commit b4b63704 authored by Zhijun He's avatar Zhijun He
Browse files

CpuConsumer: Add set buffer size and format functions.

Add setDefaultBufferSize() and setDefaultBufferFormat(). ImageReader JNI need
them.

Bug: 9254294
Change-Id: I7d2464d43b0ca73fbb834ed22cecbfbb30eef60c
parent 1eae0ee4
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -72,6 +72,18 @@ class CpuConsumer : public ConsumerBase
    // log messages.
    void setName(const String8& name);

    // setDefaultBufferSize is used to set the size of buffers returned by
    // requestBuffers when a width and height of zero is requested.
    // A call to setDefaultBufferSize() may trigger requestBuffers() to
    // be called from the client. Default size is 1x1.
    status_t setDefaultBufferSize(uint32_t width, uint32_t height);

    // setDefaultBufferFormat allows CpuConsumer's BufferQueue to create buffers
    // of a defaultFormat if no format is specified by producer. Formats are
    // enumerated in graphics.h; the initial default is
    // HAL_PIXEL_FORMAT_RGBA_8888.
    status_t setDefaultBufferFormat(uint32_t defaultFormat);

    // Gets the next graphics buffer from the producer and locks it for CPU use,
    // filling out the passed-in locked buffer structure with the native pointer
    // and metadata. Returns BAD_VALUE if no new buffer is available, and
+12 −0
Original line number Diff line number Diff line
@@ -55,6 +55,18 @@ void CpuConsumer::setName(const String8& name) {
    mBufferQueue->setConsumerName(name);
}

status_t CpuConsumer::setDefaultBufferSize(uint32_t width, uint32_t height)
{
    Mutex::Autolock _l(mMutex);
    return mBufferQueue->setDefaultBufferSize(width, height);
}

status_t CpuConsumer::setDefaultBufferFormat(uint32_t defaultFormat)
{
    Mutex::Autolock _l(mMutex);
    return mBufferQueue->setDefaultBufferFormat(defaultFormat);
}

status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
    status_t err;