summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSelim Cinek <cinek@google.com>2014-04-16 17:27:19 +0200
committerSelim Cinek <cinek@google.com>2014-04-17 09:55:11 +0200
commit19cadc203e3fdede40a89b13738464493ed3834a (patch)
tree02686b13c06cab50ac604c0b0e3d4e51f8844cc4
parent781c55fda2fe2685209bdbc1d9554e4fb2b855bf (diff)
downloadframeworks_base-19cadc203e3fdede40a89b13738464493ed3834a.zip
frameworks_base-19cadc203e3fdede40a89b13738464493ed3834a.tar.gz
frameworks_base-19cadc203e3fdede40a89b13738464493ed3834a.tar.bz2
ViewGroup now applies clipBounds to its children
Fixed a bug where a ViewGroup did not clip its children to the set clipBounds unless willNotDraw was set to true. Bug: 14104527 Change-Id: I4892639bb860c1767f1ae6892f3e69525691e55e
-rw-r--r--core/java/android/view/View.java10
-rw-r--r--core/java/android/view/ViewGroup.java18
2 files changed, 23 insertions, 5 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f44cc87..1f9ba46 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -720,6 +720,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
private static boolean sIgnoreMeasureCache = false;
/**
+ * Ignore the clipBounds of this view for the children.
+ */
+ static boolean sIgnoreClipBoundsForChildren = false;
+
+ /**
* This view does not want keystrokes. Use with TAKES_FOCUS_MASK when
* calling setFlags.
*/
@@ -2963,7 +2968,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
/**
* Current clip bounds. to which all drawing of this view are constrained.
*/
- private Rect mClipBounds = null;
+ Rect mClipBounds = null;
private boolean mLastIsOpaque;
@@ -3511,6 +3516,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
// of whether a layout was requested on that View.
sIgnoreMeasureCache = targetSdkVersion < KITKAT;
+ // Older apps may need this to ignore the clip bounds
+ sIgnoreClipBoundsForChildren = targetSdkVersion < L;
+
sCompatibilityDone = true;
}
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index d2c6302..8dac51c 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2960,14 +2960,24 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
}
}
- int saveCount = 0;
+ int clipSaveCount = 0;
final boolean clipToPadding = (flags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK;
+ boolean hasClipBounds = mClipBounds != null && !sIgnoreClipBoundsForChildren;
+ boolean clippingNeeded = clipToPadding || hasClipBounds;
+
+ if (clippingNeeded) {
+ clipSaveCount = canvas.save();
+ }
+
if (clipToPadding) {
- saveCount = canvas.save();
canvas.clipRect(mScrollX + mPaddingLeft, mScrollY + mPaddingTop,
mScrollX + mRight - mLeft - mPaddingRight,
mScrollY + mBottom - mTop - mPaddingBottom);
+ }
+ if (hasClipBounds) {
+ canvas.clipRect(mClipBounds.left, mClipBounds.top, mClipBounds.right,
+ mClipBounds.bottom);
}
// We will draw our child's animation, let's reset the flag
@@ -3008,8 +3018,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
onDebugDraw(canvas);
}
- if (clipToPadding) {
- canvas.restoreToCount(saveCount);
+ if (clippingNeeded) {
+ canvas.restoreToCount(clipSaveCount);
}
// mGroupFlags might have been updated by drawChild()