Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7bf9d36 authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Reduce the number of measurement passes in RelativeLayout"

parents 119143de 4cb81d64
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -695,6 +695,20 @@ public class RelativeLayout extends ViewGroup {
                params.topMargin, params.bottomMargin,
                mPaddingTop, mPaddingBottom,
                myHeight);
        if (params.mPreviousWidthSpec == childWidthMeasureSpec && !child.isLayoutRequested()) {
            switch (MeasureSpec.getMode(childHeightMeasureSpec)) {
                case MeasureSpec.EXACTLY:
                    if (child.getMeasuredHeight() == MeasureSpec.getSize(childHeightMeasureSpec)) {
                        return;
                    }
                    break;
                case MeasureSpec.AT_MOST:
                    if (child.getMeasuredHeight() <= MeasureSpec.getSize(childHeightMeasureSpec)) {
                        return;
                    }
                    break;
            }
        }
        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    }

@@ -726,6 +740,7 @@ public class RelativeLayout extends ViewGroup {
            childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
        }
        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
        params.mPreviousWidthSpec = childWidthMeasureSpec;
    }

    /**
@@ -900,8 +915,6 @@ public class RelativeLayout extends ViewGroup {
        } else if (childParams.alignWithParent && rules[LEFT_OF] != 0) {
            if (myWidth >= 0) {
                childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin;
            } else {
                // FIXME uh oh...
            }
        }

@@ -926,8 +939,6 @@ public class RelativeLayout extends ViewGroup {
        } else if (childParams.alignWithParent && rules[ALIGN_RIGHT] != 0) {
            if (myWidth >= 0) {
                childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin;
            } else {
                // FIXME uh oh...
            }
        }

@@ -938,8 +949,6 @@ public class RelativeLayout extends ViewGroup {
        if (0 != rules[ALIGN_PARENT_RIGHT]) {
            if (myWidth >= 0) {
                childParams.mRight = myWidth - mPaddingRight - childParams.rightMargin;
            } else {
                // FIXME uh oh...
            }
        }
    }
@@ -958,8 +967,6 @@ public class RelativeLayout extends ViewGroup {
        } else if (childParams.alignWithParent && rules[ABOVE] != 0) {
            if (myHeight >= 0) {
                childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin;
            } else {
                // FIXME uh oh...
            }
        }

@@ -984,8 +991,6 @@ public class RelativeLayout extends ViewGroup {
        } else if (childParams.alignWithParent && rules[ALIGN_BOTTOM] != 0) {
            if (myHeight >= 0) {
                childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin;
            } else {
                // FIXME uh oh...
            }
        }

@@ -996,8 +1001,6 @@ public class RelativeLayout extends ViewGroup {
        if (0 != rules[ALIGN_PARENT_BOTTOM]) {
            if (myHeight >= 0) {
                childParams.mBottom = myHeight - mPaddingBottom - childParams.bottomMargin;
            } else {
                // FIXME uh oh...
            }
        }

@@ -1242,6 +1245,8 @@ public class RelativeLayout extends ViewGroup {
        @ViewDebug.ExportedProperty(category = "layout")
        public boolean alignWithParent;

        int mPreviousWidthSpec;

        public LayoutParams(Context c, AttributeSet attrs) {
            super(c, attrs);