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

Commit a7d2de48 authored by Clément Julliard's avatar Clément Julliard
Browse files

Relax constraints on valid ImageReader usage flags

The only allowed format - usage pairs are currently:
* PRIVATE with USAGE_GPU_SAMPLED_IMAGE
* PRIVATE with USAGE_VIDEO_ENCODE
* PRIVATE with USAGE_GPU_SAMPLED_IMAGE | USAGE_VIDEO_ENCODE
* Non-PRIVATE with USAGE_CPU_READ_RARELY
* Non-PRIVATE with USAGE_CPU_READ_OFTEN

This commit enable other cases, ie. PRIVATE with
GRALLOC_USAGE_HW_COMPOSER.

Bug: 77148005
Test: Manually tested it.
Change-Id: I414c25bc62d52a3573461df6cec4d88512509ec4
parent d9afdee2
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -727,18 +727,7 @@ public class ImageReader implements AutoCloseable {
            return false;
        }

        if (format == ImageFormat.PRIVATE) {
            // Usage need to be either USAGE0_GPU_SAMPLED_IMAGE or USAGE0_VIDEO_ENCODE or combined.
            boolean isAllowed = (usage == HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE);
            isAllowed = isAllowed || (usage == HardwareBuffer.USAGE_VIDEO_ENCODE);
            isAllowed = isAllowed || (usage ==
                    (HardwareBuffer.USAGE_VIDEO_ENCODE | HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE));
            return isAllowed;
        } else {
            // Usage need to make the buffer CPU readable for explicit format.
            return ((usage == HardwareBuffer.USAGE_CPU_READ_RARELY) ||
                    (usage == HardwareBuffer.USAGE_CPU_READ_OFTEN));
        }
        return true;
    }

    /**