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
diff --git a/apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java b/apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java
index f32bf9a..c62aad6 100644
--- a/apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java
+++ b/apct-tests/perftests/core/src/android/wm/RelayoutPerfTest.java
@@ -20,6 +20,7 @@
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 @@
mViewVisibility.getAsInt(), mFlags, mFrameNumber, mOutFrame,
mOutContentInsets, mOutVisibleInsets, mOutStableInsets,
mOutBackDropFrame, mOutDisplayCutout, mOutMergedConfiguration,
- mOutSurfaceControl, mOutInsetsState);
+ mOutSurfaceControl, mOutInsetsState, new Point());
}
}
}
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 9a76a1b..e3fd8d2 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -31,6 +31,7 @@
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 @@
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 @@
} 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();
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index 8f25d89..e3446e1 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -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 @@
* 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 @@
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
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index e0f6e06..8809091 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -423,6 +423,10 @@
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 @@
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();
diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java
index 1312a9b..9f27848 100644
--- a/core/java/android/view/WindowlessWindowManager.java
+++ b/core/java/android/view/WindowlessWindowManager.java
@@ -18,6 +18,7 @@
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 @@
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());
diff --git a/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java b/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java
index 02c7857..5aba013 100644
--- a/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java
+++ b/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java
@@ -39,10 +39,10 @@
import android.view.InsetsSourceControl;
import android.view.InsetsState;
import android.view.SurfaceControl;
+import android.view.SurfaceControlViewHost;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
-import android.view.SurfaceControlViewHost;
import android.view.WindowlessWindowManager;
import com.android.internal.os.IResultReceiver;
@@ -238,11 +238,13 @@
long frameNumber, Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
Rect outVisibleInsets, Rect outStableInsets,
DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration,
- SurfaceControl outSurfaceControl, InsetsState outInsetsState) {
+ SurfaceControl outSurfaceControl, InsetsState outInsetsState,
+ Point outSurfaceSize) {
int res = super.relayout(window, seq, attrs, requestedWidth, requestedHeight,
viewVisibility, flags, frameNumber, outFrame, outOverscanInsets,
outContentInsets, outVisibleInsets, outStableInsets,
- cutout, mergedConfiguration, outSurfaceControl, outInsetsState);
+ cutout, mergedConfiguration, outSurfaceControl, outInsetsState,
+ outSurfaceSize);
if (res != 0) {
return res;
}
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 3b349b8..5babdaf 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -31,6 +31,7 @@
import android.annotation.Nullable;
import android.content.ClipData;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
@@ -189,7 +190,8 @@
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) {
if (false) Slog.d(TAG_WM, ">>>>>> ENTERED relayout from "
+ Binder.getCallingPid());
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, mRelayoutTag);
@@ -197,7 +199,7 @@
requestedWidth, requestedHeight, viewFlags, flags, frameNumber,
outFrame, outContentInsets, outVisibleInsets,
outStableInsets, outBackdropFrame, cutout,
- mergedConfiguration, outSurfaceControl, outInsetsState);
+ mergedConfiguration, outSurfaceControl, outInsetsState, outSurfaceSize);
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
if (false) Slog.d(TAG_WM, "<<<<<< EXITING relayout to "
+ Binder.getCallingPid());
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
index e2a21a9..57de753 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
@@ -55,6 +55,7 @@
import android.graphics.Color;
import android.graphics.GraphicBuffer;
import android.graphics.Paint;
+import android.graphics.Point;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Looper;
@@ -115,6 +116,7 @@
private static final String TAG = TAG_WITH_CLASS_NAME ? "SnapshotStartingWindow" : TAG_WM;
private static final int MSG_REPORT_DRAW = 0;
private static final String TITLE_FORMAT = "SnapshotStartingWindow for taskId=%s";
+ private static final Point sSurfaceSize = new Point(); //tmp var for unused relayout param
private final Window mWindow;
private final Surface mSurface;
private SurfaceControl mSurfaceControl;
@@ -227,7 +229,8 @@
try {
session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1,
tmpFrame, tmpContentInsets, tmpRect, tmpStableInsets, tmpRect,
- tmpCutout, tmpMergedConfiguration, surfaceControl, mTmpInsetsState);
+ tmpCutout, tmpMergedConfiguration, surfaceControl, mTmpInsetsState,
+ sSurfaceSize);
} catch (RemoteException e) {
// Local call.
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 74fdba1..05ff2fa 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2037,7 +2037,8 @@
long frameNumber, Rect outFrame, Rect outContentInsets,
Rect outVisibleInsets, Rect outStableInsets, Rect outBackdropFrame,
DisplayCutout.ParcelableWrapper outCutout, MergedConfiguration mergedConfiguration,
- SurfaceControl outSurfaceControl, InsetsState outInsetsState) {
+ SurfaceControl outSurfaceControl, InsetsState outInsetsState,
+ Point outSurfaceSize) {
int result = 0;
boolean configChanged;
final int pid = Binder.getCallingPid();
@@ -2359,6 +2360,10 @@
displayContent.sendNewConfiguration();
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
+ if (winAnimator.mSurfaceController != null) {
+ outSurfaceSize.set(winAnimator.mSurfaceController.getWidth(),
+ winAnimator.mSurfaceController.getHeight());
+ }
}
Binder.restoreCallingIdentity(origId);
@@ -2412,8 +2417,8 @@
return focusMayChange;
}
- private int createSurfaceControl(SurfaceControl outSurfaceControl, int result, WindowState win,
- WindowStateAnimator winAnimator) {
+ private int createSurfaceControl(SurfaceControl outSurfaceControl,
+ int result, WindowState win, WindowStateAnimator winAnimator) {
if (!win.mHasSurface) {
result |= RELAYOUT_RES_SURFACE_CHANGED;
}