@@ -11529,12 +11529,34 @@ void setDisplayListProperties(DisplayList displayList) {
1152911529 displayList.setClipChildren(
1153011530 (((ViewGroup)mParent).mGroupFlags & ViewGroup.FLAG_CLIP_CHILDREN) != 0);
1153111531 }
11532- if (mAttachInfo != null && mAttachInfo.mScalingRequired &&
11533- mAttachInfo.mApplicationScale != 1.0f) {
11534- displayList.setApplicationScale(1f / mAttachInfo.mApplicationScale);
11532+ float alpha = 1;
11533+ if (mParent instanceof ViewGroup && (((ViewGroup) mParent).mGroupFlags &
11534+ ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
11535+ ViewGroup parentVG = (ViewGroup) mParent;
11536+ final boolean hasTransform =
11537+ parentVG.getChildStaticTransformation(this, parentVG.mChildTransformation);
11538+ if (hasTransform) {
11539+ Transformation transform = parentVG.mChildTransformation;
11540+ final int transformType = parentVG.mChildTransformation.getTransformationType();
11541+ if (transformType != Transformation.TYPE_IDENTITY) {
11542+ if ((transformType & Transformation.TYPE_ALPHA) != 0) {
11543+ alpha = transform.getAlpha();
11544+ }
11545+ if ((transformType & Transformation.TYPE_MATRIX) != 0) {
11546+ displayList.setStaticMatrix(transform.getMatrix());
11547+ }
11548+ }
11549+ }
1153511550 }
1153611551 if (mTransformationInfo != null) {
11537- displayList.setTransformationInfo(mTransformationInfo.mAlpha,
11552+ alpha *= mTransformationInfo.mAlpha;
11553+ if (alpha < 1) {
11554+ final int multipliedAlpha = (int) (255 * alpha);
11555+ if (onSetAlpha(multipliedAlpha)) {
11556+ alpha = 1;
11557+ }
11558+ }
11559+ displayList.setTransformationInfo(alpha,
1153811560 mTransformationInfo.mTranslationX, mTransformationInfo.mTranslationY,
1153911561 mTransformationInfo.mRotation, mTransformationInfo.mRotationX,
1154011562 mTransformationInfo.mRotationY, mTransformationInfo.mScaleX,
@@ -11548,6 +11570,8 @@ void setDisplayListProperties(DisplayList displayList) {
1154811570 displayList.setPivotX(getPivotX());
1154911571 displayList.setPivotY(getPivotY());
1155011572 }
11573+ } else if (alpha < 1) {
11574+ displayList.setAlpha(alpha);
1155111575 }
1155211576 }
1155311577 }
@@ -11580,6 +11604,7 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1158011604 if ((flags & ViewGroup.FLAG_CHILDREN_DRAWN_WITH_CACHE) != 0 ||
1158111605 (flags & ViewGroup.FLAG_ALWAYS_DRAWN_WITH_CACHE) != 0) {
1158211606 caching = true;
11607+ // Auto-scaled apps are not hw-accelerated, no need to set scaling flag on DisplayList
1158311608 if (mAttachInfo != null) scalingRequired = mAttachInfo.mScalingRequired;
1158411609 } else {
1158511610 caching = (layerType != LAYER_TYPE_NONE) || hardwareAccelerated;
@@ -11590,7 +11615,8 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1159011615 more = drawAnimation(parent, drawingTime, a, scalingRequired);
1159111616 concatMatrix = a.willChangeTransformationMatrix();
1159211617 transformToApply = parent.mChildTransformation;
11593- } else if ((flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
11618+ } else if (!useDisplayListProperties &&
11619+ (flags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) {
1159411620 final boolean hasTransform =
1159511621 parent.getChildStaticTransformation(this, parent.mChildTransformation);
1159611622 if (hasTransform) {
@@ -11658,6 +11684,17 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1165811684 }
1165911685 }
1166011686 useDisplayListProperties &= hasDisplayList;
11687+ if (useDisplayListProperties) {
11688+ displayList = getDisplayList();
11689+ if (!displayList.isValid()) {
11690+ // Uncommon, but possible. If a view is removed from the hierarchy during the call
11691+ // to getDisplayList(), the display list will be marked invalid and we should not
11692+ // try to use it again.
11693+ displayList = null;
11694+ hasDisplayList = false;
11695+ useDisplayListProperties = false;
11696+ }
11697+ }
1166111698
1166211699 final boolean hasNoCache = cache == null || hasDisplayList;
1166311700 final boolean offsetForScroll = cache == null && !hasDisplayList &&
@@ -11675,6 +11712,7 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1167511712 }
1167611713 if (scalingRequired) {
1167711714 if (useDisplayListProperties) {
11715+ // TODO: Might not need this if we put everything inside the DL
1167811716 restoreTo = canvas.save();
1167911717 }
1168011718 // mAttachInfo cannot be null, otherwise scalingRequired == false
@@ -11684,7 +11722,7 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1168411722 }
1168511723
1168611724 float alpha = useDisplayListProperties ? 1 : getAlpha();
11687- if (transformToApply != null || alpha < 1.0f || !hasIdentityMatrix()) {
11725+ if (transformToApply != null || alpha < 1 || !hasIdentityMatrix()) {
1168811726 if (transformToApply != null || !childHasIdentityMatrix) {
1168911727 int transX = 0;
1169011728 int transY = 0;
@@ -11696,16 +11734,20 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1169611734
1169711735 if (transformToApply != null) {
1169811736 if (concatMatrix) {
11699- // Undo the scroll translation, apply the transformation matrix,
11700- // then redo the scroll translate to get the correct result.
11701- canvas.translate(-transX, -transY);
11702- canvas.concat(transformToApply.getMatrix());
11703- canvas.translate(transX, transY);
11737+ if (useDisplayListProperties) {
11738+ displayList.setAnimationMatrix(transformToApply.getMatrix());
11739+ } else {
11740+ // Undo the scroll translation, apply the transformation matrix,
11741+ // then redo the scroll translate to get the correct result.
11742+ canvas.translate(-transX, -transY);
11743+ canvas.concat(transformToApply.getMatrix());
11744+ canvas.translate(transX, transY);
11745+ }
1170411746 parent.mGroupFlags |= ViewGroup.FLAG_CLEAR_TRANSFORMATION;
1170511747 }
1170611748
1170711749 float transformAlpha = transformToApply.getAlpha();
11708- if (transformAlpha < 1.0f ) {
11750+ if (transformAlpha < 1) {
1170911751 alpha *= transformToApply.getAlpha();
1171011752 parent.mGroupFlags |= ViewGroup.FLAG_CLEAR_TRANSFORMATION;
1171111753 }
@@ -11718,7 +11760,7 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1171811760 }
1171911761 }
1172011762
11721- if (alpha < 1.0f ) {
11763+ if (alpha < 1) {
1172211764 parent.mGroupFlags |= ViewGroup.FLAG_CLEAR_TRANSFORMATION;
1172311765 if (hasNoCache) {
1172411766 final int multipliedAlpha = (int) (255 * alpha);
@@ -11728,7 +11770,9 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1172811770 layerType != LAYER_TYPE_NONE) {
1172911771 layerFlags |= Canvas.CLIP_TO_LAYER_SAVE_FLAG;
1173011772 }
11731- if (layerType == LAYER_TYPE_NONE) {
11773+ if (useDisplayListProperties) {
11774+ displayList.setAlpha(alpha * getAlpha());
11775+ } else if (layerType == LAYER_TYPE_NONE) {
1173211776 final int scrollX = hasDisplayList ? 0 : sx;
1173311777 final int scrollY = hasDisplayList ? 0 : sy;
1173411778 canvas.saveLayerAlpha(scrollX, scrollY, scrollX + mRight - mLeft,
@@ -11758,7 +11802,7 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1175811802 }
1175911803 }
1176011804
11761- if (hasDisplayList) {
11805+ if (!useDisplayListProperties && hasDisplayList) {
1176211806 displayList = getDisplayList();
1176311807 if (!displayList.isValid()) {
1176411808 // Uncommon, but possible. If a view is removed from the hierarchy during the call
@@ -11815,7 +11859,7 @@ boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) {
1181511859 cachePaint.setDither(false);
1181611860 parent.mCachePaint = cachePaint;
1181711861 }
11818- if (alpha < 1.0f ) {
11862+ if (alpha < 1) {
1181911863 cachePaint.setAlpha((int) (alpha * 255));
1182011864 parent.mGroupFlags |= ViewGroup.FLAG_ALPHA_LOWER_THAN_ONE;
1182111865 } else if ((flags & ViewGroup.FLAG_ALPHA_LOWER_THAN_ONE) != 0) {
0 commit comments