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

Commit fcdd394f authored by Mathias Agopian's avatar Mathias Agopian
Browse files

Add support for direct EGLImageKHR use with pushbuffer API

We now always first try to use the EGLImageKHR directly before
making a copy with copybit. The copy may be needed when
EGLImage doesn't support the requested format, which is
currently the case with YUV.
parent 42d99d21
Loading
Loading
Loading
Loading
+30 −16
Original line number Diff line number Diff line
@@ -328,7 +328,8 @@ bool LayerBuffer::Source::transformed() const {

LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
        const ISurface::BufferHeap& buffers)
    : Source(layer), mStatus(NO_ERROR), mBufferSize(0)
    : Source(layer), mStatus(NO_ERROR), mBufferSize(0),
      mUseEGLImageDirectly(true)
{
    if (buffers.heap == NULL) {
        // this is allowed, but in this case, it is illegal to receive
@@ -466,8 +467,22 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const

#if defined(EGL_ANDROID_image_native_buffer)
    if (mLayer.mFlags & DisplayHardware::DIRECT_TEXTURE) {
        err = INVALID_OPERATION;
        if (ourBuffer->supportsCopybit()) {
            // First, try to use the buffer as an EGLImage directly
            if (mUseEGLImageDirectly) {
                // NOTE: Assume the buffer is allocated with the proper USAGE flags
                sp<GraphicBuffer> buffer = new  GraphicBuffer(
                        src.img.w, src.img.h, src.img.format,
                        GraphicBuffer::USAGE_HW_TEXTURE,
                        src.img.w, src.img.handle, false);
                err = mLayer.initializeEglImage(buffer, &mTexture);
                if (err != NO_ERROR) {
                    mUseEGLImageDirectly = false;
                }
            }
            copybit_device_t* copybit = mLayer.mBlitEngine;
        if (copybit && ourBuffer->supportsCopybit()) {
            if (copybit && err != NO_ERROR) {
                // create our EGLImageKHR the first time
                err = initTempBuffer();
                if (err == NO_ERROR) {
@@ -483,8 +498,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
                        clearTempBufferImage();
                    }
                }
        } else {
            err = INVALID_OPERATION;
            }
        }
    }
#endif
+1 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ private:
        mutable LayerBase::Texture      mTexture;
        mutable NativeBuffer            mTempBuffer;
        mutable sp<GraphicBuffer>       mTempGraphicBuffer;
        mutable bool                    mUseEGLImageDirectly;
    };
    
    class OverlaySource : public Source {