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

Commit 306ae273 authored by Jason Macnak's avatar Jason Macnak Committed by Automerger Merge Worker
Browse files

Merge "Support AHardwareBuffer_lockPlanes() with P010" am: 24350bb0

parents d536f300 24350bb0
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -207,7 +207,11 @@ int AHardwareBuffer_lockPlanes(AHardwareBuffer* buffer, uint64_t usage,
      if (result == 0) {
      if (result == 0) {
        outPlanes->planeCount = 3;
        outPlanes->planeCount = 3;
        outPlanes->planes[0].data = yuvData.y;
        outPlanes->planes[0].data = yuvData.y;
        if (format == AHARDWAREBUFFER_FORMAT_YCbCr_P010) {
            outPlanes->planes[0].pixelStride = 2;
        } else {
            outPlanes->planes[0].pixelStride = 1;
            outPlanes->planes[0].pixelStride = 1;
        }
        outPlanes->planes[0].rowStride = yuvData.ystride;
        outPlanes->planes[0].rowStride = yuvData.ystride;
        outPlanes->planes[1].data = yuvData.cb;
        outPlanes->planes[1].data = yuvData.cb;
        outPlanes->planes[1].pixelStride = yuvData.chroma_step;
        outPlanes->planes[1].pixelStride = yuvData.chroma_step;
+9 −9
Original line number Original line Diff line number Diff line
@@ -300,20 +300,19 @@ status_t Gralloc4Mapper::lock(buffer_handle_t bufferHandle, uint64_t usage, cons
            if (!gralloc4::isStandardPlaneLayoutComponentType(planeLayoutComponent.type)) {
            if (!gralloc4::isStandardPlaneLayoutComponentType(planeLayoutComponent.type)) {
                continue;
                continue;
            }
            }
            if (0 != planeLayoutComponent.offsetInBits % 8) {
                unlock(bufferHandle);
                return BAD_VALUE;
            }


            uint8_t* tmpData = static_cast<uint8_t*>(data) + planeLayout.offsetInBytes +
            uint8_t* tmpData = static_cast<uint8_t*>(data) + planeLayout.offsetInBytes;
                    (planeLayoutComponent.offsetInBits / 8);

            // Note that `offsetInBits` may not be a multiple of 8 for packed formats (e.g. P010)
            // but we still want to point to the start of the first byte.
            tmpData += (planeLayoutComponent.offsetInBits / 8);

            uint64_t sampleIncrementInBytes;
            uint64_t sampleIncrementInBytes;


            auto type = static_cast<PlaneLayoutComponentType>(planeLayoutComponent.type.value);
            auto type = static_cast<PlaneLayoutComponentType>(planeLayoutComponent.type.value);
            switch (type) {
            switch (type) {
                case PlaneLayoutComponentType::Y:
                case PlaneLayoutComponentType::Y:
                    if ((ycbcr.y != nullptr) || (planeLayoutComponent.sizeInBits != 8) ||
                    if ((ycbcr.y != nullptr) || (planeLayout.sampleIncrementInBits % 8 != 0)) {
                        (planeLayout.sampleIncrementInBits != 8)) {
                        unlock(bufferHandle);
                        unlock(bufferHandle);
                        return BAD_VALUE;
                        return BAD_VALUE;
                    }
                    }
@@ -329,7 +328,8 @@ status_t Gralloc4Mapper::lock(buffer_handle_t bufferHandle, uint64_t usage, cons
                    }
                    }


                    sampleIncrementInBytes = planeLayout.sampleIncrementInBits / 8;
                    sampleIncrementInBytes = planeLayout.sampleIncrementInBits / 8;
                    if ((sampleIncrementInBytes != 1) && (sampleIncrementInBytes != 2)) {
                    if ((sampleIncrementInBytes != 1) && (sampleIncrementInBytes != 2) &&
                        (sampleIncrementInBytes != 4)) {
                        unlock(bufferHandle);
                        unlock(bufferHandle);
                        return BAD_VALUE;
                        return BAD_VALUE;
                    }
                    }