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

Commit 30360556 authored by Valerie Hau's avatar Valerie Hau
Browse files

Preserve intended width/height for Blast adapter layers

Some surfaces may be a different size from the requested width/height.
Pass back calculated width/height from WindowStateAnimator back to
ViewRootImpl

Bug: 147674215, 147689472
Test: build, boot, manual
Change-Id: Ib557a4769d79e6414b9bebab8cb006adfb551e4d
parent da935681
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat

import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.RemoteException;
import android.perftests.utils.BenchmarkState;
@@ -149,7 +150,7 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase {
                        mViewVisibility.getAsInt(), mFlags, mFrameNumber, mOutFrame,
                        mOutContentInsets, mOutVisibleInsets, mOutStableInsets,
                        mOutBackDropFrame, mOutDisplayCutout, mOutMergedConfiguration,
                        mOutSurfaceControl, mOutInsetsState);
                        mOutSurfaceControl, mOutInsetsState, new Point());
            }
        }
    }
+4 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
@@ -188,6 +189,7 @@ public abstract class WallpaperService extends Service {
        DisplayCutout mDispatchedDisplayCutout = DisplayCutout.NO_CUTOUT;
        final InsetsState mInsetsState = new InsetsState();
        final MergedConfiguration mMergedConfiguration = new MergedConfiguration();
        private final Point mSurfaceSize = new Point();

        final WindowManager.LayoutParams mLayout
                = new WindowManager.LayoutParams();
@@ -838,12 +840,13 @@ public abstract class WallpaperService extends Service {
                    } else {
                        mLayout.surfaceInsets.set(0, 0, 0, 0);
                    }

                    final int relayoutResult = mSession.relayout(
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, -1, mWinFrame, mContentInsets,
                            mVisibleInsets, mStableInsets, mBackdropFrame,
                            mDisplayCutout, mMergedConfiguration, mSurfaceControl,
                            mInsetsState);
                            mInsetsState, mSurfaceSize);
                    if (mSurfaceControl.isValid()) {
                        mSurfaceHolder.mSurface.copyFrom(mSurfaceControl);
                        mSurfaceControl.release();
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
package android.view;

import android.content.ClipData;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Bundle;
@@ -90,6 +91,7 @@ interface IWindowSession {
     * since it was last displayed.
     * @param outSurface Object in which is placed the new display surface.
     * @param insetsState The current insets state in the system.
     * @param outSurfaceSize The width and height of the surface control
     *
     * @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_SHOW_FOCUS},
     * {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
@@ -101,7 +103,7 @@ interface IWindowSession {
            out Rect outBackdropFrame,
            out DisplayCutout.ParcelableWrapper displayCutout,
            out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
            out InsetsState insetsState);
            out InsetsState insetsState, out Point outSurfaceSize);

    /*
     * Notify the window manager that an application is relaunching and
+7 −4
Original line number Diff line number Diff line
@@ -423,6 +423,10 @@ public final class ViewRootImpl implements ViewParent,
    FallbackEventHandler mFallbackEventHandler;
    Choreographer mChoreographer;

    // used in relayout to get SurfaceControl size
    // for BLAST adapter surface setup
    private final Point mSurfaceSize = new Point();

    final Rect mTempRect; // used in the transaction to not thrash the heap.
    final Rect mVisRect; // used to retrieve visible rect of focused view.
    private final Rect mTempBoundsRect = new Rect(); // used to set the size of the bounds surface.
@@ -7278,14 +7282,13 @@ public final class ViewRootImpl implements ViewParent,
                insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber,
                mTmpFrame, mPendingContentInsets, mPendingVisibleInsets,
                mPendingStableInsets, mPendingBackDropFrame, mPendingDisplayCutout,
                mPendingMergedConfiguration, mSurfaceControl, mTempInsets);
                mPendingMergedConfiguration, mSurfaceControl, mTempInsets, mSurfaceSize);
        if (mSurfaceControl.isValid()) {
            if (!WindowManagerGlobal.USE_BLAST_ADAPTER) {
                mSurface.copyFrom(mSurfaceControl);
            } else {
                mSurface.transferFrom(getOrCreateBLASTSurface(
                    (int) (mView.getMeasuredWidth() * appScale + 0.5f),
                    (int) (mView.getMeasuredHeight() * appScale + 0.5f)));
                mSurface.transferFrom(getOrCreateBLASTSurface(mSurfaceSize.x,
                        mSurfaceSize.y));
            }
        } else {
            destroySurface();
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.view;

import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.IBinder;
import android.os.RemoteException;
@@ -159,7 +160,8 @@ public class WindowlessWindowManager implements IWindowSession {
            Rect outFrame, Rect outContentInsets, Rect outVisibleInsets,
            Rect outStableInsets, Rect outBackdropFrame,
            DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration,
            SurfaceControl outSurfaceControl, InsetsState outInsetsState) {
            SurfaceControl outSurfaceControl, InsetsState outInsetsState,
            Point outSurfaceSize) {
        State state = null;
        synchronized (this) {
            state = mStateForWindow.get(window.asBinder());
Loading