Skip to content

Commit 2b72d93

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Don't destroy a window's buffers when moving it"
2 parents 535e8f3 + f21c9b0 commit 2b72d93

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
215215
boolean mLastWasImTarget;
216216

217217
boolean mWindowAttributesChanged = false;
218+
int mWindowAttributesChangesFlag = 0;
218219

219220
// These can be accessed by any thread, must be protected with a lock.
220221
// Surface can never be reassigned or cleared (use Surface.clear()).
@@ -439,6 +440,7 @@ public void setView(View view, WindowManager.LayoutParams attrs, View panelParen
439440

440441
mSoftInputMode = attrs.softInputMode;
441442
mWindowAttributesChanged = true;
443+
mWindowAttributesChangesFlag = WindowManager.LayoutParams.EVERYTHING_CHANGED;
442444
mAttachInfo.mRootView = view;
443445
mAttachInfo.mScalingRequired = mTranslator != null;
444446
mAttachInfo.mApplicationScale =
@@ -640,7 +642,7 @@ void setLayoutParams(WindowManager.LayoutParams attrs, boolean newView) {
640642
// preserve compatible window flag if exists.
641643
int compatibleWindowFlag =
642644
mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
643-
mWindowAttributes.copyFrom(attrs);
645+
mWindowAttributesChangesFlag = mWindowAttributes.copyFrom(attrs);
644646
mWindowAttributes.flags |= compatibleWindowFlag;
645647

646648
if (newView) {
@@ -844,14 +846,17 @@ private void performTraversals() {
844846
|| mNewSurfaceNeeded;
845847

846848
WindowManager.LayoutParams params = null;
849+
int windowAttributesChanges = 0;
847850
if (mWindowAttributesChanged) {
848851
mWindowAttributesChanged = false;
849852
surfaceChanged = true;
850853
params = lp;
854+
windowAttributesChanges = mWindowAttributesChangesFlag;
851855
}
852856
CompatibilityInfo compatibilityInfo = mCompatibilityInfo.get();
853857
if (compatibilityInfo.supportsScreen() == mLastInCompatMode) {
854858
params = lp;
859+
windowAttributesChanges |= WindowManager.LayoutParams.BUFFER_CHANGED;
855860
fullRedrawNeeded = true;
856861
mLayoutRequested = true;
857862
if (mLastInCompatMode) {
@@ -862,6 +867,9 @@ private void performTraversals() {
862867
mLastInCompatMode = true;
863868
}
864869
}
870+
871+
mWindowAttributesChangesFlag = 0;
872+
865873
Rect frame = mWinFrame;
866874
if (mFirst) {
867875
fullRedrawNeeded = true;
@@ -1041,6 +1049,7 @@ private void performTraversals() {
10411049
|| attachInfo.mSystemUiVisibility != oldVis
10421050
|| attachInfo.mHasSystemUiListeners) {
10431051
params = lp;
1052+
windowAttributesChanges |= WindowManager.LayoutParams.BUFFER_CHANGED;
10441053
}
10451054
}
10461055

@@ -1066,6 +1075,7 @@ private void performTraversals() {
10661075
~WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST) |
10671076
resizeMode;
10681077
params = lp;
1078+
windowAttributesChanges |= WindowManager.LayoutParams.BUFFER_CHANGED;
10691079
}
10701080
}
10711081
}
@@ -1362,7 +1372,8 @@ private void performTraversals() {
13621372
}
13631373
}
13641374

1365-
if (hwInitialized || ((windowShouldResize || params != null) &&
1375+
if (hwInitialized || ((windowShouldResize || (params != null &&
1376+
(windowAttributesChanges & WindowManager.LayoutParams.BUFFER_CHANGED) != 0)) &&
13661377
mAttachInfo.mHardwareRenderer != null &&
13671378
mAttachInfo.mHardwareRenderer.isEnabled())) {
13681379
mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight);
@@ -1637,6 +1648,7 @@ public void requestTransparentRegion(View child) {
16371648
// Need to make sure we re-evaluate the window attributes next
16381649
// time around, to ensure the window has the correct format.
16391650
mWindowAttributesChanged = true;
1651+
mWindowAttributesChangesFlag = 0;
16401652
requestLayout();
16411653
}
16421654
}

core/java/android/view/WindowManager.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,11 @@ public LayoutParams(Parcel in) {
12521252
public static final int INPUT_FEATURES_CHANGED = 1<<15;
12531253
/** {@hide} */
12541254
public static final int PRIVATE_FLAGS_CHANGED = 1<<16;
1255-
1255+
/** {@hide} */
1256+
public static final int BUFFER_CHANGED = 1<<17;
1257+
/** {@hide} */
1258+
public static final int EVERYTHING_CHANGED = 0xffffffff;
1259+
12561260
// internal buffer to backup/restore parameters under compatibility mode.
12571261
private int[] mCompatibilityParamsBackup = null;
12581262

@@ -1261,11 +1265,11 @@ public final int copyFrom(LayoutParams o) {
12611265

12621266
if (width != o.width) {
12631267
width = o.width;
1264-
changes |= LAYOUT_CHANGED;
1268+
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
12651269
}
12661270
if (height != o.height) {
12671271
height = o.height;
1268-
changes |= LAYOUT_CHANGED;
1272+
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
12691273
}
12701274
if (x != o.x) {
12711275
x = o.x;
@@ -1277,27 +1281,27 @@ public final int copyFrom(LayoutParams o) {
12771281
}
12781282
if (horizontalWeight != o.horizontalWeight) {
12791283
horizontalWeight = o.horizontalWeight;
1280-
changes |= LAYOUT_CHANGED;
1284+
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
12811285
}
12821286
if (verticalWeight != o.verticalWeight) {
12831287
verticalWeight = o.verticalWeight;
1284-
changes |= LAYOUT_CHANGED;
1288+
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
12851289
}
12861290
if (horizontalMargin != o.horizontalMargin) {
12871291
horizontalMargin = o.horizontalMargin;
1288-
changes |= LAYOUT_CHANGED;
1292+
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
12891293
}
12901294
if (verticalMargin != o.verticalMargin) {
12911295
verticalMargin = o.verticalMargin;
1292-
changes |= LAYOUT_CHANGED;
1296+
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
12931297
}
12941298
if (type != o.type) {
12951299
type = o.type;
12961300
changes |= TYPE_CHANGED;
12971301
}
12981302
if (flags != o.flags) {
12991303
flags = o.flags;
1300-
changes |= FLAGS_CHANGED;
1304+
changes |= FLAGS_CHANGED | BUFFER_CHANGED;
13011305
}
13021306
if (privateFlags != o.privateFlags) {
13031307
privateFlags = o.privateFlags;
@@ -1309,11 +1313,11 @@ public final int copyFrom(LayoutParams o) {
13091313
}
13101314
if (gravity != o.gravity) {
13111315
gravity = o.gravity;
1312-
changes |= LAYOUT_CHANGED;
1316+
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
13131317
}
13141318
if (format != o.format) {
13151319
format = o.format;
1316-
changes |= FORMAT_CHANGED;
1320+
changes |= FORMAT_CHANGED | BUFFER_CHANGED;
13171321
}
13181322
if (windowAnimations != o.windowAnimations) {
13191323
windowAnimations = o.windowAnimations;
@@ -1352,7 +1356,7 @@ public final int copyFrom(LayoutParams o) {
13521356

13531357
if (screenOrientation != o.screenOrientation) {
13541358
screenOrientation = o.screenOrientation;
1355-
changes |= SCREEN_ORIENTATION_CHANGED;
1359+
changes |= SCREEN_ORIENTATION_CHANGED | BUFFER_CHANGED;
13561360
}
13571361

13581362
if (systemUiVisibility != o.systemUiVisibility

0 commit comments

Comments
 (0)