summaryrefslogtreecommitdiff
path: root/core/java/android/view/View.java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-07-11 17:44:57 -0700
committerRomain Guy <romainguy@google.com>2012-07-11 17:44:57 -0700
commit846a533945576e5cb1a66529ca3a52d71749f04f (patch)
tree5f122ddffce0038a2b885851249cb8a9bb51ca6c /core/java/android/view/View.java
parent053a82cc18b8ad9b6cb321b57893225411ccf146 (diff)
Update layers' opaque property when needed
Before this change, changing a View's opacity would not be reflected by hardware layers. This could cause layers to retain their previous opacity. Change-Id: Iba2c8b4242deca021651df9324cc7c585a64653d
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;
}