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

Commit 56832046 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera2: Consolidate the overriding of PRIVATE format"

parents a62415dd 71e6d62d
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -348,9 +348,7 @@ public class LegacyCameraDevice implements AutoCloseable {

                    Size[] sizes = streamConfigurations.getOutputSizes(surfaceType);
                    if (sizes == null) {
                        // WAR: Override default format to IMPLEMENTATION_DEFINED for b/9487482
                        if ((surfaceType >= LegacyMetadataMapper.HAL_PIXEL_FORMAT_RGBA_8888 &&
                            surfaceType <= LegacyMetadataMapper.HAL_PIXEL_FORMAT_BGRA_8888)) {
                        if (surfaceType == ImageFormat.PRIVATE) {

                            // YUV_420_888 is always present in LEGACY for all
                            // IMPLEMENTATION_DEFINED output sizes, and is publicly visible in the
@@ -649,7 +647,16 @@ public class LegacyCameraDevice implements AutoCloseable {
     */
    public static int detectSurfaceType(Surface surface) throws BufferQueueAbandonedException {
        checkNotNull(surface);
        return LegacyExceptionUtils.throwOnError(nativeDetectSurfaceType(surface));
        int surfaceType = nativeDetectSurfaceType(surface);

        // TODO: remove this override since the default format should be
        // ImageFormat.PRIVATE. b/9487482
        if ((surfaceType >= LegacyMetadataMapper.HAL_PIXEL_FORMAT_RGBA_8888 &&
                surfaceType <= LegacyMetadataMapper.HAL_PIXEL_FORMAT_BGRA_8888)) {
            surfaceType = ImageFormat.PRIVATE;
        }

        return LegacyExceptionUtils.throwOnError(surfaceType);
    }

    /**
+0 −6
Original line number Diff line number Diff line
@@ -408,12 +408,6 @@ public final class StreamConfigurationMap {
        // See if consumer is flexible.
        boolean isFlexible = SurfaceUtils.isFlexibleConsumer(surface);

        // Override RGB formats to IMPLEMENTATION_DEFINED, b/9487482
        if ((surfaceFormat >= LegacyMetadataMapper.HAL_PIXEL_FORMAT_RGBA_8888 &&
                        surfaceFormat <= LegacyMetadataMapper.HAL_PIXEL_FORMAT_BGRA_8888)) {
            surfaceFormat = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
        }

        StreamConfiguration[] configs =
                surfaceDataspace != HAL_DATASPACE_DEPTH ? mConfigurations : mDepthConfigurations;
        for (StreamConfiguration config : configs) {
+0 −8
Original line number Diff line number Diff line
@@ -118,15 +118,7 @@ public class SurfaceUtils {
     * @param surface The high speed output surface to be checked.
     */
    private static void checkHighSpeedSurfaceFormat(Surface surface) {
        // TODO: remove this override since the default format should be
        // ImageFormat.PRIVATE. b/9487482
        final int HAL_FORMAT_RGB_START = 1; // HAL_PIXEL_FORMAT_RGBA_8888 from graphics.h
        final int HAL_FORMAT_RGB_END = 5; // HAL_PIXEL_FORMAT_BGRA_8888 from graphics.h
        int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface);
        if (surfaceFormat >= HAL_FORMAT_RGB_START &&
                surfaceFormat <= HAL_FORMAT_RGB_END) {
            surfaceFormat = ImageFormat.PRIVATE;
        }

        if (surfaceFormat != ImageFormat.PRIVATE) {
            throw new IllegalArgumentException("Surface format(" + surfaceFormat + ") is not"