예제 #1
0
  private void updateWindowsAppsAndRotationAnimationsLocked() {
    final ArrayList<AppWindowToken> appTokens = mService.mAnimatingAppTokens;
    int i;
    final int NAT = appTokens.size();
    for (i = 0; i < NAT; i++) {
      final AppWindowAnimator appAnimator = appTokens.get(i).mAppAnimator;
      final boolean wasAnimating =
          appAnimator.animation != null
              && appAnimator.animation != AppWindowAnimator.sDummyAnimation;
      if (appAnimator.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
        mAnimating = true;
      } else if (wasAnimating) {
        // stopped animating, do one more pass through the layout
        mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
          mService.debugLayoutRepeats(
              "appToken " + appAnimator.mAppToken + " done", mPendingLayoutChanges);
        }
        if (WindowManagerService.DEBUG_ANIM)
          Slog.v(TAG, "updateWindowsApps...: done animating " + appAnimator.mAppToken);
      }
    }

    final int NEAT = mService.mExitingAppTokens.size();
    for (i = 0; i < NEAT; i++) {
      final AppWindowAnimator appAnimator = mService.mExitingAppTokens.get(i).mAppAnimator;
      final boolean wasAnimating =
          appAnimator.animation != null
              && appAnimator.animation != AppWindowAnimator.sDummyAnimation;
      if (appAnimator.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
        mAnimating = true;
      } else if (wasAnimating) {
        // stopped animating, do one more pass through the layout
        mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
          mService.debugLayoutRepeats(
              "exiting appToken " + appAnimator.mAppToken + " done", mPendingLayoutChanges);
        }
        if (WindowManagerService.DEBUG_ANIM)
          Slog.v(TAG, "updateWindowsApps...: done animating exiting " + appAnimator.mAppToken);
      }
    }

    if (mScreenRotationAnimation != null && mScreenRotationAnimation.isAnimating()) {
      if (mScreenRotationAnimation.stepAnimationLocked(mCurrentTime)) {
        mAnimating = true;
      } else {
        mBulkUpdateParams |= SET_UPDATE_ROTATION;
        mScreenRotationAnimation.kill();
        mScreenRotationAnimation = null;
      }
    }
  }
예제 #2
0
  synchronized void animate() {
    mPendingLayoutChanges = 0;
    mCurrentTime = SystemClock.uptimeMillis();
    mBulkUpdateParams = 0;
    boolean wasAnimating = mAnimating;
    mAnimating = false;
    if (WindowManagerService.DEBUG_WINDOW_TRACE) {
      Slog.i(TAG, "!!! animate: entry time=" + mCurrentTime);
    }

    // Update animations of all applications, including those
    // associated with exiting/removed apps
    Surface.openTransaction();

    try {
      updateWindowsAppsAndRotationAnimationsLocked();
      performAnimationsLocked();
      testWallpaperAndBackgroundLocked();

      // THIRD LOOP: Update the surfaces of all windows.

      if (mScreenRotationAnimation != null) {
        mScreenRotationAnimation.updateSurfaces();
      }

      final int N = mWinAnimators.size();
      for (int i = 0; i < N; i++) {
        mWinAnimators.get(i).prepareSurfaceLocked(true);
      }

      if (mDimParams != null) {
        mDimAnimator.updateParameters(mContext.getResources(), mDimParams, mCurrentTime);
      }
      if (mDimAnimator != null && mDimAnimator.mDimShown) {
        mAnimating |=
            mDimAnimator.updateSurface(isDimming(), mCurrentTime, !mService.okToDisplay());
      }

      if (mService.mBlackFrame != null) {
        if (mScreenRotationAnimation != null) {
          mService.mBlackFrame.setMatrix(
              mScreenRotationAnimation.getEnterTransformation().getMatrix());
        } else {
          mService.mBlackFrame.clearMatrix();
        }
      }

      if (mService.mWatermark != null) {
        mService.mWatermark.drawIfNeeded();
      }
    } catch (RuntimeException e) {
      Log.wtf(TAG, "Unhandled exception in Window Manager", e);
    } finally {
      Surface.closeTransaction();
    }

    mService.bulkSetParameters(mBulkUpdateParams, mPendingLayoutChanges);

    if (mAnimating) {
      mService.scheduleAnimationLocked();
    } else if (wasAnimating) {
      mService.requestTraversalLocked();
    }
    if (WindowManagerService.DEBUG_WINDOW_TRACE) {
      Slog.i(
          TAG,
          "!!! animate: exit mAnimating="
              + mAnimating
              + " mBulkUpdateParams="
              + Integer.toHexString(mBulkUpdateParams)
              + " mPendingLayoutChanges="
              + Integer.toHexString(mPendingLayoutChanges));
    }
  }