summaryrefslogtreecommitdiff
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/view/View.java')
-rw-r--r--core/java/android/view/View.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index c269ea3b2b75..22b307c4c6c7 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -11928,9 +11928,24 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mHardwareLayer = mAttachInfo.mHardwareRenderer.createHardwareLayer(
width, height, isOpaque());
mLocalDirtyRect.set(0, 0, width, height);
- } else if (mHardwareLayer.getWidth() != width || mHardwareLayer.getHeight() != height) {
- mHardwareLayer.resize(width, height);
- mLocalDirtyRect.set(0, 0, width, height);
+ } else {
+ if (mHardwareLayer.getWidth() != width || mHardwareLayer.getHeight() != height) {
+ mHardwareLayer.resize(width, height);
+ mLocalDirtyRect.set(0, 0, width, height);
+ }
+
+ // This should not be necessary but applications that change
+ // the parameters of their background drawable without calling
+ // this.setBackground(Drawable) can leave the view in a bad state
+ // (for instance isOpaque() returns true, but the background is
+ // not opaque.)
+ computeOpaqueFlags();
+
+ final boolean opaque = isOpaque();
+ if (mHardwareLayer.isOpaque() != opaque) {
+ mHardwareLayer.setOpaque(opaque);
+ mLocalDirtyRect.set(0, 0, width, height);
+ }
}
// The layer is not valid if the underlying GPU resources cannot be allocated
@@ -13989,6 +14004,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
@Deprecated
public void setBackgroundDrawable(Drawable background) {
+ computeOpaqueFlags();
+
if (background == mBackground) {
return;
}