Fix display List bugs
Various property setters in View need to invalidate the parent's
cache to get redrawn properly when accelerated with display lists.
Also, fix logic around display lists and old-style Animations in
ViewGroup.
Change-Id: I70e1c2fa49e62228ee4a1301a006ce50bda4c305
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 2e6664b..e2c346f 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2937,13 +2937,6 @@
}
/**
- * Gets the current list of listeners for layout changes.
- */
- public List<OnLayoutChangeListener> getOnLayoutChangeListeners() {
- return mOnLayoutChangeListeners;
- }
-
- /**
* Returns the focus-change callback registered for this view.
*
* @return The callback, or null if one is not registered.
@@ -6011,6 +6004,7 @@
invalidate(true);
}
mBackgroundSizeChanged = true;
+ invalidateParentIfNeeded();
}
}
@@ -6077,6 +6071,7 @@
invalidate(true);
}
mBackgroundSizeChanged = true;
+ invalidateParentIfNeeded();
}
}
@@ -6137,6 +6132,7 @@
invalidate(true);
}
mBackgroundSizeChanged = true;
+ invalidateParentIfNeeded();
}
}
@@ -6194,6 +6190,7 @@
invalidate(true);
}
mBackgroundSizeChanged = true;
+ invalidateParentIfNeeded();
}
}
@@ -6438,6 +6435,7 @@
mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
invalidate(false);
}
+ invalidateParentIfNeeded();
}
}
@@ -6476,6 +6474,7 @@
mPrivateFlags |= DRAWN; // force another invalidation with the new orientation
invalidate(false);
}
+ invalidateParentIfNeeded();
}
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 9e5b23c..d4efdb6 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -17,6 +17,7 @@
package android.view;
import android.animation.LayoutTransition;
+import android.view.animation.AlphaAnimation;
import com.android.internal.R;
import com.android.internal.util.Predicate;
@@ -2364,6 +2365,7 @@
DisplayList displayList = null;
Bitmap cache = null;
+ boolean hasDisplayList = false;
if (caching) {
if (!canvas.isHardwareAccelerated()) {
if (layerType != LAYER_TYPE_NONE) {
@@ -2376,12 +2378,13 @@
child.buildDrawingCache(true);
cache = child.getDrawingCache(true);
} else if (layerType == LAYER_TYPE_NONE) {
- displayList = child.getDisplayList();
+ // Delay getting the display list until animation-driven alpha values are
+ // set up and possibly passed on to the view
+ hasDisplayList = true;
}
}
}
- final boolean hasDisplayList = displayList != null && displayList.isReady();
final boolean hasNoCache = cache == null || hasDisplayList;
final int restoreTo = canvas.save();
@@ -2472,6 +2475,10 @@
}
}
+ if (hasDisplayList) {
+ displayList = child.getDisplayList();
+ }
+
if (hasNoCache) {
boolean layerRendered = false;
if (layerType == LAYER_TYPE_HARDWARE) {
@@ -2529,7 +2536,9 @@
canvas.restoreToCount(restoreTo);
if (a != null && !more) {
- child.onSetAlpha(255);
+ if (!canvas.isHardwareAccelerated() && !a.getFillAfter()) {
+ child.onSetAlpha(255);
+ }
finishAnimatingView(child, a);
}
@@ -2538,6 +2547,10 @@
// display lists to render, force an invalidate to allow the animation to
// continue drawing another frame
invalidate();
+ if (a instanceof AlphaAnimation) {
+ // alpha animations should cause the child to recreate its display list
+ child.invalidate();
+ }
}
child.mRecreateDisplayList = false;