Avoid setting size/position on Transaction if not needed
Passing the JNI layer is quite expensive. Avoid updating the position/size if not needed by storing the last size. Test: AppTransitionTests Test: go/wm-smoke Bug: 71510789 Change-Id: Ibb3660114fb0e573c9cd2144e5af11f57a96a9d6
This commit is contained in:
@@ -44,6 +44,7 @@ import static com.android.server.wm.proto.StackProto.WINDOW_CONTAINER;
|
||||
|
||||
import android.annotation.CallSuper;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.os.RemoteException;
|
||||
@@ -145,6 +146,7 @@ public class TaskStack extends WindowContainer<Task> implements
|
||||
* For {@link #prepareSurfaces}.
|
||||
*/
|
||||
final Rect mTmpDimBoundsRect = new Rect();
|
||||
private final Point mLastSurfaceSize = new Point();
|
||||
|
||||
TaskStack(WindowManagerService service, int stackId, StackWindowController controller) {
|
||||
super(service);
|
||||
@@ -743,7 +745,13 @@ public class TaskStack extends WindowContainer<Task> implements
|
||||
}
|
||||
|
||||
final Rect stackBounds = getBounds();
|
||||
transaction.setSize(mSurfaceControl, stackBounds.width(), stackBounds.height());
|
||||
final int width = stackBounds.width();
|
||||
final int height = stackBounds.height();
|
||||
if (width == mLastSurfaceSize.x && height == mLastSurfaceSize.y) {
|
||||
return;
|
||||
}
|
||||
transaction.setSize(mSurfaceControl, width, height);
|
||||
mLastSurfaceSize.set(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -95,6 +95,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
||||
protected final WindowManagerService mService;
|
||||
|
||||
private final Point mTmpPos = new Point();
|
||||
protected final Point mLastSurfacePosition = new Point();
|
||||
|
||||
/** Total number of elements in this subtree, including our own hierarchy element. */
|
||||
private int mTreeWeight = 1;
|
||||
@@ -1172,7 +1173,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
||||
}
|
||||
|
||||
getRelativePosition(mTmpPos);
|
||||
if (mTmpPos.equals(mLastSurfacePosition)) {
|
||||
return;
|
||||
}
|
||||
|
||||
transaction.setPosition(mSurfaceControl, mTmpPos.x, mTmpPos.y);
|
||||
mLastSurfacePosition.set(mTmpPos.x, mTmpPos.y);
|
||||
|
||||
for (int i = mChildren.size() - 1; i >= 0; i--) {
|
||||
mChildren.get(i).updateSurfacePosition(transaction);
|
||||
|
||||
@@ -4432,6 +4432,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
|
||||
// Leash is now responsible for position, so set our position to 0.
|
||||
t.setPosition(mSurfaceControl, 0, 0);
|
||||
mLastSurfacePosition.set(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -4447,8 +4448,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
}
|
||||
|
||||
transformFrameToSurfacePosition(mFrame.left, mFrame.top, mSurfacePosition);
|
||||
if (!mSurfaceAnimator.hasLeash()) {
|
||||
if (!mSurfaceAnimator.hasLeash() && !mLastSurfacePosition.equals(mSurfacePosition)) {
|
||||
t.setPosition(mSurfaceControl, mSurfacePosition.x, mSurfacePosition.y);
|
||||
mLastSurfacePosition.set(mSurfacePosition.x, mSurfacePosition.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user