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

Commit 442ba547 authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Add letterboxInsets to TaskSnapshot" into sc-v2-dev

parents 5c400743 2dcd8f56
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class TaskSnapshot implements Parcelable {
    /** The size of the snapshot before scaling */
    private final Point mTaskSize;
    private final Rect mContentInsets;
    private final Rect mLetterboxInsets;
    // Whether this snapshot is a down-sampled version of the high resolution snapshot, used
    // mainly for loading snapshots quickly from disk when user is flinging fast
    private final boolean mIsLowResolution;
@@ -67,9 +68,10 @@ public class TaskSnapshot implements Parcelable {
    public TaskSnapshot(long id,
            @NonNull ComponentName topActivityComponent, HardwareBuffer snapshot,
            @NonNull ColorSpace colorSpace, int orientation, int rotation, Point taskSize,
            Rect contentInsets, boolean isLowResolution, boolean isRealSnapshot,
            int windowingMode, @WindowInsetsController.Appearance int appearance,
            boolean isTranslucent, boolean hasImeSurface) {
            Rect contentInsets, Rect letterboxInsets, boolean isLowResolution,
            boolean isRealSnapshot, int windowingMode,
            @WindowInsetsController.Appearance int appearance, boolean isTranslucent,
            boolean hasImeSurface) {
        mId = id;
        mTopActivityComponent = topActivityComponent;
        mSnapshot = snapshot;
@@ -79,6 +81,7 @@ public class TaskSnapshot implements Parcelable {
        mRotation = rotation;
        mTaskSize = new Point(taskSize);
        mContentInsets = new Rect(contentInsets);
        mLetterboxInsets = new Rect(letterboxInsets);
        mIsLowResolution = isLowResolution;
        mIsRealSnapshot = isRealSnapshot;
        mWindowingMode = windowingMode;
@@ -99,6 +102,7 @@ public class TaskSnapshot implements Parcelable {
        mRotation = source.readInt();
        mTaskSize = source.readTypedObject(Point.CREATOR);
        mContentInsets = source.readTypedObject(Rect.CREATOR);
        mLetterboxInsets = source.readTypedObject(Rect.CREATOR);
        mIsLowResolution = source.readBoolean();
        mIsRealSnapshot = source.readBoolean();
        mWindowingMode = source.readInt();
@@ -178,6 +182,14 @@ public class TaskSnapshot implements Parcelable {
        return mContentInsets;
    }

    /**
     * @return The letterbox insets on the snapshot. These can be clipped off in order to
     *         remove any letterbox areas in the snapshot.
     */
    public Rect getLetterboxInsets() {
        return mLetterboxInsets;
    }

    /**
     * @return Whether this snapshot is a down-sampled version of the full resolution.
     */
@@ -241,6 +253,7 @@ public class TaskSnapshot implements Parcelable {
        dest.writeInt(mRotation);
        dest.writeTypedObject(mTaskSize, 0);
        dest.writeTypedObject(mContentInsets, 0);
        dest.writeTypedObject(mLetterboxInsets, 0);
        dest.writeBoolean(mIsLowResolution);
        dest.writeBoolean(mIsRealSnapshot);
        dest.writeInt(mWindowingMode);
@@ -262,6 +275,7 @@ public class TaskSnapshot implements Parcelable {
                + " mRotation=" + mRotation
                + " mTaskSize=" + mTaskSize.toString()
                + " mContentInsets=" + mContentInsets.toShortString()
                + " mLetterboxInsets=" + mLetterboxInsets.toShortString()
                + " mIsLowResolution=" + mIsLowResolution
                + " mIsRealSnapshot=" + mIsRealSnapshot
                + " mWindowingMode=" + mWindowingMode
@@ -289,6 +303,7 @@ public class TaskSnapshot implements Parcelable {
        private int mRotation;
        private Point mTaskSize;
        private Rect mContentInsets;
        private Rect mLetterboxInsets;
        private boolean mIsRealSnapshot;
        private int mWindowingMode;
        private @WindowInsetsController.Appearance
@@ -340,6 +355,11 @@ public class TaskSnapshot implements Parcelable {
            return this;
        }

        public Builder setLetterboxInsets(Rect letterboxInsets) {
            mLetterboxInsets = letterboxInsets;
            return this;
        }

        public Builder setIsRealSnapshot(boolean realSnapshot) {
            mIsRealSnapshot = realSnapshot;
            return this;
@@ -387,6 +407,7 @@ public class TaskSnapshot implements Parcelable {
                    mRotation,
                    mTaskSize,
                    mContentInsets,
                    mLetterboxInsets,
                    // When building a TaskSnapshot with the Builder class, isLowResolution
                    // is always false. Low-res snapshots are only created when loading from
                    // disk.
+2 −2
Original line number Diff line number Diff line
@@ -301,8 +301,8 @@ public class StartingSurfaceDrawerTests {
                System.currentTimeMillis(),
                new ComponentName("", ""), buffer,
                ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
                Surface.ROTATION_0, taskSize, contentInsets, false,
                true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
                Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */,
                false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
                0 /* systemUiVisibility */, false /* isTranslucent */,
                hasImeSurface /* hasImeSurface */);
    }
+2 −2
Original line number Diff line number Diff line
@@ -94,8 +94,8 @@ public class TaskSnapshotWindowTest {
                System.currentTimeMillis(),
                new ComponentName("", ""), buffer,
                ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
                Surface.ROTATION_0, taskSize, contentInsets, false,
                true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
                Surface.ROTATION_0, taskSize, contentInsets, new Rect() /* letterboxInsets */,
                false, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
                0 /* systemUiVisibility */, false /* isTranslucent */, false /* hasImeSurface */);
    }

+3 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public class ThumbnailData {
    public int orientation;
    public int rotation;
    public Rect insets;
    public Rect letterboxInsets;
    public boolean reducedResolution;
    public boolean isRealSnapshot;
    public boolean isTranslucent;
@@ -55,6 +56,7 @@ public class ThumbnailData {
        orientation = ORIENTATION_UNDEFINED;
        rotation = ROTATION_UNDEFINED;
        insets = new Rect();
        letterboxInsets = new Rect();
        reducedResolution = false;
        scale = 1f;
        isRealSnapshot = true;
@@ -97,6 +99,7 @@ public class ThumbnailData {
    public ThumbnailData(TaskSnapshot snapshot) {
        thumbnail = makeThumbnail(snapshot);
        insets = new Rect(snapshot.getContentInsets());
        letterboxInsets = new Rect(snapshot.getLetterboxInsets());
        orientation = snapshot.getOrientation();
        rotation = snapshot.getRotation();
        reducedResolution = snapshot.isLowResolution();
+4 −0
Original line number Diff line number Diff line
@@ -41,4 +41,8 @@
     // The task height when the snapshot was taken
     int32 task_height = 15;
     int32 appearance = 16;
     int32 letterbox_inset_left = 17;
     int32 letterbox_inset_top = 18;
     int32 letterbox_inset_right = 19;
     int32 letterbox_inset_bottom = 20;
 }
Loading