From ff641477a75b7318a936f048e2bd87a1ae114b98 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Thu, 20 Feb 2014 15:06:17 -0800 Subject: [PATCH] Damage IsolatedZVolume when shadows change bug:12874322 Change-Id: I3dd92f551dfb00965ccd08647586f378f8949b1c --- core/java/android/view/View.java | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 0665264687e02..e9082c39233ad 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -11554,6 +11554,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, receiver.damageInParent(); } } + + // Damage the entire IsolatedZVolume recieving this view's shadow. + if (getCastsShadow() && getTranslationZ() != 0) { + damageIsolatedZVolume(); + } } } @@ -11580,6 +11585,29 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return mBackground != null; } + /** + * Damage area of the screen covered by the current isolated Z volume + * + * This method will guarantee that any changes to shadows cast by a View + * are damaged on the screen for future redraw. + */ + private void damageIsolatedZVolume() { + final AttachInfo ai = mAttachInfo; + if (ai != null) { + ViewParent p = getParent(); + while (p != null) { + if (p instanceof ViewGroup) { + final ViewGroup vg = (ViewGroup) p; + if (vg.hasIsolatedZVolume()) { + vg.damageInParent(); + return; + } + } + p = p.getParent(); + } + } + } + /** * Quick invalidation for View property changes (alpha, translationXY, etc.). We don't want to * set any flags or handle all of the cases handled by the default invalidation methods. @@ -11608,12 +11636,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } else { damageInParent(); } + if (invalidateParent && getCastsShadow() && getTranslationZ() != 0) { + damageIsolatedZVolume(); + } } /** * Tells the parent view to damage this view's bounds. + * + * @hide */ - private void damageInParent() { + protected void damageInParent() { final AttachInfo ai = mAttachInfo; final ViewParent p = mParent; if (p != null && ai != null) {