1010import android .util .Slog ;
1111import android .view .Surface ;
1212import android .view .WindowManager ;
13- import android .view .WindowManager .LayoutParams ;
1413import android .view .WindowManagerPolicy ;
1514import android .view .animation .Animation ;
1615
@@ -103,7 +102,7 @@ private void testWallpaperAndBackgroundLocked() {
103102 final int dw = mDw ;
104103 final int dh = mDh ;
105104 mWindowAnimationBackgroundSurface .show (dw , dh ,
106- target .mAnimLayer - WindowManagerService .LAYER_OFFSET_DIM ,
105+ target .mWinAnimator . mAnimLayer - WindowManagerService .LAYER_OFFSET_DIM ,
107106 mWindowAnimationBackgroundColor );
108107 } else if (mWindowAnimationBackgroundSurface != null ) {
109108 mWindowAnimationBackgroundSurface .hide ();
@@ -164,10 +163,9 @@ private void updateWindowsAndWallpaperLocked() {
164163 for (int i = mService .mWindows .size () - 1 ; i >= 0 ; i --) {
165164 WindowState w = mService .mWindows .get (i );
166165 WindowStateAnimator winAnimator = w .mWinAnimator ;
167-
168166 final WindowManager .LayoutParams attrs = w .mAttrs ;
169167
170- if (w .mSurface != null ) {
168+ if (winAnimator .mSurface != null ) {
171169 final boolean wasAnimating = winAnimator .mWasAnimating ;
172170 final boolean nowAnimating = winAnimator .stepAnimationLocked (mCurrentTime );
173171
@@ -181,13 +179,14 @@ private void updateWindowsAndWallpaperLocked() {
181179 // a detached wallpaper animation.
182180 if (nowAnimating ) {
183181 if (winAnimator .mAnimation != null ) {
184- if ((w . mAttrs .flags &FLAG_SHOW_WALLPAPER ) != 0
182+ if ((attrs .flags &FLAG_SHOW_WALLPAPER ) != 0
185183 && winAnimator .mAnimation .getDetachWallpaper ()) {
186- mService . mInnerFields . mDetachedWallpaper = w ;
184+ mDetachedWallpaper = w ;
187185 }
188186 if (winAnimator .mAnimation .getBackgroundColor () != 0 ) {
189187 if (mWindowAnimationBackground == null
190- || (w .mAnimLayer < mWindowAnimationBackground .mAnimLayer )) {
188+ || (winAnimator .mAnimLayer <
189+ mWindowAnimationBackground .mWinAnimator .mAnimLayer )) {
191190 mWindowAnimationBackground = w ;
192191 mWindowAnimationBackgroundColor =
193192 winAnimator .mAnimation .getBackgroundColor ();
@@ -202,14 +201,14 @@ private void updateWindowsAndWallpaperLocked() {
202201 // displayed behind it.
203202 if (w .mAppToken != null && w .mAppToken .animation != null
204203 && w .mAppToken .animating ) {
205- if ((w . mAttrs .flags &FLAG_SHOW_WALLPAPER ) != 0
204+ if ((attrs .flags &FLAG_SHOW_WALLPAPER ) != 0
206205 && w .mAppToken .animation .getDetachWallpaper ()) {
207- mService . mInnerFields . mDetachedWallpaper = w ;
206+ mDetachedWallpaper = w ;
208207 }
209208 if (w .mAppToken .animation .getBackgroundColor () != 0 ) {
210209 if (mWindowAnimationBackground == null
211- || (w .mAnimLayer <
212- mWindowAnimationBackground .mAnimLayer )) {
210+ || (winAnimator .mAnimLayer <
211+ mWindowAnimationBackground .mWinAnimator . mAnimLayer )) {
213212 mWindowAnimationBackground = w ;
214213 mWindowAnimationBackgroundColor =
215214 w .mAppToken .animation .getBackgroundColor ();
@@ -296,7 +295,7 @@ private void updateWindowsAndWallpaperLocked() {
296295 + w .isDrawnLw ()
297296 + ", isAnimating=" + winAnimator .isAnimating ());
298297 if (!w .isDrawnLw ()) {
299- Slog .v (TAG , "Not displayed: s=" + w .mSurface
298+ Slog .v (TAG , "Not displayed: s=" + winAnimator .mSurface
300299 + " pv=" + w .mPolicyVisibility
301300 + " dp=" + w .mDrawPending
302301 + " cdp=" + w .mCommitDrawPending
@@ -323,7 +322,7 @@ private void updateWindowsAndWallpaperLocked() {
323322 }
324323 }
325324 } else if (w .mReadyToShow ) {
326- if (w .performShowLocked ()) {
325+ if (winAnimator .performShowLocked ()) {
327326 mPendingLayoutChanges |= WindowManagerPolicy .FINISH_LAYOUT_REDO_ANIM ;
328327 if (WindowManagerService .DEBUG_LAYOUT_REPEATS ) {
329328 mService .debugLayoutRepeats ("updateWindowsAndWallpaperLocked 5" );
@@ -335,8 +334,8 @@ private void updateWindowsAndWallpaperLocked() {
335334 atoken .thumbnailTransactionSeq = mTransactionSequence ;
336335 atoken .thumbnailLayer = 0 ;
337336 }
338- if (atoken .thumbnailLayer < w .mAnimLayer ) {
339- atoken .thumbnailLayer = w .mAnimLayer ;
337+ if (atoken .thumbnailLayer < winAnimator .mAnimLayer ) {
338+ atoken .thumbnailLayer = winAnimator .mAnimLayer ;
340339 }
341340 }
342341 } // end forall windows
@@ -386,14 +385,10 @@ private void testTokenMayBeDrawnLocked() {
386385 }
387386
388387 private void performAnimationsLocked () {
389- if (WindowManagerService .DEBUG_APP_TRANSITIONS ) Slog .v (TAG , "*** ANIM STEP: seq="
390- + mTransactionSequence + " mAnimating="
391- + mAnimating );
392-
393388 mTokenMayBeDrawn = false ;
394389 mService .mInnerFields .mWallpaperMayChange = false ;
395390 mForceHiding = false ;
396- mService . mInnerFields . mDetachedWallpaper = null ;
391+ mDetachedWallpaper = null ;
397392 mWindowAnimationBackground = null ;
398393 mWindowAnimationBackgroundColor = 0 ;
399394
@@ -402,188 +397,8 @@ private void performAnimationsLocked() {
402397 if (mTokenMayBeDrawn ) {
403398 testTokenMayBeDrawnLocked ();
404399 }
405-
406- if (WindowManagerService .DEBUG_APP_TRANSITIONS ) Slog .v (TAG , "*** ANIM STEP: changes=0x"
407- + Integer .toHexString (mPendingLayoutChanges ));
408400 }
409401
410- public void prepareSurfaceLocked (final WindowState w , final boolean recoveringMemory ) {
411- if (w .mSurface == null ) {
412- if (w .mOrientationChanging ) {
413- if (WindowManagerService .DEBUG_ORIENTATION ) {
414- Slog .v (TAG , "Orientation change skips hidden " + w );
415- }
416- w .mOrientationChanging = false ;
417- }
418- return ;
419- }
420-
421- boolean displayed = false ;
422-
423- w .computeShownFrameLocked ();
424-
425- int width , height ;
426- if ((w .mAttrs .flags & LayoutParams .FLAG_SCALED ) != 0 ) {
427- // for a scaled surface, we just want to use
428- // the requested size.
429- width = w .mRequestedWidth ;
430- height = w .mRequestedHeight ;
431- } else {
432- width = w .mCompatFrame .width ();
433- height = w .mCompatFrame .height ();
434- }
435-
436- if (width < 1 ) {
437- width = 1 ;
438- }
439- if (height < 1 ) {
440- height = 1 ;
441- }
442- final boolean surfaceResized = w .mSurfaceW != width || w .mSurfaceH != height ;
443- if (surfaceResized ) {
444- w .mSurfaceW = width ;
445- w .mSurfaceH = height ;
446- }
447-
448- if (w .mSurfaceX != w .mShownFrame .left
449- || w .mSurfaceY != w .mShownFrame .top ) {
450- try {
451- if (WindowManagerService .SHOW_TRANSACTIONS ) WindowManagerService .logSurface (w ,
452- "POS " + w .mShownFrame .left
453- + ", " + w .mShownFrame .top , null );
454- w .mSurfaceX = w .mShownFrame .left ;
455- w .mSurfaceY = w .mShownFrame .top ;
456- w .mSurface .setPosition (w .mShownFrame .left , w .mShownFrame .top );
457- } catch (RuntimeException e ) {
458- Slog .w (TAG , "Error positioning surface of " + w
459- + " pos=(" + w .mShownFrame .left
460- + "," + w .mShownFrame .top + ")" , e );
461- if (!recoveringMemory ) {
462- mService .reclaimSomeSurfaceMemoryLocked (w , "position" , true );
463- }
464- }
465- }
466-
467- if (surfaceResized ) {
468- try {
469- if (WindowManagerService .SHOW_TRANSACTIONS ) WindowManagerService .logSurface (w ,
470- "SIZE " + width + "x" + height , null );
471- w .mSurfaceResized = true ;
472- w .mSurface .setSize (width , height );
473- } catch (RuntimeException e ) {
474- // If something goes wrong with the surface (such
475- // as running out of memory), don't take down the
476- // entire system.
477- Slog .e (TAG , "Error resizing surface of " + w
478- + " size=(" + width + "x" + height + ")" , e );
479- if (!recoveringMemory ) {
480- mService .reclaimSomeSurfaceMemoryLocked (w , "size" , true );
481- }
482- }
483- }
484-
485- if (w .mAttachedHidden || !w .isReadyForDisplay ()) {
486- if (!w .mLastHidden ) {
487- //dump();
488- w .mLastHidden = true ;
489- if (WindowManagerService .SHOW_TRANSACTIONS ) WindowManagerService .logSurface (w ,
490- "HIDE (performLayout)" , null );
491- if (w .mSurface != null ) {
492- w .mSurfaceShown = false ;
493- try {
494- w .mSurface .hide ();
495- } catch (RuntimeException e ) {
496- Slog .w (TAG , "Exception hiding surface in " + w );
497- }
498- }
499- }
500- // If we are waiting for this window to handle an
501- // orientation change, well, it is hidden, so
502- // doesn't really matter. Note that this does
503- // introduce a potential glitch if the window
504- // becomes unhidden before it has drawn for the
505- // new orientation.
506- if (w .mOrientationChanging ) {
507- w .mOrientationChanging = false ;
508- if (WindowManagerService .DEBUG_ORIENTATION ) Slog .v (TAG ,
509- "Orientation change skips hidden " + w );
510- }
511- } else if (w .mLastLayer != w .mAnimLayer
512- || w .mLastAlpha != w .mShownAlpha
513- || w .mLastDsDx != w .mDsDx
514- || w .mLastDtDx != w .mDtDx
515- || w .mLastDsDy != w .mDsDy
516- || w .mLastDtDy != w .mDtDy
517- || w .mLastHScale != w .mHScale
518- || w .mLastVScale != w .mVScale
519- || w .mLastHidden ) {
520- displayed = true ;
521- w .mLastAlpha = w .mShownAlpha ;
522- w .mLastLayer = w .mAnimLayer ;
523- w .mLastDsDx = w .mDsDx ;
524- w .mLastDtDx = w .mDtDx ;
525- w .mLastDsDy = w .mDsDy ;
526- w .mLastDtDy = w .mDtDy ;
527- w .mLastHScale = w .mHScale ;
528- w .mLastVScale = w .mVScale ;
529- if (WindowManagerService .SHOW_TRANSACTIONS ) WindowManagerService .logSurface (w ,
530- "alpha=" + w .mShownAlpha + " layer=" + w .mAnimLayer
531- + " matrix=[" + (w .mDsDx *w .mHScale )
532- + "," + (w .mDtDx *w .mVScale )
533- + "][" + (w .mDsDy *w .mHScale )
534- + "," + (w .mDtDy *w .mVScale ) + "]" , null );
535- if (w .mSurface != null ) {
536- try {
537- w .mSurfaceAlpha = w .mShownAlpha ;
538- w .mSurface .setAlpha (w .mShownAlpha );
539- w .mSurfaceLayer = w .mAnimLayer ;
540- w .mSurface .setLayer (w .mAnimLayer );
541- w .mSurface .setMatrix (
542- w .mDsDx *w .mHScale , w .mDtDx *w .mVScale ,
543- w .mDsDy *w .mHScale , w .mDtDy *w .mVScale );
544- } catch (RuntimeException e ) {
545- Slog .w (TAG , "Error updating surface in " + w , e );
546- if (!recoveringMemory ) {
547- mService .reclaimSomeSurfaceMemoryLocked (w , "update" , true );
548- }
549- }
550- }
551-
552- if (w .mLastHidden && w .isDrawnLw ()
553- && !w .mReadyToShow ) {
554- if (WindowManagerService .SHOW_TRANSACTIONS ) WindowManagerService .logSurface (w ,
555- "SHOW (performLayout)" , null );
556- if (WindowManagerService .DEBUG_VISIBILITY ) Slog .v (TAG , "Showing " + w
557- + " during relayout" );
558- if (mService .showSurfaceRobustlyLocked (w )) {
559- w .mHasDrawn = true ;
560- w .mLastHidden = false ;
561- } else {
562- w .mOrientationChanging = false ;
563- }
564- }
565- if (w .mSurface != null ) {
566- w .mToken .hasVisible = true ;
567- }
568- } else {
569- displayed = true ;
570- }
571-
572- if (displayed ) {
573- if (w .mOrientationChanging ) {
574- if (!w .isDrawnLw ()) {
575- mService .mInnerFields .mOrientationChangeComplete = false ;
576- if (WindowManagerService .DEBUG_ORIENTATION ) Slog .v (TAG ,
577- "Orientation continue waiting for draw in " + w );
578- } else {
579- w .mOrientationChanging = false ;
580- if (WindowManagerService .DEBUG_ORIENTATION ) Slog .v (TAG ,
581- "Orientation change complete in " + w );
582- }
583- }
584- w .mToken .hasVisible = true ;
585- }
586- }
587402
588403 void animate () {
589404 mPendingLayoutChanges = 0 ;
@@ -608,7 +423,7 @@ void animate() {
608423 final int N = mService .mWindows .size ();
609424 for (int i =N -1 ; i >=0 ; i --) {
610425 WindowState w = mService .mWindows .get (i );
611- prepareSurfaceLocked (w , true );
426+ w . mWinAnimator . prepareSurfaceLocked (true );
612427 }
613428
614429 if (mService .mDimAnimator != null && mService .mDimAnimator .mDimShown ) {
@@ -629,7 +444,7 @@ void animate() {
629444 } finally {
630445 Surface .closeTransaction ();
631446 }
632-
447+
633448 if (mWallpaperMayChange ) {
634449 mService .notifyWallpaperMayChange ();
635450 }
0 commit comments