Deprecate and disable legacy caching APIs
bug:20159889 Change-Id: Ib25bb6bceaee27b4d04a64e8ad298db9977b2719
This commit is contained in:
@@ -15021,7 +15021,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;
|
||||
@@ -15138,23 +15138,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;
|
||||
@@ -15204,34 +15194,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;
|
||||
|
||||
@@ -244,8 +244,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
|
||||
@@ -291,16 +290,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
|
||||
@@ -583,8 +577,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;
|
||||
@@ -3067,44 +3059,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;
|
||||
@@ -3275,8 +3229,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];
|
||||
@@ -3284,12 +3236,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3303,10 +3249,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());
|
||||
}
|
||||
@@ -3484,13 +3426,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);
|
||||
}
|
||||
|
||||
@@ -5258,8 +5193,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;
|
||||
}
|
||||
@@ -5274,6 +5211,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);
|
||||
@@ -5288,8 +5228,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;
|
||||
}
|
||||
@@ -5310,6 +5252,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);
|
||||
@@ -5323,8 +5268,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;
|
||||
}
|
||||
@@ -5341,6 +5289,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);
|
||||
|
||||
Reference in New Issue
Block a user