summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2015-04-13 19:46:31 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-04-13 19:46:32 +0000
commitf518a3ab70acf70d2f7d3ef3d1f6effd09b224df (patch)
tree6fee32c3c8738ec408e25d51db01031be3a47b2e
parent98680e969b384e2765a311fe14a070fb39f587ee (diff)
parent5a6bbae6fca83e4534600be3701a28eb787ae71c (diff)
Merge "Deprecate and disable legacy caching APIs"
-rw-r--r--api/current.txt12
-rw-r--r--api/system-current.txt12
-rw-r--r--core/java/android/view/View.java68
-rw-r--r--core/java/android/view/ViewGroup.java98
4 files changed, 65 insertions, 125 deletions
diff --git a/api/current.txt b/api/current.txt
index 533682fd7380..6de9a03c35bd 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -35833,10 +35833,10 @@ package android.view {
method public int indexOfChild(android.view.View);
method public final void invalidateChild(android.view.View, android.graphics.Rect);
method public android.view.ViewParent invalidateChildInParent(int[], android.graphics.Rect);
- method public boolean isAlwaysDrawnWithCacheEnabled();
- method public boolean isAnimationCacheEnabled();
+ method public deprecated boolean isAlwaysDrawnWithCacheEnabled();
+ method public deprecated boolean isAnimationCacheEnabled();
method protected boolean isChildrenDrawingOrderEnabled();
- method protected boolean isChildrenDrawnWithCacheEnabled();
+ method protected deprecated boolean isChildrenDrawnWithCacheEnabled();
method public boolean isMotionEventSplittingEnabled();
method public boolean isTransitionGroup();
method public final void layout(int, int, int, int);
@@ -35875,11 +35875,11 @@ package android.view {
method public void requestTransparentRegion(android.view.View);
method public void scheduleLayoutAnimation();
method public void setAddStatesFromChildren(boolean);
- method public void setAlwaysDrawnWithCacheEnabled(boolean);
- method public void setAnimationCacheEnabled(boolean);
+ method public deprecated void setAlwaysDrawnWithCacheEnabled(boolean);
+ method public deprecated void setAnimationCacheEnabled(boolean);
method protected void setChildrenDrawingCacheEnabled(boolean);
method protected void setChildrenDrawingOrderEnabled(boolean);
- method protected void setChildrenDrawnWithCacheEnabled(boolean);
+ method protected deprecated void setChildrenDrawnWithCacheEnabled(boolean);
method public void setClipChildren(boolean);
method public void setClipToPadding(boolean);
method public void setDescendantFocusability(int);
diff --git a/api/system-current.txt b/api/system-current.txt
index 7698f8e483fd..2d387d13d303 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -38458,10 +38458,10 @@ package android.view {
method public int indexOfChild(android.view.View);
method public final void invalidateChild(android.view.View, android.graphics.Rect);
method public android.view.ViewParent invalidateChildInParent(int[], android.graphics.Rect);
- method public boolean isAlwaysDrawnWithCacheEnabled();
- method public boolean isAnimationCacheEnabled();
+ method public deprecated boolean isAlwaysDrawnWithCacheEnabled();
+ method public deprecated boolean isAnimationCacheEnabled();
method protected boolean isChildrenDrawingOrderEnabled();
- method protected boolean isChildrenDrawnWithCacheEnabled();
+ method protected deprecated boolean isChildrenDrawnWithCacheEnabled();
method public boolean isMotionEventSplittingEnabled();
method public boolean isTransitionGroup();
method public final void layout(int, int, int, int);
@@ -38500,11 +38500,11 @@ package android.view {
method public void requestTransparentRegion(android.view.View);
method public void scheduleLayoutAnimation();
method public void setAddStatesFromChildren(boolean);
- method public void setAlwaysDrawnWithCacheEnabled(boolean);
- method public void setAnimationCacheEnabled(boolean);
+ method public deprecated void setAlwaysDrawnWithCacheEnabled(boolean);
+ method public deprecated void setAnimationCacheEnabled(boolean);
method protected void setChildrenDrawingCacheEnabled(boolean);
method protected void setChildrenDrawingOrderEnabled(boolean);
- method protected void setChildrenDrawnWithCacheEnabled(boolean);
+ method protected deprecated void setChildrenDrawnWithCacheEnabled(boolean);
method public void setClipChildren(boolean);
method public void setClipToPadding(boolean);
method public void setDescendantFocusability(int);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 60d2cebece59..3fa8c81a2e94 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15087,7 +15087,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* Utility function, called by draw(canvas, parent, drawingTime) to handle the less common
* case of an active Animation being run on the view.
*/
- private boolean drawAnimation(ViewGroup parent, long drawingTime,
+ private boolean applyLegacyAnimation(ViewGroup parent, long drawingTime,
Animation a, boolean scalingRequired) {
Transformation invalidationTransform;
final int flags = parent.mGroupFlags;
@@ -15204,23 +15204,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
Transformation transformToApply = null;
boolean concatMatrix = false;
- boolean scalingRequired = false;
- boolean caching;
+ boolean scalingRequired = mAttachInfo != null && mAttachInfo.mScalingRequired;
int layerType = getLayerType();
-
final boolean hardwareAccelerated = canvas.isHardwareAccelerated();
- if ((flags & ViewGroup.FLAG_CHILDREN_DRAWN_WITH_CACHE) != 0 ||
- (flags & ViewGroup.FLAG_ALWAYS_DRAWN_WITH_CACHE) != 0) {
- caching = true;
- // Auto-scaled apps are not hw-accelerated, no need to set scaling flag on DisplayList
- if (mAttachInfo != null) scalingRequired = mAttachInfo.mScalingRequired;
- } else {
- caching = (layerType != LAYER_TYPE_NONE) || hardwareAccelerated;
- }
final Animation a = getAnimation();
if (a != null) {
- more = drawAnimation(parent, drawingTime, a, scalingRequired);
+ more = applyLegacyAnimation(parent, drawingTime, a, scalingRequired);
concatMatrix = a.willChangeTransformationMatrix();
if (concatMatrix) {
mPrivateFlags3 |= PFLAG3_VIEW_IS_ANIMATING_TRANSFORM;
@@ -15270,34 +15260,32 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
RenderNode renderNode = null;
Bitmap cache = null;
boolean hasDisplayList = false;
- if (caching) {
- if (!hardwareAccelerated) {
- if (layerType != LAYER_TYPE_NONE) {
- layerType = LAYER_TYPE_SOFTWARE;
- buildDrawingCache(true);
- }
- cache = getDrawingCache(true);
- } else {
- switch (layerType) {
- case LAYER_TYPE_SOFTWARE:
- if (usingRenderNodeProperties) {
- hasDisplayList = canHaveDisplayList();
- } else {
- buildDrawingCache(true);
- cache = getDrawingCache(true);
- }
- break;
- case LAYER_TYPE_HARDWARE:
- if (usingRenderNodeProperties) {
- hasDisplayList = canHaveDisplayList();
- }
- break;
- case LAYER_TYPE_NONE:
- // Delay getting the display list until animation-driven alpha values are
- // set up and possibly passed on to the view
+ if (!hardwareAccelerated) {
+ if (layerType != LAYER_TYPE_NONE) {
+ layerType = LAYER_TYPE_SOFTWARE;
+ buildDrawingCache(true);
+ }
+ cache = getDrawingCache(true);
+ } else {
+ switch (layerType) {
+ case LAYER_TYPE_SOFTWARE:
+ if (usingRenderNodeProperties) {
hasDisplayList = canHaveDisplayList();
- break;
- }
+ } else {
+ buildDrawingCache(true);
+ cache = getDrawingCache(true);
+ }
+ break;
+ case LAYER_TYPE_HARDWARE:
+ if (usingRenderNodeProperties) {
+ hasDisplayList = canHaveDisplayList();
+ }
+ break;
+ case LAYER_TYPE_NONE:
+ // Delay getting the display list until animation-driven alpha values are
+ // set up and possibly passed on to the view
+ hasDisplayList = canHaveDisplayList();
+ break;
}
}
usingRenderNodeProperties &= hasDisplayList;
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 8d06ce2f6ccf..98b895d893cc 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -245,8 +245,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
// to clip it, even if FLAG_CLIP_TO_PADDING is set
private static final int FLAG_PADDING_NOT_NULL = 0x20;
- // When set, this ViewGroup caches its children in a Bitmap before starting a layout animation
- // Set by default
+ /** @deprecated - functionality removed */
private static final int FLAG_ANIMATION_CACHE = 0x40;
// When set, this ViewGroup converts calls to invalidate(Rect) to invalidate() during a
@@ -292,16 +291,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*/
private static final int FLAG_ADD_STATES_FROM_CHILDREN = 0x2000;
- /**
- * When set, this ViewGroup tries to always draw its children using their drawing cache.
- */
- static final int FLAG_ALWAYS_DRAWN_WITH_CACHE = 0x4000;
+ /** @deprecated functionality removed */
+ private static final int FLAG_ALWAYS_DRAWN_WITH_CACHE = 0x4000;
- /**
- * When set, and if FLAG_ALWAYS_DRAWN_WITH_CACHE is not set, this ViewGroup will try to
- * draw its children with their drawing cache.
- */
- static final int FLAG_CHILDREN_DRAWN_WITH_CACHE = 0x8000;
+ /** @deprecated functionality removed */
+ private static final int FLAG_CHILDREN_DRAWN_WITH_CACHE = 0x8000;
/**
* When set, this group will go through its list of children to notify them of
@@ -584,8 +578,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
mGroupFlags |= FLAG_CLIP_CHILDREN;
mGroupFlags |= FLAG_CLIP_TO_PADDING;
mGroupFlags |= FLAG_ANIMATION_DONE;
- mGroupFlags |= FLAG_ANIMATION_CACHE;
- mGroupFlags |= FLAG_ALWAYS_DRAWN_WITH_CACHE;
if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB) {
mGroupFlags |= FLAG_SPLIT_MOTION_EVENTS;
@@ -3088,44 +3080,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
}
@Override
- protected void onAnimationStart() {
- super.onAnimationStart();
-
- // When this ViewGroup's animation starts, build the cache for the children
- if ((mGroupFlags & FLAG_ANIMATION_CACHE) == FLAG_ANIMATION_CACHE) {
- final int count = mChildrenCount;
- final View[] children = mChildren;
- final boolean buildCache = !isHardwareAccelerated();
-
- for (int i = 0; i < count; i++) {
- final View child = children[i];
- if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
- child.setDrawingCacheEnabled(true);
- if (buildCache) {
- child.buildDrawingCache(true);
- }
- }
- }
-
- mGroupFlags |= FLAG_CHILDREN_DRAWN_WITH_CACHE;
- }
- }
-
- @Override
- protected void onAnimationEnd() {
- super.onAnimationEnd();
-
- // When this ViewGroup's animation ends, destroy the cache of the children
- if ((mGroupFlags & FLAG_ANIMATION_CACHE) == FLAG_ANIMATION_CACHE) {
- mGroupFlags &= ~FLAG_CHILDREN_DRAWN_WITH_CACHE;
-
- if ((mPersistentDrawingCache & PERSISTENT_ANIMATION_CACHE) == 0) {
- setChildrenDrawingCacheEnabled(false);
- }
- }
- }
-
- @Override
Bitmap createSnapshot(Bitmap.Config quality, int backgroundColor, boolean skipChildren) {
int count = mChildrenCount;
int[] visibilities = null;
@@ -3295,8 +3249,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
int flags = mGroupFlags;
if ((flags & FLAG_RUN_ANIMATION) != 0 && canAnimate()) {
- final boolean cache = (mGroupFlags & FLAG_ANIMATION_CACHE) == FLAG_ANIMATION_CACHE;
-
final boolean buildCache = !isHardwareAccelerated();
for (int i = 0; i < childrenCount; i++) {
final View child = children[i];
@@ -3304,12 +3256,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
final LayoutParams params = child.getLayoutParams();
attachLayoutAnimationParameters(child, params, i, childrenCount);
bindLayoutAnimation(child);
- if (cache) {
- child.setDrawingCacheEnabled(true);
- if (buildCache) {
- child.buildDrawingCache(true);
- }
- }
}
}
@@ -3323,10 +3269,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
mGroupFlags &= ~FLAG_RUN_ANIMATION;
mGroupFlags &= ~FLAG_ANIMATION_DONE;
- if (cache) {
- mGroupFlags |= FLAG_CHILDREN_DRAWN_WITH_CACHE;
- }
-
if (mAnimationListener != null) {
mAnimationListener.onAnimationStart(controller.getAnimation());
}
@@ -3504,13 +3446,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
post(end);
}
- if ((mGroupFlags & FLAG_ANIMATION_CACHE) == FLAG_ANIMATION_CACHE) {
- mGroupFlags &= ~FLAG_CHILDREN_DRAWN_WITH_CACHE;
- if ((mPersistentDrawingCache & PERSISTENT_ANIMATION_CACHE) == 0) {
- setChildrenDrawingCacheEnabled(false);
- }
- }
-
invalidate(true);
}
@@ -5278,8 +5213,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*
* @see #setAnimationCacheEnabled(boolean)
* @see View#setDrawingCacheEnabled(boolean)
+ *
+ * @deprecated As of {@link android.os.Build.VERSION_CODES#MNC}, this property is ignored.
+ * Caching behavior of children may be controlled through {@link View#setLayerType(int, Paint)}.
*/
- @ViewDebug.ExportedProperty
public boolean isAnimationCacheEnabled() {
return (mGroupFlags & FLAG_ANIMATION_CACHE) == FLAG_ANIMATION_CACHE;
}
@@ -5294,6 +5231,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*
* @see #isAnimationCacheEnabled()
* @see View#setDrawingCacheEnabled(boolean)
+ *
+ * @deprecated As of {@link android.os.Build.VERSION_CODES#MNC}, this property is ignored.
+ * Caching behavior of children may be controlled through {@link View#setLayerType(int, Paint)}.
*/
public void setAnimationCacheEnabled(boolean enabled) {
setBooleanFlag(FLAG_ANIMATION_CACHE, enabled);
@@ -5308,8 +5248,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
* @see #setAlwaysDrawnWithCacheEnabled(boolean)
* @see #setChildrenDrawnWithCacheEnabled(boolean)
* @see View#setDrawingCacheEnabled(boolean)
+ *
+ * @deprecated As of {@link android.os.Build.VERSION_CODES#MNC}, this property is ignored.
+ * Child views may no longer have their caching behavior disabled by parents.
*/
- @ViewDebug.ExportedProperty(category = "drawing")
public boolean isAlwaysDrawnWithCacheEnabled() {
return (mGroupFlags & FLAG_ALWAYS_DRAWN_WITH_CACHE) == FLAG_ALWAYS_DRAWN_WITH_CACHE;
}
@@ -5330,6 +5272,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
* @see #setChildrenDrawnWithCacheEnabled(boolean)
* @see View#setDrawingCacheEnabled(boolean)
* @see View#setDrawingCacheQuality(int)
+ *
+ * @deprecated As of {@link android.os.Build.VERSION_CODES#MNC}, this property is ignored.
+ * Child views may no longer have their caching behavior disabled by parents.
*/
public void setAlwaysDrawnWithCacheEnabled(boolean always) {
setBooleanFlag(FLAG_ALWAYS_DRAWN_WITH_CACHE, always);
@@ -5343,8 +5288,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*
* @see #setAlwaysDrawnWithCacheEnabled(boolean)
* @see #setChildrenDrawnWithCacheEnabled(boolean)
+ *
+ * @deprecated As of {@link android.os.Build.VERSION_CODES#MNC}, this property is ignored.
+ * Child views may no longer be forced to cache their rendering state by their parents.
+ * Use {@link View#setLayerType(int, Paint)} on individual Views instead.
*/
- @ViewDebug.ExportedProperty(category = "drawing")
protected boolean isChildrenDrawnWithCacheEnabled() {
return (mGroupFlags & FLAG_CHILDREN_DRAWN_WITH_CACHE) == FLAG_CHILDREN_DRAWN_WITH_CACHE;
}
@@ -5361,6 +5309,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*
* @see #setAlwaysDrawnWithCacheEnabled(boolean)
* @see #isChildrenDrawnWithCacheEnabled()
+ *
+ * @deprecated As of {@link android.os.Build.VERSION_CODES#MNC}, this property is ignored.
+ * Child views may no longer be forced to cache their rendering state by their parents.
+ * Use {@link View#setLayerType(int, Paint)} on individual Views instead.
*/
protected void setChildrenDrawnWithCacheEnabled(boolean enabled) {
setBooleanFlag(FLAG_CHILDREN_DRAWN_WITH_CACHE, enabled);