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

Commit a429d5df authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Improve compat mode scaling implementation." into honeycomb-mr2

parents 185d9c4d ffb3d939
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -156,9 +156,8 @@ class DragState {
        }

        if (mDragInProgress && newWin.isPotentialDragTarget()) {
            DragEvent event = DragEvent.obtain(DragEvent.ACTION_DRAG_STARTED,
                    touchX - newWin.mFrame.left, touchY - newWin.mFrame.top,
                    null, desc, null, false);
            DragEvent event = obtainDragEvent(newWin, DragEvent.ACTION_DRAG_STARTED,
                    touchX, touchY, null, desc, null, false);
            try {
                newWin.mClient.dispatchDragEvent(event);
                // track each window that we've notified that the drag is starting
@@ -267,9 +266,8 @@ class DragState {
                    Slog.d(WindowManagerService.TAG, "sending DRAG_EXITED to " + mTargetWindow);
                }
                // force DRAG_EXITED_EVENT if appropriate
                DragEvent evt = DragEvent.obtain(DragEvent.ACTION_DRAG_EXITED,
                        x - mTargetWindow.mFrame.left, y - mTargetWindow.mFrame.top,
                        null, null, null, false);
                DragEvent evt = obtainDragEvent(mTargetWindow, DragEvent.ACTION_DRAG_EXITED,
                        x, y, null, null, null, false);
                mTargetWindow.mClient.dispatchDragEvent(evt);
                if (myPid != mTargetWindow.mSession.mPid) {
                    evt.recycle();
@@ -279,9 +277,8 @@ class DragState {
                if (false && WindowManagerService.DEBUG_DRAG) {
                    Slog.d(WindowManagerService.TAG, "sending DRAG_LOCATION to " + touchedWin);
                }
                DragEvent evt = DragEvent.obtain(DragEvent.ACTION_DRAG_LOCATION,
                        x - touchedWin.mFrame.left, y - touchedWin.mFrame.top,
                        null, null, null, false);
                DragEvent evt = obtainDragEvent(touchedWin, DragEvent.ACTION_DRAG_LOCATION,
                        x, y, null, null, null, false);
                touchedWin.mClient.dispatchDragEvent(evt);
                if (myPid != touchedWin.mSession.mPid) {
                    evt.recycle();
@@ -310,8 +307,7 @@ class DragState {
        }
        final int myPid = Process.myPid();
        final IBinder token = touchedWin.mClient.asBinder();
        DragEvent evt = DragEvent.obtain(DragEvent.ACTION_DROP,
                x - touchedWin.mFrame.left, y - touchedWin.mFrame.top,
        DragEvent evt = obtainDragEvent(touchedWin, DragEvent.ACTION_DROP, x, y,
                null, null, mData, false);
        try {
            touchedWin.mClient.dispatchDragEvent(evt);
@@ -365,4 +361,16 @@ class DragState {

        return touchedWin;
    }

    private static DragEvent obtainDragEvent(WindowState win, int action,
            float x, float y, Object localState,
            ClipDescription description, ClipData data, boolean result) {
        float winX = x - win.mFrame.left;
        float winY = y - win.mFrame.top;
        if (win.mEnforceSizeCompat) {
            winX *= win.mGlobalScale;
            winY *= win.mGlobalScale;
        }
        return DragEvent.obtain(action, winX, winY, localState, description, data, result);
    }
}
 No newline at end of file
+0 −44
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm;

import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Transformation;

/**
 * Animation that fade in after 0.5 interpolate time, or fade out in reverse order.
 * This is used for opening/closing transition for apps in compatible mode.
 */
class FadeInOutAnimation extends Animation {
    boolean mFadeIn;

    public FadeInOutAnimation(boolean fadeIn) {
        setInterpolator(new AccelerateInterpolator());
        setDuration(WindowManagerService.DEFAULT_FADE_IN_OUT_DURATION);
        mFadeIn = fadeIn;
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        float x = interpolatedTime;
        if (!mFadeIn) {
            x = 1.0f - x; // reverse the interpolation for fade out
        }
        t.setAlpha(x);
    }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ final class InputMonitor {
            inputWindow.ownerPid = child.mSession.mPid;
            inputWindow.ownerUid = child.mSession.mUid;
            
            final Rect frame = child.mScaledFrame;
            final Rect frame = child.mFrame;
            inputWindow.frameLeft = frame.left;
            inputWindow.frameTop = frame.top;
            inputWindow.frameRight = frame.right;
+31 −107
Original line number Diff line number Diff line
@@ -603,9 +603,6 @@ public class WindowManagerService extends IWindowManager.Stub
    // The frame use to limit the size of the app running in compatibility mode.
    Rect mCompatibleScreenFrame = new Rect();
    float mCompatibleScreenScale;
    // The surface used to fill the outer rim of the app running in compatibility mode.
    Surface mBackgroundFillerSurface = null;
    WindowState mBackgroundFillerTarget = null;

    public static WindowManagerService main(Context context,
            PowerManagerService pm, boolean haveInputMethods) {
@@ -1774,7 +1771,7 @@ public class WindowManagerService extends IWindowManager.Stub
        boolean rawChanged = false;
        float wpx = mLastWallpaperX >= 0 ? mLastWallpaperX : 0.5f;
        float wpxs = mLastWallpaperXStep >= 0 ? mLastWallpaperXStep : -1.0f;
        int availw = wallpaperWin.mScaledFrame.right-wallpaperWin.mScaledFrame.left-dw;
        int availw = wallpaperWin.mFrame.right-wallpaperWin.mFrame.left-dw;
        int offset = availw > 0 ? -(int)(availw*wpx+.5f) : 0;
        changed = wallpaperWin.mXOffset != offset;
        if (changed) {
@@ -2369,6 +2366,11 @@ public class WindowManagerService extends IWindowManager.Stub
                    w.mGivenVisibleInsets.set(visibleInsets);
                    w.mGivenTouchableRegion.set(touchableRegion);
                    w.mTouchableInsets = touchableInsets;
                    if (w.mGlobalScale != 1) {
                        w.mGivenContentInsets.scale(w.mGlobalScale);
                        w.mGivenVisibleInsets.scale(w.mGlobalScale);
                        w.mGivenTouchableRegion.scale(w.mGlobalScale);
                    }
                    mLayoutNeeded = true;
                    performLayoutAndPlaceSurfacesLocked();
                }
@@ -2704,7 +2706,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (win.mAppToken != null) {
                win.mAppToken.updateReportedVisibilityLocked();
            }
            outFrame.set(win.mFrame);
            outFrame.set(win.mCompatFrame);
            outContentInsets.set(win.mContentInsets);
            outVisibleInsets.set(win.mVisibleInsets);
            if (localLOGV) Slog.v(
@@ -2903,18 +2905,14 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    private boolean applyAnimationLocked(AppWindowToken wtoken,
            WindowManager.LayoutParams lp, int transit, boolean enter, boolean bgFiller) {
            WindowManager.LayoutParams lp, int transit, boolean enter) {
        // Only apply an animation if the display isn't frozen.  If it is
        // frozen, there is no reason to animate and it can cause strange
        // artifacts when we unfreeze the display if some different animation
        // is running.
        if (!mDisplayFrozen && mPolicy.isScreenOn()) {
            Animation a;
            if (bgFiller) {
                a = new FadeInOutAnimation(enter);
                if (DEBUG_ANIM) Slog.v(TAG,
                        "applying FadeInOutAnimation for a window in compatibility mode");
            } else if (mNextAppTransitionPackage != null) {
            if (mNextAppTransitionPackage != null) {
                a = loadAnimation(mNextAppTransitionPackage, enter ?
                        mNextAppTransitionEnter : mNextAppTransitionExit);
            } else {
@@ -3706,7 +3704,7 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    boolean setTokenVisibilityLocked(AppWindowToken wtoken, WindowManager.LayoutParams lp,
            boolean visible, int transit, boolean performLayout, boolean bgFiller) {
            boolean visible, int transit, boolean performLayout) {
        boolean delayed = false;

        if (wtoken.clientHidden == visible) {
@@ -3728,7 +3726,7 @@ public class WindowManagerService extends IWindowManager.Stub
                if (wtoken.animation == sDummyAnimation) {
                    wtoken.animation = null;
                }
                applyAnimationLocked(wtoken, lp, transit, visible, bgFiller);
                applyAnimationLocked(wtoken, lp, transit, visible);
                changed = true;
                if (wtoken.animation != null) {
                    delayed = runningAppAnimation = true;
@@ -3882,7 +3880,7 @@ public class WindowManagerService extends IWindowManager.Stub

            final long origId = Binder.clearCallingIdentity();
            setTokenVisibilityLocked(wtoken, null, visible, WindowManagerPolicy.TRANSIT_UNSET,
                    true, false);
                    true);
            wtoken.updateReportedVisibilityLocked();
            Binder.restoreCallingIdentity(origId);
        }
@@ -4009,7 +4007,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (basewtoken != null && (wtoken=basewtoken.appWindowToken) != null) {
                if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Removing app token: " + wtoken);
                delayed = setTokenVisibilityLocked(wtoken, null, false,
                        WindowManagerPolicy.TRANSIT_UNSET, true, false);
                        WindowManagerPolicy.TRANSIT_UNSET, true);
                wtoken.inPendingTransaction = false;
                mOpeningApps.remove(wtoken);
                wtoken.waitingToShow = false;
@@ -4830,7 +4828,7 @@ public class WindowManagerService extends IWindowManager.Stub
                
                // Don't include wallpaper in bounds calculation
                if (!ws.mIsWallpaper) {
                    final Rect wf = ws.mScaledFrame;
                    final Rect wf = ws.mFrame;
                    final Rect cr = ws.mContentInsets;
                    int left = wf.left + cr.left;
                    int top = wf.top + cr.top;
@@ -5549,8 +5547,8 @@ public class WindowManagerService extends IWindowManager.Stub

        // Override display width and height with what we are computing,
        // to be sure they remain consistent.
        dm.widthPixels = mPolicy.getNonDecorDisplayWidth(dw);
        dm.heightPixels = mPolicy.getNonDecorDisplayHeight(dh);
        dm.widthPixels = dm.realWidthPixels = mPolicy.getNonDecorDisplayWidth(dw);
        dm.heightPixels = dm.realHeightPixels = mPolicy.getNonDecorDisplayHeight(dh);

        mCompatibleScreenScale = CompatibilityInfo.updateCompatibleScreenFrame(
                dm, mCompatibleScreenFrame, null);
@@ -6851,7 +6849,6 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                    win.prelayout();
                    mPolicy.layoutWindowLw(win, win.mAttrs, null);
                    win.evalNeedsBackgroundFiller(innerDw, innerDh);
                    win.mLayoutSeq = seq;
                    if (DEBUG_LAYOUT) Slog.v(TAG, "-> mFrame="
                            + win.mFrame + " mContainingFrame="
@@ -6888,7 +6885,6 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                    win.prelayout();
                    mPolicy.layoutWindowLw(win, win.mAttrs, win.mAttachedWindow);
                    win.evalNeedsBackgroundFiller(innerDw, innerDh);
                    win.mLayoutSeq = seq;
                    if (DEBUG_LAYOUT) Slog.v(TAG, "-> mFrame="
                            + win.mFrame + " mContainingFrame="
@@ -7340,7 +7336,6 @@ public class WindowManagerService extends IWindowManager.Stub
                        LayoutParams animLp = null;
                        int bestAnimLayer = -1;
                        boolean fullscreenAnim = false;
                        boolean needBgFiller = false;

                        if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
                                "New wallpaper target=" + mWallpaperTarget
@@ -7378,16 +7373,8 @@ public class WindowManagerService extends IWindowManager.Stub
                            if (wtoken.appFullscreen) {
                                WindowState ws = wtoken.findMainWindow();
                                if (ws != null) {
                                    // If this is a compatibility mode
                                    // window, we will always use its anim.
                                    if (ws.mNeedsBackgroundFiller) {
                                        animLp = ws.mAttrs;
                                        bestAnimLayer = Integer.MAX_VALUE;
                                        needBgFiller = true;
                                    } else if (!fullscreenAnim || ws.mLayer > bestAnimLayer) {
                                    animLp = ws.mAttrs;
                                    bestAnimLayer = ws.mLayer;
                                    }
                                    fullscreenAnim = true;
                                }
                            } else if (!fullscreenAnim) {
@@ -7449,7 +7436,7 @@ public class WindowManagerService extends IWindowManager.Stub
                            wtoken.inPendingTransaction = false;
                            wtoken.animation = null;
                            setTokenVisibilityLocked(wtoken, animLp, true,
                                    transit, false, needBgFiller);
                                    transit, false);
                            wtoken.updateReportedVisibilityLocked();
                            wtoken.waitingToShow = false;
                            wtoken.showAllWindowsLocked();
@@ -7462,7 +7449,7 @@ public class WindowManagerService extends IWindowManager.Stub
                            wtoken.inPendingTransaction = false;
                            wtoken.animation = null;
                            setTokenVisibilityLocked(wtoken, animLp, false,
                                    transit, false, needBgFiller);
                                    transit, false);
                            wtoken.updateReportedVisibilityLocked();
                            wtoken.waitingToHide = false;
                            // Force the allDrawn flag, because we want to start
@@ -7629,8 +7616,6 @@ public class WindowManagerService extends IWindowManager.Stub
            boolean dimming = false;
            boolean covered = false;
            boolean syswin = false;
            boolean backgroundFillerWasShown = mBackgroundFillerTarget != null;
            mBackgroundFillerTarget = null;

            final int N = mWindows.size();

@@ -7659,8 +7644,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    w.computeShownFrameLocked();
                    if (localLOGV) Slog.v(
                            TAG, "Placing surface #" + i + " " + w.mSurface
                            + ": new=" + w.mShownFrame + ", old="
                            + w.mLastShownFrame);
                            + ": new=" + w.mShownFrame);

                    int width, height;
                    if ((w.mAttrs.flags & w.mAttrs.FLAG_SCALED) != 0) {
@@ -7668,13 +7652,9 @@ public class WindowManagerService extends IWindowManager.Stub
                        // the requested size.
                        width  = w.mRequestedWidth;
                        height = w.mRequestedHeight;
                        w.mLastRequestedWidth = width;
                        w.mLastRequestedHeight = height;
                        w.mLastShownFrame.set(w.mShownFrame);
                    } else {
                        width = w.mShownFrame.width();
                        height = w.mShownFrame.height();
                        w.mLastShownFrame.set(w.mShownFrame);
                        width = w.mCompatFrame.width();
                        height = w.mCompatFrame.height();
                    }

                    if (w.mSurface != null) {
@@ -7741,8 +7721,8 @@ public class WindowManagerService extends IWindowManager.Stub
                        }
                        if (localLOGV) Slog.v(TAG, "Resizing " + w
                                + ": configChanged=" + configChanged
                                + " last=" + w.mLastFrame + " frame=" + w.mFrame);
                        boolean frameChanged = !w.mLastFrame.equals(w.mFrame);
                                + " last=" + w.mLastCompatFrame + " frame=" + w.mCompatFrame);
                        boolean frameChanged = !w.mLastCompatFrame.equals(w.mCompatFrame);
                        if (frameChanged
                                || w.mContentInsetsChanged
                                || w.mVisibleInsetsChanged
@@ -7758,6 +7738,7 @@ public class WindowManagerService extends IWindowManager.Stub
                            }

                            w.mLastFrame.set(w.mFrame);
                            w.mLastCompatFrame.set(w.mCompatFrame);
                            w.mLastContentInsets.set(w.mContentInsets);
                            w.mLastVisibleInsets.set(w.mVisibleInsets);
                            // If the screen is currently frozen, then keep
@@ -7793,7 +7774,7 @@ public class WindowManagerService extends IWindowManager.Stub
                                }
                            }
                            if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
                                    "Resizing window " + w + " to " + w.mFrame);
                                    "Resizing window " + w + " to " + w.mCompatFrame);
                            mResizingWindows.add(w);
                        } else if (w.mOrientationChanging) {
                            if (!w.mDrawPending && !w.mCommitDrawPending) {
@@ -7932,16 +7913,6 @@ public class WindowManagerService extends IWindowManager.Stub

                final boolean obscuredChanged = w.mObscured != obscured;

                if (mBackgroundFillerTarget != null) {
                    if (w.isAnimating()) {
                        // Background filler is below all other windows that
                        // are animating.
                        mBackgroundFillerTarget = w;
                    } else if (w.mIsWallpaper) {
                        mBackgroundFillerTarget = w;
                    }
                }

                // Update effect.
                if (!(w.mObscured=obscured)) {
                    if (w.mSurface != null) {
@@ -7970,12 +7941,6 @@ public class WindowManagerService extends IWindowManager.Stub
                        // so we want to leave all of them as unblurred (for
                        // performance reasons).
                        obscured = true;
                    } else if (w.mNeedsBackgroundFiller && w.mHasDrawn
                            && w.mViewVisibility == View.VISIBLE
                            && (canBeSeen || w.isAnimating())) {
                        // This window is in compatibility mode, and needs background filler.
                        obscured = true;
                        mBackgroundFillerTarget = w;
                    } else if (canBeSeen && !obscured &&
                            (attrFlags&FLAG_BLUR_BEHIND|FLAG_DIM_BEHIND) != 0) {
                        if (localLOGV) Slog.v(TAG, "Win " + w
@@ -8042,47 +8007,6 @@ public class WindowManagerService extends IWindowManager.Stub
                }
            }

            if (mBackgroundFillerTarget != null) {
                if (mBackgroundFillerSurface == null) {
                    try {
                        mBackgroundFillerSurface = new Surface(mFxSession, 0,
                                "BackGroundFiller",
                                0, dw, dh,
                                PixelFormat.OPAQUE,
                                Surface.FX_SURFACE_NORMAL);
                    } catch (Exception e) {
                        Slog.e(TAG, "Exception creating filler surface", e);
                    }
                    if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BG FILLER "
                            + mBackgroundFillerSurface + ": CREATE");
                }
                try {
                    if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BG FILLER "
                            + mBackgroundFillerSurface + " SHOW: pos=(0,0) ("
                            + dw + "x" + dh + ") layer="
                            + (mBackgroundFillerTarget.mLayer - 1));
                    mBackgroundFillerSurface.setPosition(0, 0);
                    mBackgroundFillerSurface.setSize(dw, dh);
                    // Using the same layer as Dim because they will never be shown at the
                    // same time.  NOTE: we do NOT use mAnimLayer, because we don't
                    // want this surface dragged up in front of stuff that is animating.
                    mBackgroundFillerSurface.setLayer(mBackgroundFillerTarget.mLayer
                            - LAYER_OFFSET_DIM);
                    mBackgroundFillerSurface.show();
                } catch (RuntimeException e) {
                    Slog.e(TAG, "Exception showing filler surface");
                }
            } else if (backgroundFillerWasShown) {
                mBackgroundFillerTarget = null;
                if (SHOW_TRANSACTIONS) Slog.i(TAG, "  BG FILLER "
                        + mBackgroundFillerSurface + " HIDE");
                try {
                    mBackgroundFillerSurface.hide();
                } catch (RuntimeException e) {
                    Slog.e(TAG, "Exception hiding filler surface", e);
                }
            }

            if (mDimAnimator != null && mDimAnimator.mDimShown) {
                animating |= mDimAnimator.updateSurface(dimming, currentTime,
                        mDisplayFrozen || !mPolicy.isScreenOn());
@@ -8137,7 +8061,7 @@ public class WindowManagerService extends IWindowManager.Stub
                WindowState win = mResizingWindows.get(i);
                try {
                    if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
                            "Reporting new frame to " + win + ": " + win.mFrame);
                            "Reporting new frame to " + win + ": " + win.mCompatFrame);
                    int diff = 0;
                    boolean configChanged =
                        win.mConfiguration != mCurConfiguration
@@ -8146,13 +8070,13 @@ public class WindowManagerService extends IWindowManager.Stub
                    if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION)
                            && configChanged) {
                        Slog.i(TAG, "Sending new config to window " + win + ": "
                                + win.mFrame.width() + "x" + win.mFrame.height()
                                + win.mCompatFrame.width() + "x" + win.mCompatFrame.height()
                                + " / " + mCurConfiguration + " / 0x"
                                + Integer.toHexString(diff));
                    }
                    win.mConfiguration = mCurConfiguration;
                    win.mClient.resized(win.mFrame.width(),
                            win.mFrame.height(), win.mLastContentInsets,
                    win.mClient.resized(win.mCompatFrame.width(),
                            win.mCompatFrame.height(), win.mLastContentInsets,
                            win.mLastVisibleInsets, win.mDrawPending,
                            configChanged ? win.mConfiguration : null);
                    win.mContentInsetsChanged = false;
+98 −118

File changed.

Preview size limit exceeded, changes collapsed.