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

Commit aa90c193 authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Don't allow protected buffers in Bitmap#wrapHardwareBuffer"

parents cdf0a80f bc3dac3d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -782,10 +782,13 @@ public final class Bitmap implements Parcelable {
    @Nullable
    public static Bitmap wrapHardwareBuffer(@NonNull HardwareBuffer hardwareBuffer,
            @Nullable ColorSpace colorSpace) {
        if ((hardwareBuffer.getUsage() & HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE) == 0) {
        final long usage = hardwareBuffer.getUsage();
        if ((usage & HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE) == 0) {
            throw new IllegalArgumentException("usage flags must contain USAGE_GPU_SAMPLED_IMAGE.");
        }
        int format = hardwareBuffer.getFormat();
        if ((usage & HardwareBuffer.USAGE_PROTECTED_CONTENT) != 0) {
            throw new IllegalArgumentException("Bitmap is not compatible with protected buffers");
        }
        if (colorSpace == null) {
            colorSpace = ColorSpace.get(ColorSpace.Named.SRGB);
        }