Skip to content

Commit d51a68b

Browse files
Craig MautnerAndroid (Google) Code Review
authored andcommitted
Merge "Eliminate deferred surface destruction." into jb-dev
2 parents 9cb376e + bf08af3 commit d51a68b

File tree

5 files changed

+17
-59
lines changed

5 files changed

+17
-59
lines changed

core/java/android/view/WindowManager.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -691,13 +691,6 @@ public static class LayoutParams extends ViewGroup.LayoutParams
691691
*/
692692
public static final int FLAG_NEEDS_MENU_KEY = 0x08000000;
693693

694-
/** Window flag: *sigh* The lock screen wants to continue running its
695-
* animation while it is fading. A kind-of hack to allow this. Maybe
696-
* in the future we just make this the default behavior.
697-
*
698-
* {@hide} */
699-
public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000;
700-
701694
/** Window flag: special flag to limit the size of the window to be
702695
* original size ([320x480] x density). Used to create window for applications
703696
* running under compatibility mode.

policy/src/com/android/internal/policy/impl/KeyguardViewManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ public synchronized void show() {
117117
final int stretch = ViewGroup.LayoutParams.MATCH_PARENT;
118118
int flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
119119
| WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
120-
| WindowManager.LayoutParams.FLAG_KEEP_SURFACE_WHILE_ANIMATING
121120
| WindowManager.LayoutParams.FLAG_SLIPPERY
122121
/*| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
123122
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR*/ ;

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,7 @@ static boolean canBeImeTarget(WindowState w) {
11731173
if (DEBUG_INPUT_METHOD) {
11741174
Slog.i(TAG, "isVisibleOrAdding " + w + ": " + w.isVisibleOrAdding());
11751175
if (!w.isVisibleOrAdding()) {
1176-
Slog.i(TAG, " mSurface=" + w.mWinAnimator.mSurface + " reportDestroy="
1177-
+ w.mWinAnimator.mReportDestroySurface
1176+
Slog.i(TAG, " mSurface=" + w.mWinAnimator.mSurface
11781177
+ " relayoutCalled=" + w.mRelayoutCalled + " viewVis=" + w.mViewVisibility
11791178
+ " policyVis=" + w.mPolicyVisibility + " attachHid=" + w.mAttachedHidden
11801179
+ " exiting=" + w.mExiting + " destroying=" + w.mDestroying);
@@ -2651,7 +2650,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
26512650
int requestedHeight, int viewVisibility, int flags,
26522651
Rect outFrame, Rect outContentInsets,
26532652
Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {
2654-
boolean displayed = false;
2653+
boolean toBeDisplayed = false;
26552654
boolean inTouchMode;
26562655
boolean configChanged;
26572656
boolean surfaceChanged = false;
@@ -2754,7 +2753,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
27542753
}
27552754
if (viewVisibility == View.VISIBLE &&
27562755
(win.mAppToken == null || !win.mAppToken.clientHidden)) {
2757-
displayed = !win.isVisibleLw();
2756+
toBeDisplayed = !win.isVisibleLw();
27582757
if (win.mExiting) {
27592758
winAnimator.cancelExitAnimationForNextAnimationLocked();
27602759
win.mExiting = false;
@@ -2766,7 +2765,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
27662765
if (oldVisibility == View.GONE) {
27672766
winAnimator.mEnterAnimationPending = true;
27682767
}
2769-
if (displayed) {
2768+
if (toBeDisplayed) {
27702769
if (win.isDrawnLw() && okToDisplay()) {
27712770
winAnimator.applyEnterAnimationLocked();
27722771
}
@@ -2792,7 +2791,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
27922791
if ((attrChanges&WindowManager.LayoutParams.FORMAT_CHANGED) != 0) {
27932792
// To change the format, we need to re-build the surface.
27942793
winAnimator.destroySurfaceLocked();
2795-
displayed = true;
2794+
toBeDisplayed = true;
27962795
surfaceChanged = true;
27972796
}
27982797
try {
@@ -2802,8 +2801,6 @@ public int relayoutWindow(Session session, IWindow client, int seq,
28022801
Surface surface = winAnimator.createSurfaceLocked();
28032802
if (surface != null) {
28042803
outSurface.copyFrom(surface);
2805-
winAnimator.mReportDestroySurface = false;
2806-
winAnimator.mSurfacePendingDestroy = false;
28072804
if (SHOW_TRANSACTIONS) Slog.i(TAG,
28082805
" OUT SURFACE " + outSurface + ": copied");
28092806
} else {
@@ -2820,7 +2817,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
28202817
Binder.restoreCallingIdentity(origId);
28212818
return 0;
28222819
}
2823-
if (displayed) {
2820+
if (toBeDisplayed) {
28242821
focusMayChange = true;
28252822
}
28262823
if (win.mAttrs.type == TYPE_INPUT_METHOD
@@ -2845,19 +2842,18 @@ public int relayoutWindow(Session session, IWindow client, int seq,
28452842
winAnimator.mEnterAnimationPending = false;
28462843
if (winAnimator.mSurface != null) {
28472844
if (DEBUG_VISIBILITY) Slog.i(TAG, "Relayout invis " + win
2848-
+ ": mExiting=" + win.mExiting
2849-
+ " mSurfacePendingDestroy=" + winAnimator.mSurfacePendingDestroy);
2845+
+ ": mExiting=" + win.mExiting);
28502846
// If we are not currently running the exit animation, we
28512847
// need to see about starting one.
2852-
if (!win.mExiting || winAnimator.mSurfacePendingDestroy) {
2848+
if (!win.mExiting) {
28532849
surfaceChanged = true;
28542850
// Try starting an animation; if there isn't one, we
28552851
// can destroy the surface right away.
28562852
int transit = WindowManagerPolicy.TRANSIT_EXIT;
28572853
if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
28582854
transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
28592855
}
2860-
if (!winAnimator.mSurfacePendingDestroy && win.isWinVisibleLw() &&
2856+
if (win.isWinVisibleLw() &&
28612857
winAnimator.applyAnimationLocked(transit, false)) {
28622858
focusMayChange = true;
28632859
win.mExiting = true;
@@ -2880,22 +2876,8 @@ public int relayoutWindow(Session session, IWindow client, int seq,
28802876
}
28812877
}
28822878

2883-
if (winAnimator.mSurface == null || (win.getAttrs().flags
2884-
& WindowManager.LayoutParams.FLAG_KEEP_SURFACE_WHILE_ANIMATING) == 0
2885-
|| winAnimator.mSurfacePendingDestroy) {
2886-
// We could be called from a local process, which
2887-
// means outSurface holds its current surface. Ensure the
2888-
// surface object is cleared, but we don't necessarily want
2889-
// it actually destroyed at this point.
2890-
winAnimator.mSurfacePendingDestroy = false;
2891-
outSurface.release();
2892-
if (DEBUG_VISIBILITY) Slog.i(TAG, "Releasing surface in: " + win);
2893-
} else if (winAnimator.mSurface != null) {
2894-
if (DEBUG_VISIBILITY) Slog.i(TAG,
2895-
"Keeping surface, will report destroy: " + win);
2896-
winAnimator.mReportDestroySurface = true;
2897-
outSurface.copyFrom(winAnimator.mSurface);
2898-
}
2879+
outSurface.release();
2880+
if (DEBUG_VISIBILITY) Slog.i(TAG, "Releasing surface in: " + win);
28992881
}
29002882

29012883
if (focusMayChange) {
@@ -2912,7 +2894,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
29122894
boolean assignLayers = false;
29132895

29142896
if (imMayMove) {
2915-
if (moveInputMethodWindowsIfNeededLocked(false) || displayed) {
2897+
if (moveInputMethodWindowsIfNeededLocked(false) || toBeDisplayed) {
29162898
// Little hack here -- we -should- be able to rely on the
29172899
// function to return true if the IME has moved and needs
29182900
// its layer recomputed. However, if the IME was hidden
@@ -2934,7 +2916,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
29342916
}
29352917
configChanged = updateOrientationFromAppTokensLocked(false);
29362918
performLayoutAndPlaceSurfacesLocked();
2937-
if (displayed && win.mIsWallpaper) {
2919+
if (toBeDisplayed && win.mIsWallpaper) {
29382920
updateWallpaperOffsetLocked(win, mAppDisplayWidth, mAppDisplayHeight, false);
29392921
}
29402922
if (win.mAppToken != null) {
@@ -2970,7 +2952,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
29702952
Binder.restoreCallingIdentity(origId);
29712953

29722954
return (inTouchMode ? WindowManagerImpl.RELAYOUT_RES_IN_TOUCH_MODE : 0)
2973-
| (displayed ? WindowManagerImpl.RELAYOUT_RES_FIRST_TIME : 0)
2955+
| (toBeDisplayed ? WindowManagerImpl.RELAYOUT_RES_FIRST_TIME : 0)
29742956
| (surfaceChanged ? WindowManagerImpl.RELAYOUT_RES_SURFACE_CHANGED : 0)
29752957
| (animating ? WindowManagerImpl.RELAYOUT_RES_ANIMATING : 0);
29762958
}

services/java/com/android/server/wm/WindowState.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,7 @@ boolean isPotentialDragTarget() {
679679
*/
680680
boolean isVisibleOrAdding() {
681681
final AppWindowToken atoken = mAppToken;
682-
return ((mHasSurface && !mWinAnimator.mReportDestroySurface)
683-
|| (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
682+
return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
684683
&& mPolicyVisibility && !mAttachedHidden
685684
&& (atoken == null || !atoken.hiddenRequested)
686685
&& !mExiting && !mDestroying;

services/java/com/android/server/wm/WindowStateAnimator.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class WindowStateAnimator {
7171

7272
Surface mSurface;
7373
Surface mPendingDestroySurface;
74-
boolean mReportDestroySurface;
75-
boolean mSurfacePendingDestroy;
7674

7775
/**
7876
* Set when we have changed the size of the surface, to know that
@@ -561,8 +559,6 @@ public String toString() {
561559

562560
Surface createSurfaceLocked() {
563561
if (mSurface == null) {
564-
mReportDestroySurface = false;
565-
mSurfacePendingDestroy = false;
566562
if (DEBUG_ANIM || DEBUG_ORIENTATION) Slog.i(TAG,
567563
"createSurface " + this + ": mDrawState=DRAW_PENDING");
568564
mDrawState = DRAW_PENDING;
@@ -694,7 +690,6 @@ void destroySurfaceLocked() {
694690
mWin.mAppToken.startingDisplayed = false;
695691
}
696692

697-
mDrawState = NO_SURFACE;
698693
if (mSurface != null) {
699694

700695
int i = mWin.mChildWindows.size();
@@ -704,17 +699,6 @@ void destroySurfaceLocked() {
704699
c.mAttachedHidden = true;
705700
}
706701

707-
if (mReportDestroySurface) {
708-
mReportDestroySurface = false;
709-
mSurfacePendingDestroy = true;
710-
try {
711-
mWin.mClient.dispatchGetNewSurface();
712-
// We'll really destroy on the next time around.
713-
return;
714-
} catch (RemoteException e) {
715-
}
716-
}
717-
718702
try {
719703
if (DEBUG_VISIBILITY) {
720704
RuntimeException e = null;
@@ -760,6 +744,7 @@ void destroySurfaceLocked() {
760744
mSurfaceShown = false;
761745
mSurface = null;
762746
mWin.mHasSurface =false;
747+
mDrawState = NO_SURFACE;
763748
}
764749
}
765750

@@ -1147,7 +1132,7 @@ public void prepareSurfaceLocked(final boolean recoveringMemory) {
11471132
}
11481133
} else {
11491134
if (DEBUG_ANIM) {
1150-
Slog.v(TAG, "prepareSurface: No changes in animation for " + mWin);
1135+
// Slog.v(TAG, "prepareSurface: No changes in animation for " + mWin);
11511136
}
11521137
displayed = true;
11531138
}

0 commit comments

Comments
 (0)