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

Commit 4807b6b2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix 2 graphical issues for drag resizing."

parents 40056001 fbd8ea64
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2322,10 +2322,12 @@ public final class ViewRootImpl implements ViewParent,
                        mResizeMode = freeformResizing
                                ? RESIZE_MODE_FREEFORM
                                : RESIZE_MODE_DOCKED_DIVIDER;
                        final boolean backdropSizeMatchesFrame =
                                mWinFrame.width() == mPendingBackDropFrame.width()
                                        && mWinFrame.height() == mPendingBackDropFrame.height();
                        // TODO: Need cutout?
                        startDragResizing(mPendingBackDropFrame,
                                mWinFrame.equals(mPendingBackDropFrame), mPendingVisibleInsets,
                                mPendingStableInsets, mResizeMode);
                        startDragResizing(mPendingBackDropFrame, !backdropSizeMatchesFrame,
                                mPendingVisibleInsets, mPendingStableInsets, mResizeMode);
                    } else {
                        // We shouldn't come here, but if we come we should end the resize.
                        endDragResizing();
+38 −36
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
    private ColorDrawable mNavigationBarColor;
    private boolean mOldFullscreen;
    private boolean mFullscreen;
    private final int mResizeMode;
    private final Rect mOldSystemInsets = new Rect();
    private final Rect mOldStableInsets = new Rect();
    private final Rect mSystemInsets = new Rect();
@@ -79,7 +78,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
    public BackdropFrameRenderer(DecorView decorView, ThreadedRenderer renderer, Rect initialBounds,
            Drawable resizingBackgroundDrawable, Drawable captionBackgroundDrawable,
            Drawable userCaptionBackgroundDrawable, int statusBarColor, int navigationBarColor,
            boolean fullscreen, Rect systemInsets, Rect stableInsets, int resizeMode) {
            boolean fullscreen, Rect systemInsets, Rect stableInsets) {
        setName("ResizeFrame");

        mRenderer = renderer;
@@ -100,7 +99,6 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
        mStableInsets.set(stableInsets);
        mOldSystemInsets.set(systemInsets);
        mOldStableInsets.set(stableInsets);
        mResizeMode = resizeMode;

        // Kick off our draw thread.
        start();
@@ -109,6 +107,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
    void onResourcesLoaded(DecorView decorView, Drawable resizingBackgroundDrawable,
            Drawable captionBackgroundDrawableDrawable, Drawable userCaptionBackgroundDrawable,
            int statusBarColor, int navigationBarColor) {
        synchronized (this) {
            mDecorView = decorView;
            mResizingBackgroundDrawable = resizingBackgroundDrawable != null
                    && resizingBackgroundDrawable.getConstantState() != null
@@ -138,6 +137,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
                mNavigationBarColor = null;
            }
        }
    }

    private void addSystemBarNodeIfNeeded() {
        if (mSystemBarBackgroundNode != null) {
@@ -186,7 +186,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
     * All resources of the renderer will be released. This function can be called from the
     * the UI thread as well as the renderer thread.
     */
    public void releaseRenderer() {
    void releaseRenderer() {
        synchronized (this) {
            if (mRenderer != null) {
                // Invalidate the current content bounds.
@@ -268,7 +268,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
     * @param ySize The height of the content.
     * @return true if a frame should be requested after the content is drawn; false otherwise.
     */
    public boolean onContentDrawn(int xOffset, int yOffset, int xSize, int ySize) {
    boolean onContentDrawn(int xOffset, int yOffset, int xSize, int ySize) {
        synchronized (this) {
            final boolean firstCall = mLastContentWidth == 0;
            // The current content buffer is drawn here.
@@ -291,7 +291,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
        }
    }

    public void onRequestDraw(boolean reportNextDraw) {
    void onRequestDraw(boolean reportNextDraw) {
        synchronized (this) {
            mReportNextDraw = reportNextDraw;
            mOldTargetRect.set(0, 0, 0, 0);
@@ -329,8 +329,8 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
            return;
        }

        // Since the surface is spanning the entire screen, we have to add the start offset of
        // the bounds to get to the surface location.
        // Content may not be drawn at the surface origin, so we want to keep the offset when we're
        // resizing it.
        final int left = mLastXOffset + newBounds.left;
        final int top = mLastYOffset + newBounds.top;
        final int width = newBounds.width();
@@ -414,6 +414,8 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
    }

    void setUserCaptionBackgroundDrawable(Drawable userCaptionBackgroundDrawable) {
        synchronized (this) {
            mUserCaptionBackgroundDrawable = userCaptionBackgroundDrawable;
        }
    }
}
+9 −2
Original line number Diff line number Diff line
@@ -2093,7 +2093,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                    initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
                    mUserCaptionBackgroundDrawable, getCurrentColor(mStatusColorViewState),
                    getCurrentColor(mNavigationColorViewState), fullscreen, systemInsets,
                    stableInsets, resizeMode);
                    stableInsets);

            // Get rid of the shadow while we are resizing. Shadow drawing takes considerable time.
            // If we want to get the shadow shown while resizing, we would need to elevate a new
@@ -2229,7 +2229,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        // or it didn't change.
        if ((wasAdjustedForStack || mElevationAdjustedForStack)
                && getElevation() != elevation) {
            if (!isResizing()) {
                mWindow.setElevation(elevation);
            } else {
                // Just suppress the shadow when resizing, don't adjust surface insets because it'll
                // cause a flicker when drag resize for freeform window starts. #onContentDrawn()
                // will compensate the offset when passing to BackdropFrameRenderer.
                setElevation(elevation);
            }
        }
    }

+6 −1
Original line number Diff line number Diff line
@@ -2949,7 +2949,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        // isDragResizing() or isDragResizeChanged() is true.
        boolean resizing = isDragResizing() || isDragResizeChanged();
        if (getWindowConfiguration().useWindowFrameForBackdrop() || !resizing) {
            return frame;
            // Surface position is now inherited from parent, and BackdropFrameRenderer uses
            // backdrop frame to position content. Thus we just keep the size of backdrop frame, and
            // remove the offset to avoid double offset from display origin.
            mTmpRect.set(frame);
            mTmpRect.offsetTo(0, 0);
            return mTmpRect;
        }
        final DisplayInfo displayInfo = getDisplayInfo();
        mTmpRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);