Search in sources :

Example 46 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class WindowManagerService method applyAnimationLocked.

private boolean applyAnimationLocked(AppWindowToken atoken, WindowManager.LayoutParams lp, int transit, boolean enter, boolean isVoiceInteraction) {
    // 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.
    Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "WM#applyAnimationLocked");
    if (okToDisplay()) {
        DisplayInfo displayInfo = getDefaultDisplayInfoLocked();
        final int width = displayInfo.appWidth;
        final int height = displayInfo.appHeight;
        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM)
            Slog.v(TAG_WM, "applyAnimation: atoken=" + atoken);
        // Determine the visible rect to calculate the thumbnail clip
        final WindowState win = atoken.findMainWindow();
        final Rect frame = new Rect(0, 0, width, height);
        final Rect displayFrame = new Rect(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
        final Rect insets = new Rect();
        Rect surfaceInsets = null;
        final boolean freeform = win != null && win.inFreeformWorkspace();
        if (win != null) {
            // the status bar). In that case we need to use the final frame.
            if (freeform) {
                frame.set(win.mFrame);
            } else {
                frame.set(win.mContainingFrame);
            }
            surfaceInsets = win.getAttrs().surfaceInsets;
            insets.set(win.mContentInsets);
        }
        if (atoken.mLaunchTaskBehind) {
            // Differentiate the two animations. This one which is briefly on the screen
            // gets the !enter animation, and the other activity which remains on the
            // screen gets the enter animation. Both appear in the mOpeningApps set.
            enter = false;
        }
        if (DEBUG_APP_TRANSITIONS)
            Slog.d(TAG_WM, "Loading animation for app transition." + " transit=" + AppTransition.appTransitionToString(transit) + " enter=" + enter + " frame=" + frame + " insets=" + insets + " surfaceInsets=" + surfaceInsets);
        Animation a = mAppTransition.loadAnimation(lp, transit, enter, mCurConfiguration.uiMode, mCurConfiguration.orientation, frame, displayFrame, insets, surfaceInsets, isVoiceInteraction, freeform, atoken.mTask.mTaskId);
        if (a != null) {
            if (DEBUG_ANIM)
                logWithStack(TAG, "Loaded animation " + a + " for " + atoken);
            final int containingWidth = frame.width();
            final int containingHeight = frame.height();
            atoken.mAppAnimator.setAnimation(a, containingWidth, containingHeight, mAppTransition.canSkipFirstFrame(), mAppTransition.getAppStackClipMode());
        }
    } else {
        atoken.mAppAnimator.clearAnimation();
    }
    Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
    return atoken.mAppAnimator.animation != null;
}
Also used : Rect(android.graphics.Rect) DisplayInfo(android.view.DisplayInfo) Animation(android.view.animation.Animation) Point(android.graphics.Point)

Example 47 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class WindowSurfacePlacer method createThumbnailAppAnimator.

private void createThumbnailAppAnimator(int transit, AppWindowToken appToken, int openingLayer, int closingLayer) {
    AppWindowAnimator openingAppAnimator = (appToken == null) ? null : appToken.mAppAnimator;
    if (openingAppAnimator == null || openingAppAnimator.animation == null) {
        return;
    }
    final int taskId = appToken.mTask.mTaskId;
    Bitmap thumbnailHeader = mService.mAppTransition.getAppTransitionThumbnailHeader(taskId);
    if (thumbnailHeader == null || thumbnailHeader.getConfig() == Bitmap.Config.ALPHA_8) {
        if (DEBUG_APP_TRANSITIONS)
            Slog.d(TAG, "No thumbnail header bitmap for: " + taskId);
        return;
    }
    // This thumbnail animation is very special, we need to have
    // an extra surface with the thumbnail included with the animation.
    Rect dirty = new Rect(0, 0, thumbnailHeader.getWidth(), thumbnailHeader.getHeight());
    try {
        // TODO(multi-display): support other displays
        final DisplayContent displayContent = mService.getDefaultDisplayContentLocked();
        final Display display = displayContent.getDisplay();
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        // Create a new surface for the thumbnail
        SurfaceControl surfaceControl = new SurfaceControl(mService.mFxSession, "thumbnail anim", dirty.width(), dirty.height(), PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
        surfaceControl.setLayerStack(display.getLayerStack());
        if (SHOW_TRANSACTIONS) {
            Slog.i(TAG, "  THUMBNAIL " + surfaceControl + ": CREATE");
        }
        // Draw the thumbnail onto the surface
        Surface drawSurface = new Surface();
        drawSurface.copyFrom(surfaceControl);
        Canvas c = drawSurface.lockCanvas(dirty);
        c.drawBitmap(thumbnailHeader, 0, 0, null);
        drawSurface.unlockCanvasAndPost(c);
        drawSurface.release();
        // Get the thumbnail animation
        Animation anim;
        if (mService.mAppTransition.isNextThumbnailTransitionAspectScaled()) {
            // If this is a multi-window scenario, we use the windows frame as
            // destination of the thumbnail header animation. If this is a full screen
            // window scenario, we use the whole display as the target.
            WindowState win = appToken.findMainWindow();
            Rect appRect = win != null ? win.getContentFrameLw() : new Rect(0, 0, displayInfo.appWidth, displayInfo.appHeight);
            Rect insets = win != null ? win.mContentInsets : null;
            // For the new aspect-scaled transition, we want it to always show
            // above the animating opening/closing window, and we want to
            // synchronize its thumbnail surface with the surface for the
            // open/close animation (only on the way down)
            anim = mService.mAppTransition.createThumbnailAspectScaleAnimationLocked(appRect, insets, thumbnailHeader, taskId, mService.mCurConfiguration.uiMode, mService.mCurConfiguration.orientation);
            openingAppAnimator.thumbnailForceAboveLayer = Math.max(openingLayer, closingLayer);
            openingAppAnimator.deferThumbnailDestruction = !mService.mAppTransition.isNextThumbnailTransitionScaleUp();
        } else {
            anim = mService.mAppTransition.createThumbnailScaleAnimationLocked(displayInfo.appWidth, displayInfo.appHeight, transit, thumbnailHeader);
        }
        anim.restrictDuration(MAX_ANIMATION_DURATION);
        anim.scaleCurrentDuration(mService.getTransitionAnimationScaleLocked());
        openingAppAnimator.thumbnail = surfaceControl;
        openingAppAnimator.thumbnailLayer = openingLayer;
        openingAppAnimator.thumbnailAnimation = anim;
        mService.mAppTransition.getNextAppTransitionStartRect(taskId, mTmpStartRect);
    } catch (Surface.OutOfResourcesException e) {
        Slog.e(TAG, "Can't allocate thumbnail/Canvas surface w=" + dirty.width() + " h=" + dirty.height(), e);
        openingAppAnimator.clearThumbnail();
    }
}
Also used : Rect(android.graphics.Rect) DisplayInfo(android.view.DisplayInfo) SurfaceControl(android.view.SurfaceControl) Canvas(android.graphics.Canvas) Surface(android.view.Surface) Bitmap(android.graphics.Bitmap) Animation(android.view.animation.Animation) Display(android.view.Display)

Example 48 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class WindowSurfacePlacer method performLayoutLockedInner.

final void performLayoutLockedInner(final DisplayContent displayContent, boolean initial, boolean updateInputWindows) {
    if (!displayContent.layoutNeeded) {
        return;
    }
    displayContent.layoutNeeded = false;
    WindowList windows = displayContent.getWindowList();
    boolean isDefaultDisplay = displayContent.isDefaultDisplay;
    DisplayInfo displayInfo = displayContent.getDisplayInfo();
    final int dw = displayInfo.logicalWidth;
    final int dh = displayInfo.logicalHeight;
    if (mService.mInputConsumer != null) {
        mService.mInputConsumer.layout(dw, dh);
    }
    if (mService.mWallpaperInputConsumer != null) {
        mService.mWallpaperInputConsumer.layout(dw, dh);
    }
    final int N = windows.size();
    int i;
    if (DEBUG_LAYOUT) {
        Slog.v(TAG, "-------------------------------------");
        Slog.v(TAG, "performLayout: needed=" + displayContent.layoutNeeded + " dw=" + dw + " dh=" + dh);
    }
    mService.mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mService.mRotation, mService.mCurConfiguration.uiMode);
    if (isDefaultDisplay) {
        // Not needed on non-default displays.
        mService.mSystemDecorLayer = mService.mPolicy.getSystemDecorLayerLw();
        mService.mScreenRect.set(0, 0, dw, dh);
    }
    mService.mPolicy.getContentRectLw(mTmpContentRect);
    displayContent.resize(mTmpContentRect);
    int seq = mService.mLayoutSeq + 1;
    if (seq < 0)
        seq = 0;
    mService.mLayoutSeq = seq;
    boolean behindDream = false;
    // First perform layout of any root windows (not attached
    // to another window).
    int topAttached = -1;
    for (i = N - 1; i >= 0; i--) {
        final WindowState win = windows.get(i);
        // Don't do layout of a window if it is not visible, or
        // soon won't be visible, to avoid wasting time and funky
        // changes while a window is animating away.
        final boolean gone = (behindDream && mService.mPolicy.canBeForceHidden(win, win.mAttrs)) || win.isGoneForLayoutLw();
        if (DEBUG_LAYOUT && !win.mLayoutAttached) {
            Slog.v(TAG, "1ST PASS " + win + ": gone=" + gone + " mHaveFrame=" + win.mHaveFrame + " mLayoutAttached=" + win.mLayoutAttached + " screen changed=" + win.isConfigChanged());
            final AppWindowToken atoken = win.mAppToken;
            if (gone)
                Slog.v(TAG, "  GONE: mViewVisibility=" + win.mViewVisibility + " mRelayoutCalled=" + win.mRelayoutCalled + " hidden=" + win.mRootToken.hidden + " hiddenRequested=" + (atoken != null && atoken.hiddenRequested) + " mAttachedHidden=" + win.mAttachedHidden);
            else
                Slog.v(TAG, "  VIS: mViewVisibility=" + win.mViewVisibility + " mRelayoutCalled=" + win.mRelayoutCalled + " hidden=" + win.mRootToken.hidden + " hiddenRequested=" + (atoken != null && atoken.hiddenRequested) + " mAttachedHidden=" + win.mAttachedHidden);
        }
        // just don't display").
        if (!gone || !win.mHaveFrame || win.mLayoutNeeded || ((win.isConfigChanged() || win.setReportResizeHints()) && !win.isGoneForLayoutLw() && ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || (win.mHasSurface && win.mAppToken != null && win.mAppToken.layoutConfigChanges)))) {
            if (!win.mLayoutAttached) {
                if (initial) {
                    //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial");
                    win.mContentChanged = false;
                }
                if (win.mAttrs.type == TYPE_DREAM) {
                    // Don't layout windows behind a dream, so that if it
                    // does stuff like hide the status bar we won't get a
                    // bad transition when it goes away.
                    behindDream = true;
                }
                win.mLayoutNeeded = false;
                win.prelayout();
                mService.mPolicy.layoutWindowLw(win, null);
                win.mLayoutSeq = seq;
                // Window frames may have changed. Update dim layer with the new bounds.
                final Task task = win.getTask();
                if (task != null) {
                    displayContent.mDimLayerController.updateDimLayer(task);
                }
                if (DEBUG_LAYOUT)
                    Slog.v(TAG, "  LAYOUT: mFrame=" + win.mFrame + " mContainingFrame=" + win.mContainingFrame + " mDisplayFrame=" + win.mDisplayFrame);
            } else {
                if (topAttached < 0)
                    topAttached = i;
            }
        }
    }
    boolean attachedBehindDream = false;
    // that are themselves attached.
    for (i = topAttached; i >= 0; i--) {
        final WindowState win = windows.get(i);
        if (win.mLayoutAttached) {
            if (DEBUG_LAYOUT)
                Slog.v(TAG, "2ND PASS " + win + " mHaveFrame=" + win.mHaveFrame + " mViewVisibility=" + win.mViewVisibility + " mRelayoutCalled=" + win.mRelayoutCalled);
            // just don't display").
            if (attachedBehindDream && mService.mPolicy.canBeForceHidden(win, win.mAttrs)) {
                continue;
            }
            if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) || !win.mHaveFrame || win.mLayoutNeeded) {
                if (initial) {
                    //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial");
                    win.mContentChanged = false;
                }
                win.mLayoutNeeded = false;
                win.prelayout();
                mService.mPolicy.layoutWindowLw(win, win.mAttachedWindow);
                win.mLayoutSeq = seq;
                if (DEBUG_LAYOUT)
                    Slog.v(TAG, "  LAYOUT: mFrame=" + win.mFrame + " mContainingFrame=" + win.mContainingFrame + " mDisplayFrame=" + win.mDisplayFrame);
            }
        } else if (win.mAttrs.type == TYPE_DREAM) {
            // Don't layout windows behind a dream, so that if it
            // does stuff like hide the status bar we won't get a
            // bad transition when it goes away.
            attachedBehindDream = behindDream;
        }
    }
    // Window frames may have changed. Tell the input dispatcher about it.
    mService.mInputMonitor.setUpdateInputWindowsNeededLw();
    if (updateInputWindows) {
        mService.mInputMonitor.updateInputWindowsLw(false);
    }
    mService.mPolicy.finishLayoutLw();
    mService.mH.sendEmptyMessage(UPDATE_DOCKED_STACK_DIVIDER);
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 49 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class WindowStateAnimator method calculateSurfaceWindowCrop.

void calculateSurfaceWindowCrop(Rect clipRect, Rect finalClipRect) {
    final WindowState w = mWin;
    final DisplayContent displayContent = w.getDisplayContent();
    if (displayContent == null) {
        clipRect.setEmpty();
        finalClipRect.setEmpty();
        return;
    }
    final DisplayInfo displayInfo = displayContent.getDisplayInfo();
    if (DEBUG_WINDOW_CROP)
        Slog.d(TAG, "Updating crop win=" + w + " mLastCrop=" + mLastClipRect);
    // Need to recompute a new system decor rect each time.
    if (!w.isDefaultDisplay()) {
        // On a different display there is no system decor.  Crop the window
        // by the screen boundaries.
        mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height());
        mSystemDecorRect.intersect(-w.mCompatFrame.left, -w.mCompatFrame.top, displayInfo.logicalWidth - w.mCompatFrame.left, displayInfo.logicalHeight - w.mCompatFrame.top);
    } else if (w.mLayer >= mService.mSystemDecorLayer) {
        // Above the decor layer is easy, just use the entire window.
        mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height());
    } else if (w.mDecorFrame.isEmpty()) {
        // Windows without policy decor aren't cropped.
        mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height());
    } else if (w.mAttrs.type == LayoutParams.TYPE_WALLPAPER && mAnimator.isAnimating()) {
        // If we're animating, the wallpaper crop should only be updated at the end of the
        // animation.
        mTmpClipRect.set(mSystemDecorRect);
        calculateSystemDecorRect();
        mSystemDecorRect.union(mTmpClipRect);
    } else {
        // Crop to the system decor specified by policy.
        calculateSystemDecorRect();
        if (DEBUG_WINDOW_CROP)
            Slog.d(TAG, "Applying decor to crop win=" + w + " mDecorFrame=" + w.mDecorFrame + " mSystemDecorRect=" + mSystemDecorRect);
    }
    final boolean fullscreen = w.isFrameFullscreen(displayInfo);
    final boolean isFreeformResizing = w.isDragResizing() && w.getResizeMode() == DRAG_RESIZE_MODE_FREEFORM;
    // We use the clip rect as provided by the tranformation for non-fullscreen windows to
    // avoid premature clipping with the system decor rect.
    clipRect.set((mHasClipRect && !fullscreen) ? mClipRect : mSystemDecorRect);
    if (DEBUG_WINDOW_CROP)
        Slog.d(TAG, "win=" + w + " Initial clip rect: " + clipRect + " mHasClipRect=" + mHasClipRect + " fullscreen=" + fullscreen);
    if (isFreeformResizing && !w.isChildWindow()) {
        // For freeform resizing non child windows, we are using the big surface positioned
        // at 0,0. Thus we must express the crop in that coordinate space.
        clipRect.offset(w.mShownPosition.x, w.mShownPosition.y);
    }
    // Expand the clip rect for surface insets.
    final WindowManager.LayoutParams attrs = w.mAttrs;
    clipRect.left -= attrs.surfaceInsets.left;
    clipRect.top -= attrs.surfaceInsets.top;
    clipRect.right += attrs.surfaceInsets.right;
    clipRect.bottom += attrs.surfaceInsets.bottom;
    if (mHasClipRect && fullscreen) {
        // We intersect the clip rect specified by the transformation with the expanded system
        // decor rect to prevent artifacts from drawing during animation if the transformation
        // clip rect extends outside the system decor rect.
        clipRect.intersect(mClipRect);
    }
    // The clip rect was generated assuming (0,0) as the window origin,
    // so we need to translate to match the actual surface coordinates.
    clipRect.offset(attrs.surfaceInsets.left, attrs.surfaceInsets.top);
    finalClipRect.setEmpty();
    adjustCropToStackBounds(w, clipRect, finalClipRect, isFreeformResizing);
    if (DEBUG_WINDOW_CROP)
        Slog.d(TAG, "win=" + w + " Clip rect after stack adjustment=" + clipRect);
    w.transformClipRectFromScreenToSurfaceSpace(clipRect);
    // See {@link WindowState#notifyMovedInStack} for why this is necessary.
    if (w.hasJustMovedInStack() && mLastClipRect.isEmpty() && !clipRect.isEmpty()) {
        clipRect.setEmpty();
    }
}
Also used : DisplayInfo(android.view.DisplayInfo) LayoutParams(android.view.WindowManager.LayoutParams) WindowManager(android.view.WindowManager)

Example 50 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class WindowState method getBackdropFrame.

Rect getBackdropFrame(Rect frame) {
    // When the task is docked, we send fullscreen sized backDropFrame as soon as resizing
    // start even if we haven't received the relayout window, so that the client requests
    // the relayout sooner. When dragging stops, backDropFrame needs to stay fullscreen
    // until the window to small size, otherwise the multithread renderer will shift last
    // one or more frame to wrong offset. So here we send fullscreen backdrop if either
    // isDragResizing() or isDragResizeChanged() is true.
    boolean resizing = isDragResizing() || isDragResizeChanged();
    if (StackId.useWindowFrameForBackdrop(getStackId()) || !resizing) {
        return frame;
    }
    DisplayInfo displayInfo = getDisplayInfo();
    mTmpRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
    return mTmpRect;
}
Also used : DisplayInfo(android.view.DisplayInfo)

Aggregations

DisplayInfo (android.view.DisplayInfo)186 Point (android.graphics.Point)53 Rect (android.graphics.Rect)29 RemoteException (android.os.RemoteException)19 Display (android.view.Display)11 Animation (android.view.animation.Animation)10 Bitmap (android.graphics.Bitmap)9 WindowManager (android.view.WindowManager)8 DividerSnapAlgorithm (com.android.internal.policy.DividerSnapAlgorithm)8 Canvas (android.graphics.Canvas)6 SurfaceControl (android.view.SurfaceControl)6 LayoutParams (android.view.WindowManager.LayoutParams)6 DisplayManager (android.hardware.display.DisplayManager)5 DisplayMetrics (android.util.DisplayMetrics)5 Surface (android.view.Surface)5 InputDevice (android.view.InputDevice)4 SnapTarget (com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 OutOfResourcesException (android.view.Surface.OutOfResourcesException)3