Search in sources :

Example 11 with DisplayInfo

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

the class WindowManagerService method performLayoutLockedInner.

private 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;
    final int NFW = mFakeWindows.size();
    for (int i = 0; i < NFW; i++) {
        mFakeWindows.get(i).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);
    }
    WindowStateAnimator universeBackground = null;
    mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mRotation);
    if (isDefaultDisplay) {
        // Not needed on non-default displays.
        mSystemDecorLayer = mPolicy.getSystemDecorRectLw(mSystemDecorRect);
        mScreenRect.set(0, 0, dw, dh);
    }
    int seq = mLayoutSeq + 1;
    if (seq < 0)
        seq = 0;
    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 && 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.mAttrs.type == TYPE_KEYGUARD && win.isConfigChanged()) || win.mAttrs.type == TYPE_UNIVERSE_BACKGROUND) {
            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();
                mPolicy.layoutWindowLw(win, win.mAttrs, null);
                win.mLayoutSeq = seq;
                if (DEBUG_LAYOUT)
                    Slog.v(TAG, "  LAYOUT: mFrame=" + win.mFrame + " mContainingFrame=" + win.mContainingFrame + " mDisplayFrame=" + win.mDisplayFrame);
            } else {
                if (topAttached < 0)
                    topAttached = i;
            }
        }
        if (win.mViewVisibility == View.VISIBLE && win.mAttrs.type == TYPE_UNIVERSE_BACKGROUND && universeBackground == null) {
            universeBackground = win.mWinAnimator;
        }
    }
    if (mAnimator.mUniverseBackground != universeBackground) {
        mFocusMayChange = true;
        mAnimator.mUniverseBackground = universeBackground;
    }
    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 && 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();
                mPolicy.layoutWindowLw(win, win.mAttrs, 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.
    mInputMonitor.setUpdateInputWindowsNeededLw();
    if (updateInputWindows) {
        mInputMonitor.updateInputWindowsLw(false);
    }
    mPolicy.finishLayoutLw();
}
Also used : DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point)

Example 12 with DisplayInfo

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

the class WindowManagerService method screenshotApplications.

/**
     * Takes a snapshot of the screen.  In landscape mode this grabs the whole screen.
     * In portrait mode, it grabs the upper region of the screen based on the vertical dimension
     * of the target image.
     *
     * @param displayId the Display to take a screenshot of.
     * @param width the width of the target bitmap
     * @param height the height of the target bitmap
     */
@Override
public Bitmap screenshotApplications(IBinder appToken, int displayId, int width, int height) {
    if (!checkCallingPermission(android.Manifest.permission.READ_FRAME_BUFFER, "screenshotApplications()")) {
        throw new SecurityException("Requires READ_FRAME_BUFFER permission");
    }
    Bitmap rawss = null;
    int maxLayer = 0;
    final Rect frame = new Rect();
    float scale = 0;
    int dw, dh;
    int rot = Surface.ROTATION_0;
    boolean screenshotReady;
    int minLayer;
    if (appToken == null) {
        screenshotReady = true;
        minLayer = 0;
    } else {
        screenshotReady = false;
        minLayer = Integer.MAX_VALUE;
    }
    int retryCount = 0;
    WindowState appWin = null;
    do {
        if (retryCount++ > 0) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
        }
        synchronized (mWindowMap) {
            final DisplayContent displayContent = getDisplayContentLocked(displayId);
            if (displayContent == null) {
                return null;
            }
            final DisplayInfo displayInfo = displayContent.getDisplayInfo();
            dw = displayInfo.logicalWidth;
            dh = displayInfo.logicalHeight;
            int aboveAppLayer = mPolicy.windowTypeToLayerLw(TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER + TYPE_LAYER_OFFSET;
            aboveAppLayer += TYPE_LAYER_MULTIPLIER;
            boolean isImeTarget = mInputMethodTarget != null && mInputMethodTarget.mAppToken != null && mInputMethodTarget.mAppToken.appToken != null && mInputMethodTarget.mAppToken.appToken.asBinder() == appToken;
            // Figure out the part of the screen that is actually the app.
            boolean including = false;
            appWin = null;
            final WindowList windows = displayContent.getWindowList();
            for (int i = windows.size() - 1; i >= 0; i--) {
                WindowState ws = windows.get(i);
                if (!ws.mHasSurface) {
                    continue;
                }
                if (ws.mLayer >= aboveAppLayer) {
                    continue;
                }
                // taking a screenshot of a specific app.
                if (!including && appToken != null) {
                    // is not the current IME target.
                    if (!ws.mIsImWindow || !isImeTarget) {
                        // is not associated with the screenshot app.
                        if (ws.mAppToken == null || ws.mAppToken.token != appToken) {
                            continue;
                        }
                        appWin = ws;
                    }
                }
                // We keep on including windows until we go past a full-screen
                // window.
                boolean fullscreen = ws.isFullscreen(dw, dh);
                including = !ws.mIsImWindow && !fullscreen;
                final WindowStateAnimator winAnim = ws.mWinAnimator;
                if (maxLayer < winAnim.mSurfaceLayer) {
                    maxLayer = winAnim.mSurfaceLayer;
                }
                if (minLayer > winAnim.mSurfaceLayer) {
                    minLayer = winAnim.mSurfaceLayer;
                }
                // Don't include wallpaper in bounds calculation
                if (!ws.mIsWallpaper) {
                    final Rect wf = ws.mFrame;
                    final Rect cr = ws.mContentInsets;
                    int left = wf.left + cr.left;
                    int top = wf.top + cr.top;
                    int right = wf.right - cr.right;
                    int bottom = wf.bottom - cr.bottom;
                    frame.union(left, top, right, bottom);
                }
                if (ws.mAppToken != null && ws.mAppToken.token == appToken && ws.isDisplayedLw()) {
                    screenshotReady = true;
                }
                if (fullscreen) {
                    // No point in continuing down through windows.
                    break;
                }
            }
            if (appToken != null && appWin == null) {
                // Can't find a window to snapshot.
                if (DEBUG_SCREENSHOT)
                    Slog.i(TAG, "Screenshot: Couldn't find a surface matching " + appToken);
                return null;
            }
            if (!screenshotReady) {
                // Delay and hope that window gets drawn.
                if (DEBUG_SCREENSHOT)
                    Slog.i(TAG, "Screenshot: No image ready for " + appToken + ", " + appWin + " drawState=" + appWin.mWinAnimator.mDrawState);
                continue;
            }
            // Constrain frame to the screen size.
            frame.intersect(0, 0, dw, dh);
            if (frame.isEmpty() || maxLayer == 0) {
                if (DEBUG_SCREENSHOT)
                    Slog.i(TAG, "Screenshot of " + appToken + ": returning null frame=" + frame.toShortString() + " maxLayer=" + maxLayer);
                return null;
            }
            // The screenshot API does not apply the current screen rotation.
            rot = getDefaultDisplayContentLocked().getDisplay().getRotation();
            int fw = frame.width();
            int fh = frame.height();
            // Constrain thumbnail to smaller of screen width or height. Assumes aspect
            // of thumbnail is the same as the screen (in landscape) or square.
            float targetWidthScale = width / (float) fw;
            float targetHeightScale = height / (float) fh;
            if (dw <= dh) {
                scale = targetWidthScale;
                // select the slightly larger value so we fill the entire bitmap
                if (targetHeightScale > scale && (int) (targetHeightScale * fw) == width) {
                    scale = targetHeightScale;
                }
            } else {
                scale = targetHeightScale;
                // select the slightly larger value so we fill the entire bitmap
                if (targetWidthScale > scale && (int) (targetWidthScale * fh) == height) {
                    scale = targetWidthScale;
                }
            }
            // The screen shot will contain the entire screen.
            dw = (int) (dw * scale);
            dh = (int) (dh * scale);
            if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) {
                int tmp = dw;
                dw = dh;
                dh = tmp;
                rot = (rot == Surface.ROTATION_90) ? Surface.ROTATION_270 : Surface.ROTATION_90;
            }
            if (DEBUG_SCREENSHOT) {
                Slog.i(TAG, "Screenshot: " + dw + "x" + dh + " from " + minLayer + " to " + maxLayer + " appToken=" + appToken);
                for (int i = 0; i < windows.size(); i++) {
                    WindowState win = windows.get(i);
                    Slog.i(TAG, win + ": " + win.mLayer + " animLayer=" + win.mWinAnimator.mAnimLayer + " surfaceLayer=" + win.mWinAnimator.mSurfaceLayer);
                }
            }
            rawss = SurfaceControl.screenshot(dw, dh, minLayer, maxLayer);
        }
    } while (!screenshotReady && retryCount <= MAX_SCREENSHOT_RETRIES);
    if (retryCount > MAX_SCREENSHOT_RETRIES)
        Slog.i(TAG, "Screenshot max retries " + retryCount + " of " + appToken + " appWin=" + (appWin == null ? "null" : (appWin + " drawState=" + appWin.mWinAnimator.mDrawState)));
    if (rawss == null) {
        Slog.w(TAG, "Screenshot failure taking screenshot for (" + dw + "x" + dh + ") to layer " + maxLayer);
        return null;
    }
    Bitmap bm = Bitmap.createBitmap(width, height, rawss.getConfig());
    Matrix matrix = new Matrix();
    ScreenRotationAnimation.createRotationMatrix(rot, dw, dh, matrix);
    matrix.postTranslate(-FloatMath.ceil(frame.left * scale), -FloatMath.ceil(frame.top * scale));
    Canvas canvas = new Canvas(bm);
    canvas.drawColor(0xFF000000);
    canvas.drawBitmap(rawss, matrix, null);
    canvas.setBitmap(null);
    if (true || DEBUG_SCREENSHOT) {
        // TEST IF IT's ALL BLACK
        int[] buffer = new int[bm.getWidth() * bm.getHeight()];
        bm.getPixels(buffer, 0, bm.getWidth(), 0, 0, bm.getWidth(), bm.getHeight());
        boolean allBlack = true;
        for (int i = 0; i < buffer.length; i++) {
            if (buffer[i] != Color.BLACK) {
                allBlack = false;
                break;
            }
        }
        if (allBlack) {
            Slog.i(TAG, "Screenshot " + appWin + " was all black! mSurfaceLayer=" + (appWin != null ? appWin.mWinAnimator.mSurfaceLayer : "null") + " minLayer=" + minLayer + " maxLayer=" + maxLayer);
        }
    }
    rawss.recycle();
    return bm;
}
Also used : Rect(android.graphics.Rect) DisplayInfo(android.view.DisplayInfo) Canvas(android.graphics.Canvas) Point(android.graphics.Point) Bitmap(android.graphics.Bitmap) Matrix(android.graphics.Matrix)

Example 13 with DisplayInfo

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

the class WindowState method computeFrameLw.

@Override
public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf) {
    mHaveFrame = true;
    final Rect container = mContainingFrame;
    container.set(pf);
    final Rect display = mDisplayFrame;
    display.set(df);
    final int pw = container.right - container.left;
    final int ph = container.bottom - container.top;
    int w, h;
    if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) {
        if (mAttrs.width < 0) {
            w = pw;
        } else if (mEnforceSizeCompat) {
            w = (int) (mAttrs.width * mGlobalScale + .5f);
        } else {
            w = mAttrs.width;
        }
        if (mAttrs.height < 0) {
            h = ph;
        } else if (mEnforceSizeCompat) {
            h = (int) (mAttrs.height * mGlobalScale + .5f);
        } else {
            h = mAttrs.height;
        }
    } else {
        if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) {
            w = pw;
        } else if (mEnforceSizeCompat) {
            w = (int) (mRequestedWidth * mGlobalScale + .5f);
        } else {
            w = mRequestedWidth;
        }
        if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
            h = ph;
        } else if (mEnforceSizeCompat) {
            h = (int) (mRequestedHeight * mGlobalScale + .5f);
        } else {
            h = mRequestedHeight;
        }
    }
    if (!mParentFrame.equals(pf)) {
        //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame
        //        + " to " + pf);
        mParentFrame.set(pf);
        mContentChanged = true;
    }
    if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
        mLastRequestedWidth = mRequestedWidth;
        mLastRequestedHeight = mRequestedHeight;
        mContentChanged = true;
    }
    final Rect overscan = mOverscanFrame;
    overscan.set(of);
    final Rect content = mContentFrame;
    content.set(cf);
    final Rect visible = mVisibleFrame;
    visible.set(vf);
    final Rect frame = mFrame;
    final int fw = frame.width();
    final int fh = frame.height();
    //System.out.println("In: w=" + w + " h=" + h + " container=" +
    //                   container + " x=" + mAttrs.x + " y=" + mAttrs.y);
    float x, y;
    if (mEnforceSizeCompat) {
        x = mAttrs.x * mGlobalScale;
        y = mAttrs.y * mGlobalScale;
    } else {
        x = mAttrs.x;
        y = mAttrs.y;
    }
    Gravity.apply(mAttrs.gravity, w, h, container, (int) (x + mAttrs.horizontalMargin * pw), (int) (y + mAttrs.verticalMargin * ph), frame);
    //System.out.println("Out: " + mFrame);
    // Now make sure the window fits in the overall display.
    Gravity.applyDisplay(mAttrs.gravity, df, frame);
    // final window frame.
    if (content.left < frame.left)
        content.left = frame.left;
    if (content.top < frame.top)
        content.top = frame.top;
    if (content.right > frame.right)
        content.right = frame.right;
    if (content.bottom > frame.bottom)
        content.bottom = frame.bottom;
    if (visible.left < frame.left)
        visible.left = frame.left;
    if (visible.top < frame.top)
        visible.top = frame.top;
    if (visible.right > frame.right)
        visible.right = frame.right;
    if (visible.bottom > frame.bottom)
        visible.bottom = frame.bottom;
    final Rect overscanInsets = mOverscanInsets;
    overscanInsets.left = overscan.left > frame.left ? overscan.left - frame.left : 0;
    overscanInsets.top = overscan.top > frame.top ? overscan.top - frame.top : 0;
    overscanInsets.right = overscan.right < frame.right ? frame.right - overscan.right : 0;
    overscanInsets.bottom = overscan.bottom < frame.bottom ? frame.bottom - overscan.bottom : 0;
    final Rect contentInsets = mContentInsets;
    contentInsets.left = content.left - frame.left;
    contentInsets.top = content.top - frame.top;
    contentInsets.right = frame.right - content.right;
    contentInsets.bottom = frame.bottom - content.bottom;
    final Rect visibleInsets = mVisibleInsets;
    visibleInsets.left = visible.left - frame.left;
    visibleInsets.top = visible.top - frame.top;
    visibleInsets.right = frame.right - visible.right;
    visibleInsets.bottom = frame.bottom - visible.bottom;
    mCompatFrame.set(frame);
    if (mEnforceSizeCompat) {
        // If there is a size compatibility scale being applied to the
        // window, we need to apply this to its insets so that they are
        // reported to the app in its coordinate space.
        overscanInsets.scale(mInvGlobalScale);
        contentInsets.scale(mInvGlobalScale);
        visibleInsets.scale(mInvGlobalScale);
        // Also the scaled frame that we report to the app needs to be
        // adjusted to be in its coordinate space.
        mCompatFrame.scale(mInvGlobalScale);
    }
    if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
        final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
        mService.updateWallpaperOffsetLocked(this, displayInfo.appWidth, displayInfo.appHeight, false);
    }
    if (WindowManagerService.localLOGV) {
        //if ("com.google.android.youtube".equals(mAttrs.packageName)
        //        && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
        Slog.v(TAG, "Resolving (mRequestedWidth=" + mRequestedWidth + ", mRequestedheight=" + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph + "): frame=" + mFrame.toShortString() + " ci=" + contentInsets.toShortString() + " vi=" + visibleInsets.toShortString());
    //}
    }
}
Also used : Rect(android.graphics.Rect) DisplayInfo(android.view.DisplayInfo)

Example 14 with DisplayInfo

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

the class WindowStateAnimator method stepAnimationLocked.

// This must be called while inside a transaction.  Returns true if
// there is more animation to run.
boolean stepAnimationLocked(long currentTime) {
    // Save the animation state as it was before this step so WindowManagerService can tell if
    // we just started or just stopped animating by comparing mWasAnimating with isAnimating().
    mWasAnimating = mAnimating;
    if (mService.okToDisplay()) {
        if (mWin.isDrawnLw() && mAnimation != null) {
            mHasTransformation = true;
            mHasLocalTransformation = true;
            if (!mLocalAnimating) {
                if (DEBUG_ANIM)
                    Slog.v(TAG, "Starting animation in " + this + " @ " + currentTime + ": ww=" + mWin.mFrame.width() + " wh=" + mWin.mFrame.height() + " dw=" + mAnimDw + " dh=" + mAnimDh + " scale=" + mService.mWindowAnimationScale);
                mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), mAnimDw, mAnimDh);
                final DisplayInfo displayInfo = mWin.mDisplayContent.getDisplayInfo();
                mAnimDw = displayInfo.appWidth;
                mAnimDh = displayInfo.appHeight;
                mAnimation.setStartTime(currentTime);
                mLocalAnimating = true;
                mAnimating = true;
            }
            if ((mAnimation != null) && mLocalAnimating) {
                if (stepAnimation(currentTime)) {
                    return true;
                }
            }
            if (DEBUG_ANIM)
                Slog.v(TAG, "Finished animation in " + this + " @ " + currentTime);
        //WindowManagerService.this.dump();
        }
        mHasLocalTransformation = false;
        if ((!mLocalAnimating || mAnimationIsEntrance) && mAppAnimator != null && mAppAnimator.animation != null) {
            // When our app token is animating, we kind-of pretend like
            // we are as well.  Note the mLocalAnimating mAnimationIsEntrance
            // part of this check means that we will only do this if
            // our window is not currently exiting, or it is not
            // locally animating itself.  The idea being that one that
            // is exiting and doing a local animation should be removed
            // once that animation is done.
            mAnimating = true;
            mHasTransformation = true;
            mTransformation.clear();
            return false;
        } else if (mHasTransformation) {
            // Little trick to get through the path below to act like
            // we have finished an animation.
            mAnimating = true;
        } else if (isAnimating()) {
            mAnimating = true;
        }
    } else if (mAnimation != null) {
        // If the display is frozen, and there is a pending animation,
        // clear it and make sure we run the cleanup code.
        mAnimating = true;
    }
    if (!mAnimating && !mLocalAnimating) {
        return false;
    }
    // Done animating, clean up.
    if (DEBUG_ANIM)
        Slog.v(TAG, "Animation done in " + this + ": exiting=" + mWin.mExiting + ", reportedVisible=" + (mWin.mAppToken != null ? mWin.mAppToken.reportedVisible : false));
    mAnimating = false;
    mLocalAnimating = false;
    if (mAnimation != null) {
        mAnimation.cancel();
        mAnimation = null;
    }
    if (mAnimator.mWindowDetachedWallpaper == mWin) {
        mAnimator.mWindowDetachedWallpaper = null;
    }
    mAnimLayer = mWin.mLayer;
    if (mWin.mIsImWindow) {
        mAnimLayer += mService.mInputMethodAnimLayerAdjustment;
    } else if (mIsWallpaper) {
        mAnimLayer += mService.mWallpaperAnimLayerAdjustment;
    }
    if (DEBUG_LAYERS)
        Slog.v(TAG, "Stepping win " + this + " anim layer: " + mAnimLayer);
    mHasTransformation = false;
    mHasLocalTransformation = false;
    if (mWin.mPolicyVisibility != mWin.mPolicyVisibilityAfterAnim) {
        if (WindowState.DEBUG_VISIBILITY) {
            Slog.v(TAG, "Policy visibility changing after anim in " + this + ": " + mWin.mPolicyVisibilityAfterAnim);
        }
        mWin.mPolicyVisibility = mWin.mPolicyVisibilityAfterAnim;
        mWin.mDisplayContent.layoutNeeded = true;
        if (!mWin.mPolicyVisibility) {
            if (mService.mCurrentFocus == mWin) {
                mService.mFocusMayChange = true;
            }
            // Window is no longer visible -- make sure if we were waiting
            // for it to be displayed before enabling the display, that
            // we allow the display to be enabled now.
            mService.enableScreenIfNeededLocked();
        }
    }
    mTransformation.clear();
    if (mDrawState == HAS_DRAWN && mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING && mWin.mAppToken != null && mWin.mAppToken.firstWindowDrawn && mWin.mAppToken.startingData != null) {
        if (DEBUG_STARTING_WINDOW)
            Slog.v(TAG, "Finish starting " + mWin.mToken + ": first real window done animating");
        mService.mFinishedStarting.add(mWin.mAppToken);
        mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
    }
    finishExit();
    final int displayId = mWin.mDisplayContent.getDisplayId();
    mAnimator.setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
    if (WindowManagerService.DEBUG_LAYOUT_REPEATS)
        mService.debugLayoutRepeats("WindowStateAnimator", mAnimator.getPendingLayoutChanges(displayId));
    if (mWin.mAppToken != null) {
        mWin.mAppToken.updateReportedVisibilityLocked();
    }
    return false;
}
Also used : DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point)

Example 15 with DisplayInfo

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

the class WindowManagerService method setUniverseTransformLocked.

public void setUniverseTransformLocked(WindowState window, float alpha, float offx, float offy, float dsdx, float dtdx, float dsdy, float dtdy) {
    Transformation transform = window.mWinAnimator.mUniverseTransform;
    transform.setAlpha(alpha);
    Matrix matrix = transform.getMatrix();
    matrix.getValues(mTmpFloats);
    mTmpFloats[Matrix.MTRANS_X] = offx;
    mTmpFloats[Matrix.MTRANS_Y] = offy;
    mTmpFloats[Matrix.MSCALE_X] = dsdx;
    mTmpFloats[Matrix.MSKEW_Y] = dtdx;
    mTmpFloats[Matrix.MSKEW_X] = dsdy;
    mTmpFloats[Matrix.MSCALE_Y] = dtdy;
    matrix.setValues(mTmpFloats);
    final DisplayInfo displayInfo = window.mDisplayContent.getDisplayInfo();
    final RectF dispRect = new RectF(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
    matrix.mapRect(dispRect);
    window.mGivenTouchableRegion.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
    window.mGivenTouchableRegion.op((int) dispRect.left, (int) dispRect.top, (int) dispRect.right, (int) dispRect.bottom, Region.Op.DIFFERENCE);
    window.mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION;
    window.mDisplayContent.layoutNeeded = true;
    performLayoutAndPlaceSurfacesLocked();
}
Also used : RectF(android.graphics.RectF) Transformation(android.view.animation.Transformation) Matrix(android.graphics.Matrix) 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