Fix issue #5384631: hw windows not resizing correctly
When the SystemUi becomes visible, the activity window resizes. The hardware renderer was not begin resized to suit, so it was drawing to a surface larger than that of the activity window, and some of the rendering (like the action bar) appeared off the screen. The fix is to keep track of the surface size in HardwareRenderer and to recreate the surface when the size changes. This change also removes the BUFFER_CHANGE flag from WindowManager.LayoutParams. The only reason the flag existed was to trigger a hardware surface recreation, but checking the old/new size is a more direct way of handling this. Change-Id: I9d6bf6385794886d1d93c60609c170864cdcdfab
This commit is contained in:
@@ -183,6 +183,22 @@ public abstract class HardwareRenderer {
|
||||
*/
|
||||
abstract void setup(int width, int height);
|
||||
|
||||
/**
|
||||
* Gets the current width of the surface. This is the width that the surface
|
||||
* was last set to in a call to {@link #setup(int, int)}.
|
||||
*
|
||||
* @return the current width of the surface
|
||||
*/
|
||||
abstract int getWidth();
|
||||
|
||||
/**
|
||||
* Gets the current height of the surface. This is the height that the surface
|
||||
* was last set to in a call to {@link #setup(int, int)}.
|
||||
*
|
||||
* @return the current width of the surface
|
||||
*/
|
||||
abstract int getHeight();
|
||||
|
||||
/**
|
||||
* Interface used to receive callbacks whenever a view is drawn by
|
||||
* a hardware renderer instance.
|
||||
@@ -362,6 +378,7 @@ public abstract class HardwareRenderer {
|
||||
static EGLDisplay sEglDisplay;
|
||||
static EGLConfig sEglConfig;
|
||||
static final Object[] sEglLock = new Object[0];
|
||||
int mWidth = -1, mHeight = -1;
|
||||
|
||||
static final ThreadLocal<EGLContext> sEglContextStorage = new ThreadLocal<EGLContext>();
|
||||
|
||||
@@ -714,9 +731,21 @@ public abstract class HardwareRenderer {
|
||||
void setup(int width, int height) {
|
||||
if (validate()) {
|
||||
mCanvas.setViewport(width, height);
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
int getWidth() {
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getHeight() {
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
boolean canDraw() {
|
||||
return mGl != null && mCanvas != null;
|
||||
}
|
||||
|
||||
@@ -860,7 +860,6 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
||||
CompatibilityInfo compatibilityInfo = mCompatibilityInfo.get();
|
||||
if (compatibilityInfo.supportsScreen() == mLastInCompatMode) {
|
||||
params = lp;
|
||||
windowAttributesChanges |= WindowManager.LayoutParams.BUFFER_CHANGED;
|
||||
fullRedrawNeeded = true;
|
||||
mLayoutRequested = true;
|
||||
if (mLastInCompatMode) {
|
||||
@@ -1078,7 +1077,6 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
||||
~WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST) |
|
||||
resizeMode;
|
||||
params = lp;
|
||||
windowAttributesChanges |= WindowManager.LayoutParams.BUFFER_CHANGED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1375,13 +1373,15 @@ public final class ViewRootImpl extends Handler implements ViewParent,
|
||||
}
|
||||
}
|
||||
|
||||
if (hwInitialized || ((windowShouldResize || (params != null &&
|
||||
(windowAttributesChanges & WindowManager.LayoutParams.BUFFER_CHANGED) != 0)) &&
|
||||
mAttachInfo.mHardwareRenderer != null &&
|
||||
mAttachInfo.mHardwareRenderer.isEnabled())) {
|
||||
mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight);
|
||||
if (!hwInitialized && mAttachInfo.mHardwareRenderer.isEnabled()) {
|
||||
mAttachInfo.mHardwareRenderer.invalidate(mHolder);
|
||||
if (mAttachInfo.mHardwareRenderer != null &&
|
||||
mAttachInfo.mHardwareRenderer.isEnabled()) {
|
||||
if (hwInitialized || windowShouldResize ||
|
||||
mWidth != mAttachInfo.mHardwareRenderer.getWidth() ||
|
||||
mHeight != mAttachInfo.mHardwareRenderer.getHeight()) {
|
||||
mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight);
|
||||
if (!hwInitialized) {
|
||||
mAttachInfo.mHardwareRenderer.invalidate(mHolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1260,8 +1260,6 @@ public interface WindowManager extends ViewManager {
|
||||
/** {@hide} */
|
||||
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.
|
||||
@@ -1272,11 +1270,11 @@ public interface WindowManager extends ViewManager {
|
||||
|
||||
if (width != o.width) {
|
||||
width = o.width;
|
||||
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
|
||||
changes |= LAYOUT_CHANGED;
|
||||
}
|
||||
if (height != o.height) {
|
||||
height = o.height;
|
||||
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
|
||||
changes |= LAYOUT_CHANGED;
|
||||
}
|
||||
if (x != o.x) {
|
||||
x = o.x;
|
||||
@@ -1288,19 +1286,19 @@ public interface WindowManager extends ViewManager {
|
||||
}
|
||||
if (horizontalWeight != o.horizontalWeight) {
|
||||
horizontalWeight = o.horizontalWeight;
|
||||
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
|
||||
changes |= LAYOUT_CHANGED;
|
||||
}
|
||||
if (verticalWeight != o.verticalWeight) {
|
||||
verticalWeight = o.verticalWeight;
|
||||
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
|
||||
changes |= LAYOUT_CHANGED;
|
||||
}
|
||||
if (horizontalMargin != o.horizontalMargin) {
|
||||
horizontalMargin = o.horizontalMargin;
|
||||
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
|
||||
changes |= LAYOUT_CHANGED;
|
||||
}
|
||||
if (verticalMargin != o.verticalMargin) {
|
||||
verticalMargin = o.verticalMargin;
|
||||
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
|
||||
changes |= LAYOUT_CHANGED;
|
||||
}
|
||||
if (type != o.type) {
|
||||
type = o.type;
|
||||
@@ -1308,7 +1306,7 @@ public interface WindowManager extends ViewManager {
|
||||
}
|
||||
if (flags != o.flags) {
|
||||
flags = o.flags;
|
||||
changes |= FLAGS_CHANGED | BUFFER_CHANGED;
|
||||
changes |= FLAGS_CHANGED;
|
||||
}
|
||||
if (privateFlags != o.privateFlags) {
|
||||
privateFlags = o.privateFlags;
|
||||
@@ -1320,11 +1318,11 @@ public interface WindowManager extends ViewManager {
|
||||
}
|
||||
if (gravity != o.gravity) {
|
||||
gravity = o.gravity;
|
||||
changes |= LAYOUT_CHANGED | BUFFER_CHANGED;
|
||||
changes |= LAYOUT_CHANGED;
|
||||
}
|
||||
if (format != o.format) {
|
||||
format = o.format;
|
||||
changes |= FORMAT_CHANGED | BUFFER_CHANGED;
|
||||
changes |= FORMAT_CHANGED;
|
||||
}
|
||||
if (windowAnimations != o.windowAnimations) {
|
||||
windowAnimations = o.windowAnimations;
|
||||
@@ -1363,7 +1361,7 @@ public interface WindowManager extends ViewManager {
|
||||
|
||||
if (screenOrientation != o.screenOrientation) {
|
||||
screenOrientation = o.screenOrientation;
|
||||
changes |= SCREEN_ORIENTATION_CHANGED | BUFFER_CHANGED;
|
||||
changes |= SCREEN_ORIENTATION_CHANGED;
|
||||
}
|
||||
|
||||
if (systemUiVisibility != o.systemUiVisibility
|
||||
|
||||
Reference in New Issue
Block a user