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

Commit 4f741a43 authored by Dohyun Lee's avatar Dohyun Lee Committed by Steve Kondik
Browse files

Assign more reasonable width and height of a window surface



When the surface of a window is created during relayoutWindow,
there is the case that the width and height of the surface are
not given appropriately, e.g. the staring windows.
In this case, the width and height are set to 1, which cause
resizing the size of the surface during setSurfaceBoundariesLocked.
Since setting the size of a surface is processed synchronously
in the SurfaceFlinger, there is usually a few milliseconds
delay (up to 1 vsync interval) when we launch an application.

To remove such cases, this patch assign the width and height
more reasonably like below:

 1. If FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS is set then assign
    the size of the display we can use.
   (i.e. DisplayInfo.logical[Width|Height])

 2. Otherwise, assign the width and height of the portion of
    the display that is available to applications.
    (i.e. DisplayInfo.app[Width|Height])

Change-Id: Ie8265b9ff0fdb6ecc4577687935adf7cfb4439ad
Signed-off-by: default avatarDohyun Lee <dohyun.lee@lge.com>
parent 66a76e5f
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -803,6 +803,24 @@ class WindowStateAnimator {
                flags |= SurfaceControl.SECURE;
            }

            final boolean consumingNavBar =
                    (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
                    && (attrs.systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0
                    && (attrs.systemUiVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;

            final DisplayContent displayContent = w.getDisplayContent();

            int defaultWidth = 1;
            int defaultHeight = 1;
            if (displayContent != null) {
                final DisplayInfo displayInfo = displayContent.getDisplayInfo();
                // When we need to expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
                // set the default width and height of the window to the size of the display
                // we can use.
                defaultWidth = consumingNavBar ? displayInfo.logicalWidth : displayInfo.appWidth;
                defaultHeight = consumingNavBar ? displayInfo.logicalHeight : displayInfo.appHeight;
            }

            int width;
            int height;
            if ((attrs.flags & LayoutParams.FLAG_SCALED) != 0) {
@@ -811,17 +829,17 @@ class WindowStateAnimator {
                width = w.mRequestedWidth;
                height = w.mRequestedHeight;
            } else {
                width = w.mCompatFrame.width();
                height = w.mCompatFrame.height();
                width = consumingNavBar ? defaultWidth : w.mCompatFrame.width();
                height = consumingNavBar ? defaultHeight : w.mCompatFrame.height();
            }

            // Something is wrong and SurfaceFlinger will not like this,
            // try to revert to sane values
            if (width <= 0) {
                width = 1;
                width = defaultWidth;
            }
            if (height <= 0) {
                height = 1;
                height = defaultHeight;
            }

            float left = w.mFrame.left + w.mXOffset;
@@ -925,7 +943,6 @@ class WindowStateAnimator {
                try {
                    mSurfaceControl.setPosition(left, top);
                    mSurfaceLayer = mAnimLayer;
                    final DisplayContent displayContent = w.getDisplayContent();
                    if (displayContent != null) {
                        mLayerStack = displayContent.getDisplay().getLayerStack();
                        mSurfaceControl.setLayerStack(mLayerStack);