Search in sources :

Example 31 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 32 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)

Example 33 with DisplayInfo

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

the class WindowManagerService method updateWallpaperVisibilityLocked.

void updateWallpaperVisibilityLocked() {
    final boolean visible = isWallpaperVisible(mWallpaperTarget);
    final DisplayContent displayContent = mWallpaperTarget.mDisplayContent;
    final DisplayInfo displayInfo = displayContent.getDisplayInfo();
    final int dw = displayInfo.appWidth;
    final int dh = displayInfo.appHeight;
    int curTokenIndex = mWallpaperTokens.size();
    while (curTokenIndex > 0) {
        curTokenIndex--;
        WindowToken token = mWallpaperTokens.get(curTokenIndex);
        if (token.hidden == visible) {
            token.hidden = !visible;
            // Need to do a layout to ensure the wallpaper now has the
            // correct size.
            getDefaultDisplayContentLocked().layoutNeeded = true;
        }
        int curWallpaperIndex = token.windows.size();
        while (curWallpaperIndex > 0) {
            curWallpaperIndex--;
            WindowState wallpaper = token.windows.get(curWallpaperIndex);
            if (visible) {
                updateWallpaperOffsetLocked(wallpaper, dw, dh, false);
            }
            dispatchWallpaperVisibility(wallpaper, visible);
        }
    }
}
Also used : DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point)

Example 34 with DisplayInfo

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

the class DisplayManagerGlobal method getDisplayInfo.

/**
     * Get information about a particular logical display.
     *
     * @param displayId The logical display id.
     * @return Information about the specified display, or null if it does not exist.
     * This object belongs to an internal cache and should be treated as if it were immutable.
     */
public DisplayInfo getDisplayInfo(int displayId) {
    try {
        synchronized (mLock) {
            DisplayInfo info;
            if (USE_CACHE) {
                info = mDisplayInfoCache.get(displayId);
                if (info != null) {
                    return info;
                }
            }
            info = mDm.getDisplayInfo(displayId);
            if (info == null) {
                return null;
            }
            if (USE_CACHE) {
                mDisplayInfoCache.put(displayId, info);
            }
            registerCallbackIfNeededLocked();
            if (DEBUG) {
                Log.d(TAG, "getDisplayInfo: displayId=" + displayId + ", info=" + info);
            }
            return info;
        }
    } catch (RemoteException ex) {
        Log.e(TAG, "Could not get display information from display manager.", ex);
        return null;
    }
}
Also used : DisplayInfo(android.view.DisplayInfo) RemoteException(android.os.RemoteException)

Example 35 with DisplayInfo

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

the class ColorFade method prepare.

/**
     * Warms up the color fade in preparation for turning on or off.
     * This method prepares a GL context, and captures a screen shot.
     *
     * @param mode The desired mode for the upcoming animation.
     * @return True if the color fade is ready, false if it is uncontrollable.
     */
public boolean prepare(Context context, int mode) {
    if (DEBUG) {
        Slog.d(TAG, "prepare: mode=" + mode);
    }
    mMode = mode;
    // Get the display size and layer stack.
    // This is not expected to change while the color fade surface is showing.
    DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(mDisplayId);
    mDisplayLayerStack = displayInfo.layerStack;
    mDisplayWidth = displayInfo.getNaturalWidth();
    mDisplayHeight = displayInfo.getNaturalHeight();
    // Prepare the surface for drawing.
    if (!(createSurface() && createEglContext() && createEglSurface() && captureScreenshotTextureAndSetViewport())) {
        dismiss();
        return false;
    }
    // Init GL
    if (!attachEglContext()) {
        return false;
    }
    try {
        if (!initGLShaders(context) || !initGLBuffers() || checkGlErrors("prepare")) {
            detachEglContext();
            dismiss();
            return false;
        }
    } finally {
        detachEglContext();
    }
    // Done.
    mCreatedResources = true;
    mPrepared = true;
    // painting the screenshot as-is.
    if (mode == MODE_COOL_DOWN) {
        for (int i = 0; i < DEJANK_FRAMES; i++) {
            draw(1.0f);
        }
    }
    return true;
}
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