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

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

fix [2291418] Camera preview cannot work in Emulator

The image buffer used by glTexImage2d() would be uninitialized when no copybit engine
can be found.
We now always initialize images, since the abscence of copybit is not necessarily fatal.
parent cc6ff2bc
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -266,6 +266,15 @@ LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset)
    : mBufferHeap(buffers)
{
    NativeBuffer& src(mNativeBuffer);
    src.crop.l = 0;
    src.crop.t = 0;
    src.crop.r = buffers.w;
    src.crop.b = buffers.h;

    src.img.w       = buffers.hor_stride ?: buffers.w;
    src.img.h       = buffers.ver_stride ?: buffers.h;
    src.img.format  = buffers.format;
    src.img.base    = (void*)(intptr_t(buffers.heap->base()) + offset);
    src.img.handle  = 0;

    gralloc_module_t const * module = LayerBuffer::getGrallocModule();
@@ -276,17 +285,10 @@ LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset)
                offset, buffers.heap->base(),
                &src.img.handle);

        if (err == NO_ERROR) {
            src.crop.l = 0;
            src.crop.t = 0;
            src.crop.r = buffers.w;
            src.crop.b = buffers.h;

            src.img.w       = buffers.hor_stride ?: buffers.w;
            src.img.h       = buffers.ver_stride ?: buffers.h;
            src.img.format  = buffers.format;
            src.img.base    = (void*)(intptr_t(buffers.heap->base()) + offset);
        }
        LOGE_IF(err, "CREATE_HANDLE_FROM_BUFFER (heapId=%d, size=%d, "
             "offset=%ld, base=%p) failed (%s)",
                buffers.heap->heapID(), buffers.heap->getSize(),
                offset, buffers.heap->base(), strerror(-err));
    }
 }