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

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

Merge "camera2 OutputConfiguration: update cached surface size before sending...

Merge "camera2 OutputConfiguration: update cached surface size before sending binder calls to cameraserver" into main
parents 77396b07 f84c2dd1
Loading
Loading
Loading
Loading
+24 −4
Original line number Diff line number Diff line
@@ -1167,6 +1167,21 @@ public final class OutputConfiguration implements Parcelable {
        return mIsDeferredConfig;
    }

    /**
     * Update the configured surface size to the latest surface size.
     * This function must be called right before any binder call sent to cameraserver
     * that references OutputConfiguration.
     * This is needed in order to update the cached surface size which may have changed
     * after OutputConfiguration's construction.
     *
     * @hide
     */
    public void updateCachedSurfaceSize() {
       Surface surface = getSurface();
        if (surface != null) {
            mConfiguredSize = SurfaceUtils.getSurfaceSize(surface);
        }
    }
    /**
     * Add a surface to this OutputConfiguration.
     *
@@ -1719,12 +1734,13 @@ public final class OutputConfiguration implements Parcelable {
    }

    /**
     * Get the configured size associated with this {@link OutputConfiguration}.
     * Get the latest configured size associated with this {@link OutputConfiguration}.
     *
     * @return The configured size associated with this {@link OutputConfiguration}.
     */
    @FlaggedApi(Flags.FLAG_OUTPUT_CONFIGURATION_GETTER)
    public @NonNull Size getConfiguredSize() {
        updateCachedSurfaceSize();
        return mConfiguredSize;
    }

@@ -1858,8 +1874,12 @@ public final class OutputConfiguration implements Parcelable {
        dest.writeInt(mRotation);
        dest.writeInt(mSurfaceGroupId);
        dest.writeInt(mSurfaceType);
        dest.writeInt(mConfiguredSize.getWidth());
        dest.writeInt(mConfiguredSize.getHeight());
        // Note: If / When OutputConfiguration becomes an auto-generated Parcelable,
        // OutputConfiguration.updateCachedSurfaceSize() needs to
        // be called before calling any binder call that references OutputConfiguration.
        Size configuredSize = getConfiguredSize();
        dest.writeInt(configuredSize.getWidth());
        dest.writeInt(configuredSize.getHeight());
        dest.writeInt(mIsDeferredConfig ? 1 : 0);
        dest.writeInt(mIsShared ? 1 : 0);
        dest.writeTypedList(mSurfaces);
@@ -2006,7 +2026,7 @@ public final class OutputConfiguration implements Parcelable {
    private final int mSurfaceType;

    // The size, format, and dataspace of the surface when OutputConfiguration is created.
    private final Size mConfiguredSize;
    private Size mConfiguredSize;
    private final int mConfiguredFormat;
    private final int mConfiguredDataspace;
    // The public facing format, a combination of mConfiguredFormat and mConfiguredDataspace