Merge "Don't destroy a window's buffers when moving it"

This commit is contained in:
Romain Guy
2011-09-06 17:02:43 -07:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 13 deletions

View File

@@ -215,6 +215,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
boolean mLastWasImTarget; boolean mLastWasImTarget;
boolean mWindowAttributesChanged = false; boolean mWindowAttributesChanged = false;
int mWindowAttributesChangesFlag = 0;
// These can be accessed by any thread, must be protected with a lock. // These can be accessed by any thread, must be protected with a lock.
// Surface can never be reassigned or cleared (use Surface.clear()). // Surface can never be reassigned or cleared (use Surface.clear()).
@@ -439,6 +440,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
mSoftInputMode = attrs.softInputMode; mSoftInputMode = attrs.softInputMode;
mWindowAttributesChanged = true; mWindowAttributesChanged = true;
mWindowAttributesChangesFlag = WindowManager.LayoutParams.EVERYTHING_CHANGED;
mAttachInfo.mRootView = view; mAttachInfo.mRootView = view;
mAttachInfo.mScalingRequired = mTranslator != null; mAttachInfo.mScalingRequired = mTranslator != null;
mAttachInfo.mApplicationScale = mAttachInfo.mApplicationScale =
@@ -640,7 +642,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
// preserve compatible window flag if exists. // preserve compatible window flag if exists.
int compatibleWindowFlag = int compatibleWindowFlag =
mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW; mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
mWindowAttributes.copyFrom(attrs); mWindowAttributesChangesFlag = mWindowAttributes.copyFrom(attrs);
mWindowAttributes.flags |= compatibleWindowFlag; mWindowAttributes.flags |= compatibleWindowFlag;
if (newView) { if (newView) {
@@ -844,14 +846,17 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|| mNewSurfaceNeeded; || mNewSurfaceNeeded;
WindowManager.LayoutParams params = null; WindowManager.LayoutParams params = null;
int windowAttributesChanges = 0;
if (mWindowAttributesChanged) { if (mWindowAttributesChanged) {
mWindowAttributesChanged = false; mWindowAttributesChanged = false;
surfaceChanged = true; surfaceChanged = true;
params = lp; params = lp;
windowAttributesChanges = mWindowAttributesChangesFlag;
} }
CompatibilityInfo compatibilityInfo = mCompatibilityInfo.get(); CompatibilityInfo compatibilityInfo = mCompatibilityInfo.get();
if (compatibilityInfo.supportsScreen() == mLastInCompatMode) { if (compatibilityInfo.supportsScreen() == mLastInCompatMode) {
params = lp; params = lp;
windowAttributesChanges |= WindowManager.LayoutParams.BUFFER_CHANGED;
fullRedrawNeeded = true; fullRedrawNeeded = true;
mLayoutRequested = true; mLayoutRequested = true;
if (mLastInCompatMode) { if (mLastInCompatMode) {
@@ -862,6 +867,9 @@ public final class ViewRootImpl extends Handler implements ViewParent,
mLastInCompatMode = true; mLastInCompatMode = true;
} }
} }
mWindowAttributesChangesFlag = 0;
Rect frame = mWinFrame; Rect frame = mWinFrame;
if (mFirst) { if (mFirst) {
fullRedrawNeeded = true; fullRedrawNeeded = true;
@@ -1041,6 +1049,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|| attachInfo.mSystemUiVisibility != oldVis || attachInfo.mSystemUiVisibility != oldVis
|| attachInfo.mHasSystemUiListeners) { || attachInfo.mHasSystemUiListeners) {
params = lp; params = lp;
windowAttributesChanges |= WindowManager.LayoutParams.BUFFER_CHANGED;
} }
} }
@@ -1066,6 +1075,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
~WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST) | ~WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST) |
resizeMode; resizeMode;
params = lp; params = lp;
windowAttributesChanges |= WindowManager.LayoutParams.BUFFER_CHANGED;
} }
} }
} }
@@ -1362,7 +1372,8 @@ public final class ViewRootImpl extends Handler implements ViewParent,
} }
} }
if (hwInitialized || ((windowShouldResize || params != null) && if (hwInitialized || ((windowShouldResize || (params != null &&
(windowAttributesChanges & WindowManager.LayoutParams.BUFFER_CHANGED) != 0)) &&
mAttachInfo.mHardwareRenderer != null && mAttachInfo.mHardwareRenderer != null &&
mAttachInfo.mHardwareRenderer.isEnabled())) { mAttachInfo.mHardwareRenderer.isEnabled())) {
mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight); mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight);
@@ -1637,6 +1648,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
// Need to make sure we re-evaluate the window attributes next // Need to make sure we re-evaluate the window attributes next
// time around, to ensure the window has the correct format. // time around, to ensure the window has the correct format.
mWindowAttributesChanged = true; mWindowAttributesChanged = true;
mWindowAttributesChangesFlag = 0;
requestLayout(); requestLayout();
} }
} }

View File

@@ -1252,7 +1252,11 @@ public interface WindowManager extends ViewManager {
public static final int INPUT_FEATURES_CHANGED = 1<<15; public static final int INPUT_FEATURES_CHANGED = 1<<15;
/** {@hide} */ /** {@hide} */
public static final int PRIVATE_FLAGS_CHANGED = 1<<16; public static final int PRIVATE_FLAGS_CHANGED = 1<<16;
/** {@hide} */
public static final int BUFFER_CHANGED = 1<<17;
/** {@hide} */
public static final int EVERYTHING_CHANGED = 0xffffffff;
// internal buffer to backup/restore parameters under compatibility mode. // internal buffer to backup/restore parameters under compatibility mode.
private int[] mCompatibilityParamsBackup = null; private int[] mCompatibilityParamsBackup = null;
@@ -1261,11 +1265,11 @@ public interface WindowManager extends ViewManager {
if (width != o.width) { if (width != o.width) {
width = o.width; width = o.width;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
} }
if (height != o.height) { if (height != o.height) {
height = o.height; height = o.height;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
} }
if (x != o.x) { if (x != o.x) {
x = o.x; x = o.x;
@@ -1277,19 +1281,19 @@ public interface WindowManager extends ViewManager {
} }
if (horizontalWeight != o.horizontalWeight) { if (horizontalWeight != o.horizontalWeight) {
horizontalWeight = o.horizontalWeight; horizontalWeight = o.horizontalWeight;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
} }
if (verticalWeight != o.verticalWeight) { if (verticalWeight != o.verticalWeight) {
verticalWeight = o.verticalWeight; verticalWeight = o.verticalWeight;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
} }
if (horizontalMargin != o.horizontalMargin) { if (horizontalMargin != o.horizontalMargin) {
horizontalMargin = o.horizontalMargin; horizontalMargin = o.horizontalMargin;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
} }
if (verticalMargin != o.verticalMargin) { if (verticalMargin != o.verticalMargin) {
verticalMargin = o.verticalMargin; verticalMargin = o.verticalMargin;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
} }
if (type != o.type) { if (type != o.type) {
type = o.type; type = o.type;
@@ -1297,7 +1301,7 @@ public interface WindowManager extends ViewManager {
} }
if (flags != o.flags) { if (flags != o.flags) {
flags = o.flags; flags = o.flags;
changes |= FLAGS_CHANGED; changes |= FLAGS_CHANGED | BUFFER_CHANGED;
} }
if (privateFlags != o.privateFlags) { if (privateFlags != o.privateFlags) {
privateFlags = o.privateFlags; privateFlags = o.privateFlags;
@@ -1309,11 +1313,11 @@ public interface WindowManager extends ViewManager {
} }
if (gravity != o.gravity) { if (gravity != o.gravity) {
gravity = o.gravity; gravity = o.gravity;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
} }
if (format != o.format) { if (format != o.format) {
format = o.format; format = o.format;
changes |= FORMAT_CHANGED; changes |= FORMAT_CHANGED | BUFFER_CHANGED;
} }
if (windowAnimations != o.windowAnimations) { if (windowAnimations != o.windowAnimations) {
windowAnimations = o.windowAnimations; windowAnimations = o.windowAnimations;
@@ -1352,7 +1356,7 @@ public interface WindowManager extends ViewManager {
if (screenOrientation != o.screenOrientation) { if (screenOrientation != o.screenOrientation) {
screenOrientation = o.screenOrientation; screenOrientation = o.screenOrientation;
changes |= SCREEN_ORIENTATION_CHANGED; changes |= SCREEN_ORIENTATION_CHANGED | BUFFER_CHANGED;
} }
if (systemUiVisibility != o.systemUiVisibility if (systemUiVisibility != o.systemUiVisibility