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

Commit 7d73643f authored by Bart Sears's avatar Bart Sears
Browse files

Revert "Clarify geometry management for SurfaceView"

This reverts commit 78a45f2b.

Change-Id: I782f688f52a85df84d9facef2fbf88c28f4a7082
parent 78a45f2b
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -101,24 +101,16 @@ interface IWindowSession {
     *  for the parent window appears. This allows for synchronizing movement of a child
     *  to repainting the contents of the parent.
     *
     *  "width" and "height" correspond to the width and height members of
     *  WindowManager.LayoutParams in the {@link #relayout relayout()} case.
     *  This may differ from the surface buffer size in the
     *  case of {@link LayoutParams#FLAG_SCALED} and {@link #relayout relayout()}
     *  must be used with requestedWidth/height if this must be changed.
     *
     *  @param window The window being modified. Must be attached to a parent window
     *  or this call will fail.
     *  @param x The new x position
     *  @param y The new y position
     *  @param width The new width
     *  @param height The new height
     *  @param deferTransactionUntilFrame Frame number from our parent (attached) to
     *  defer this action until.
     *  @param outFrame Rect in which is placed the new position/size on screen.
     */
    void repositionChild(IWindow childWindow, int left, int top, int right, int bottom,
            long deferTransactionUntilFrame, out Rect outFrame);
    void repositionChild(IWindow childWindow, int x, int y, long deferTransactionUntilFrame,
            out Rect outFrame);

    /**
     * If a call to relayout() asked to have the surface destroy deferred,
+21 −38
Original line number Diff line number Diff line
@@ -157,10 +157,10 @@ public class SurfaceView extends View {
    long mLastLockTime = 0;

    boolean mVisible = false;
    int mWindowSpaceLeft = -1;
    int mWindowSpaceTop = -1;
    int mWindowSpaceWidth = -1;
    int mWindowSpaceHeight = -1;
    int mLeft = -1;
    int mTop = -1;
    int mWidth = -1;
    int mHeight = -1;
    int mFormat = -1;
    final Rect mSurfaceFrame = new Rect();
    int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1;
@@ -445,33 +445,32 @@ public class SurfaceView extends View {
        getLocationInWindow(mLocation);
        final boolean creating = mWindow == null;
        final boolean formatChanged = mFormat != mRequestedFormat;
        final boolean sizeChanged = mWindowSpaceWidth != myWidth || mWindowSpaceHeight != myHeight;
        final boolean sizeChanged = mWidth != myWidth || mHeight != myHeight;
        final boolean visibleChanged = mVisible != mRequestedVisible;
        final boolean layoutSizeChanged = getWidth() != mLayout.width
                || getHeight() != mLayout.height;
        final boolean positionChanged = mWindowSpaceLeft != mLocation[0] || mWindowSpaceTop != mLocation[1];
        final boolean layoutSizeChanged = getWidth() != mLayout.width || getHeight() != mLayout.height;
        final boolean positionChanged = mLeft != mLocation[0] || mTop != mLocation[1];

        if (force || creating || formatChanged || sizeChanged || visibleChanged
            || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) {
            || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded || layoutSizeChanged) {
            if (DEBUG) Log.i(TAG, "Changes: creating=" + creating
                    + " format=" + formatChanged + " size=" + sizeChanged
                    + " visible=" + visibleChanged
                    + " left=" + (mWindowSpaceLeft != mLocation[0])
                    + " top=" + (mWindowSpaceTop != mLocation[1]));
                    + " left=" + (mLeft != mLocation[0])
                    + " top=" + (mTop != mLocation[1]));

            try {
                final boolean visible = mVisible = mRequestedVisible;
                mWindowSpaceLeft = mLocation[0];
                mWindowSpaceTop = mLocation[1];
                mWindowSpaceWidth = myWidth;
                mWindowSpaceHeight = myHeight;
                mLeft = mLocation[0];
                mTop = mLocation[1];
                mWidth = myWidth;
                mHeight = myHeight;
                mFormat = mRequestedFormat;

                // Scaling/Translate window's layout here because mLayout is not used elsewhere.

                // Places the window relative
                mLayout.x = mWindowSpaceLeft;
                mLayout.y = mWindowSpaceTop;
                mLayout.x = mLeft;
                mLayout.y = mTop;
                mLayout.width = getWidth();
                mLayout.height = getHeight();
                if (mTranslator != null) {
@@ -486,14 +485,6 @@ public class SurfaceView extends View {
                              | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                              | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                              ;
                if (!creating && !force && !mUpdateWindowNeeded) {
                    mLayout.privateFlags |=
                            WindowManager.LayoutParams.PRIVATE_FLAG_PRESERVE_GEOMETRY;
                } else {
                    mLayout.privateFlags &=
                            ~WindowManager.LayoutParams.PRIVATE_FLAG_PRESERVE_GEOMETRY;
                }

                if (!getContext().getResources().getCompatibilityInfo().supportsScreen()) {
                    mLayout.privateFlags |=
                            WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
@@ -525,7 +516,7 @@ public class SurfaceView extends View {
                    if (DEBUG) Log.i(TAG, "Cur surface: " + mSurface);

                    relayoutResult = mSession.relayout(
                        mWindow, mWindow.mSeq, mLayout, mWindowSpaceWidth, mWindowSpaceHeight,
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            visible ? VISIBLE : GONE,
                            WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY,
                            mWinFrame, mOverscanInsets, mContentInsets,
@@ -630,19 +621,11 @@ public class SurfaceView extends View {
                TAG, "Layout: x=" + mLayout.x + " y=" + mLayout.y +
                " w=" + mLayout.width + " h=" + mLayout.height +
                ", frame=" + mSurfaceFrame);
        } else if (positionChanged || layoutSizeChanged) { // Only the position has changed
            mWindowSpaceLeft = mLocation[0];
            mWindowSpaceTop = mLocation[1];
            // For our size changed check, we keep mLayout.width and mLayout.height
            // in view local space.
            mLocation[0] = mLayout.width = getWidth();
            mLocation[1] = mLayout.height = getHeight();

            transformFromViewToWindowSpace(mLocation);

        } else if (positionChanged) { // Only the position has changed
            mLeft = mLocation[0];
            mTop = mLocation[1];
            try {
                mSession.repositionChild(mWindow, mWindowSpaceLeft, mWindowSpaceTop,
                        mLocation[0], mLocation[1],
                mSession.repositionChild(mWindow, mLeft, mTop,
                        viewRoot != null ? viewRoot.getNextFrameNumber() : -1,
                        mWinFrame);
            } catch (RemoteException ex) {
+8 −16
Original line number Diff line number Diff line
@@ -18500,27 +18500,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *
     * @param location an array of two integers in which to hold the coordinates
     */
    public void getLocationInWindow(@Size(2) int[] outWindowSpace) {
        outWindowSpace[0] = 0;
        outWindowSpace[1] = 0;
        transformFromViewToWindowSpace(outWindowSpace);
    }
    void transformFromViewToWindowSpace(@Size(2) int[] inOutLocation) {
        if (inOutLocation == null || inOutLocation.length < 2) {
            throw new IllegalArgumentException("inOutLocation must be an array of two integers");
    public void getLocationInWindow(@Size(2) int[] location) {
        if (location == null || location.length < 2) {
            throw new IllegalArgumentException("location must be an array of two integers");
        }
        if (mAttachInfo == null) {
            // When the view is not attached to a window, this method does not make sense
            inOutLocation[0] = inOutLocation[1] = 0;
            location[0] = location[1] = 0;
            return;
        }
        float position[] = mAttachInfo.mTmpTransformLocation;
        position[0] = inOutLocation[0];
        position[1] = inOutLocation[1];
        float[] position = mAttachInfo.mTmpTransformLocation;
        position[0] = position[1] = 0.0f;
        if (!hasIdentityMatrix()) {
            getMatrix().mapPoints(position);
@@ -18552,8 +18544,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            position[1] -= vr.mCurScrollY;
        }
        inOutLocation[0] = (int) (position[0] + 0.5f);
        inOutLocation[1] = (int) (position[1] + 0.5f);
        location[0] = (int) (position[0] + 0.5f);
        location[1] = (int) (position[1] + 0.5f);
    }
    /**
+0 −10
Original line number Diff line number Diff line
@@ -1135,16 +1135,6 @@ public interface WindowManager extends ViewManager {
         */
        public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000;

        /**
         * Flag indicating that the x, y, width, and height members should be
         * ignored (and thus their previous value preserved). For example 
         * because they are being managed externally through repositionChild.
         *
         * {@hide}
         */
        public static final int PRIVATE_FLAG_PRESERVE_GEOMETRY = 0x00002000;


        /**
         * Control flags that are private to the platform.
         * @hide
+3 −4
Original line number Diff line number Diff line
@@ -188,10 +188,9 @@ final class Session extends IWindowSession.Stub
    }

    @Override
    public void repositionChild(IWindow window, int left, int top, int right, int bottom,
             long deferTransactionUntilFrame, Rect outFrame) {
        mService.repositionChild(this, window, left, top, right, bottom,
                deferTransactionUntilFrame, outFrame);
    public void repositionChild(IWindow window, int x, int y, long deferTransactionUntilFrame,
             Rect outFrame) {
        mService.repositionChild(this, window, x, y, deferTransactionUntilFrame, outFrame);
    }

    public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
Loading