summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/ViewGroup.java
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2012-03-13 11:03:25 -0700
committerChet Haase <chet@google.com>2012-03-16 09:14:52 -0700
commit9d1992deaeb3d60d5928f05b649a2cc654ba98a3 (patch)
treef6f5b527f3c4e2e43546ad65b24397734ac83e86 /core/java/android/view/ViewGroup.java
parentf63c52ac87c07ca37b9681a949b1bb5febce3e43 (diff)
downloadframeworks_base-9d1992deaeb3d60d5928f05b649a2cc654ba98a3.zip
frameworks_base-9d1992deaeb3d60d5928f05b649a2cc654ba98a3.tar.gz
frameworks_base-9d1992deaeb3d60d5928f05b649a2cc654ba98a3.tar.bz2
Optimizing DisplayList properties
DisplayList properties are still disabled default (flags in View.java and DisplayListRenderer.h). When they are enabled, and when a View has a DisplayList, invalidations due to property changes are now optimized to avoid causing DisplayList recreation. This eliminates the drawing step of invalidation (due to changes in these properties), only requiring issuing the previously-created DisplayList to the GL renderer. Invalidation is slightly faster (less overhead as we walk up the hierarchy), getDisplayList() is potentially much faster (going down to ~0ms), depending on the complexity of the View being redrawn and the size of the invalidated hierarchy. Change-Id: I57587d5b810c3595bdd72a6c52349c2a3d1bdf25
Diffstat (limited to 'core/java/android/view/ViewGroup.java')
-rw-r--r--core/java/android/view/ViewGroup.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 1993ce6..42426b9 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -3896,6 +3896,72 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
}
/**
+ * Quick invalidation method called by View.invalidateViewProperty. This doesn't set the
+ * DRAWN flags and doesn't handle the Animation logic that the default invalidation methods
+ * do; all we want to do here is schedule a traversal with the appropriate dirty rect.
+ *
+ * @hide
+ */
+ public void invalidateChildFast(View child, final Rect dirty) {
+ ViewParent parent = this;
+
+ final AttachInfo attachInfo = mAttachInfo;
+ if (attachInfo != null) {
+ if (child.mLayerType != LAYER_TYPE_NONE) {
+ child.mLocalDirtyRect.union(dirty);
+ }
+
+ int left = child.mLeft;
+ int top = child.mTop;
+ if (!child.getMatrix().isIdentity()) {
+ child.transformRect(dirty);
+ }
+
+ do {
+ if (parent instanceof ViewGroup) {
+ ViewGroup parentVG = (ViewGroup) parent;
+ parent = parentVG.invalidateChildInParentFast(left, top, dirty);
+ left = parentVG.mLeft;
+ top = parentVG.mTop;
+ } else {
+ // Reached the top; this calls into the usual invalidate method in
+ // ViewRootImpl, which schedules a traversal
+ final int[] location = attachInfo.mInvalidateChildLocation;
+ location[0] = left;
+ location[1] = top;
+ parent = parent.invalidateChildInParent(location, dirty);
+ }
+ } while (parent != null);
+ }
+ }
+
+ /**
+ * Quick invalidation method that simply transforms the dirty rect into the parent's
+ * coordinate system, pruning the invalidation if the parent has already been invalidated.
+ */
+ private ViewParent invalidateChildInParentFast(int left, int top, final Rect dirty) {
+ if ((mPrivateFlags & DRAWN) == DRAWN ||
+ (mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID) {
+ dirty.offset(left - mScrollX, top - mScrollY);
+
+ if ((mGroupFlags & FLAG_CLIP_CHILDREN) == 0 ||
+ dirty.intersect(0, 0, mRight - mLeft, mBottom - mTop)) {
+
+ if (mLayerType != LAYER_TYPE_NONE) {
+ mLocalDirtyRect.union(dirty);
+ }
+ if (!getMatrix().isIdentity()) {
+ transformRect(dirty);
+ }
+
+ return mParent;
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Offset a rectangle that is in a descendant's coordinate
* space into our coordinate space.
* @param descendant A descendant of this view
@@ -3986,6 +4052,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
v.mBottom += offset;
if (USE_DISPLAY_LIST_PROPERTIES && v.mDisplayList != null) {
v.mDisplayList.offsetTopBottom(offset);
+ invalidateViewProperty(false, false);
}
}
}