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

Commit 174a48b5 authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Update the size of SurfaceControl after display changed"

parents 609ae206 7501e336
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ message DisplayContentProto {
    optional int32 rotation = 11;
    optional ScreenRotationAnimationProto screen_rotation_animation = 12;
    optional DisplayFramesProto display_frames = 13;
    optional int32 surface_size = 14;
}

/* represents DisplayFrames */
@@ -211,6 +212,8 @@ message TaskProto {
    optional .android.graphics.RectProto bounds = 5;
    optional .android.graphics.RectProto temp_inset_bounds = 6;
    optional bool defer_removal = 7;
    optional int32 surface_width = 8;
    optional int32 surface_height = 9;
}

/* represents AppWindowToken */
+6 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ import static com.android.server.wm.DisplayContentProto.PINNED_STACK_CONTROLLER;
import static com.android.server.wm.DisplayContentProto.ROTATION;
import static com.android.server.wm.DisplayContentProto.SCREEN_ROTATION_ANIMATION;
import static com.android.server.wm.DisplayContentProto.STACKS;
import static com.android.server.wm.DisplayContentProto.SURFACE_SIZE;
import static com.android.server.wm.DisplayContentProto.WINDOW_CONTAINER;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_BOOT;
@@ -2409,6 +2410,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            screenRotationAnimation.writeToProto(proto, SCREEN_ROTATION_ANIMATION);
        }
        mDisplayFrames.writeToProto(proto, DISPLAY_FRAMES);
        proto.write(SURFACE_SIZE, mSurfaceSize);
        proto.end(token);
    }

@@ -3151,6 +3153,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }
    }

    int getSurfaceSize() {
        return mSurfaceSize;
    }

    void performLayout(boolean initial, boolean updateInputWindows) {
        if (!isLayoutNeeded()) {
            return;
+10 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import static com.android.server.wm.TaskProto.BOUNDS;
import static com.android.server.wm.TaskProto.DEFER_REMOVAL;
import static com.android.server.wm.TaskProto.FILLS_PARENT;
import static com.android.server.wm.TaskProto.ID;
import static com.android.server.wm.TaskProto.SURFACE_HEIGHT;
import static com.android.server.wm.TaskProto.SURFACE_WIDTH;
import static com.android.server.wm.TaskProto.TEMP_INSET_BOUNDS;
import static com.android.server.wm.TaskProto.WINDOW_CONTAINER;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK;
@@ -297,6 +299,12 @@ class Task extends WindowContainer<AppWindowToken> {
        return boundsChange;
    }

    @Override
    void onDisplayChanged(DisplayContent dc) {
        updateSurfaceSize(dc);
        super.onDisplayChanged(dc);
    }

    /**
     * Sets the bounds used to calculate the insets. See
     * {@link android.app.IActivityTaskManager#resizeDockedStack} why this is needed.
@@ -703,6 +711,8 @@ class Task extends WindowContainer<AppWindowToken> {
        getBounds().writeToProto(proto, BOUNDS);
        mTempInsetBounds.writeToProto(proto, TEMP_INSET_BOUNDS);
        proto.write(DEFER_REMOVAL, mDeferRemoval);
        proto.write(SURFACE_WIDTH, mSurfaceControl.getWidth());
        proto.write(SURFACE_HEIGHT, mSurfaceControl.getHeight());
        proto.end(token);
    }

+22 −3
Original line number Diff line number Diff line
@@ -20,13 +20,14 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.view.SurfaceControl.Transaction;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

import static com.android.server.wm.WindowContainerProto.CONFIGURATION_CONTAINER;
import static com.android.server.wm.WindowContainerProto.ORIENTATION;
import static com.android.server.wm.WindowContainerProto.SURFACE_ANIMATOR;
import static com.android.server.wm.WindowContainerProto.VISIBLE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

import android.annotation.CallSuper;
import android.annotation.IntDef;
@@ -503,6 +504,24 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        }
    }

    /**
     * Update the surface size when display changed in order to avoid children being bound by the
     * old display size.
     *
     * Note that we don't want to apply this to all layers, but only limiting this to layers that
     * don't set their own size ({@link Task}, {@link WindowState} and {@link WindowToken}).
     */
    void updateSurfaceSize(DisplayContent dc) {
        if (mSurfaceControl == null) {
            return;
        }

        final int newSurfaceSize = dc.getSurfaceSize();
        if (mSurfaceControl.getWidth() != newSurfaceSize) {
            getPendingTransaction().setSize(mSurfaceControl, newSurfaceSize, newSurfaceSize);
        }
    }

    void setWaitingForDrawnIfResizingChanged() {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final WindowContainer wc = mChildren.get(i);
+1 −0
Original line number Diff line number Diff line
@@ -1259,6 +1259,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

    @Override
    void onDisplayChanged(DisplayContent dc) {
        updateSurfaceSize(dc);
        super.onDisplayChanged(dc);
        // Window was not laid out for this display yet, so make sure mLayoutSeq does not match.
        if (dc != null) {
Loading