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

Commit e4cf152c authored by Chris Craik's avatar Chris Craik
Browse files

Move clip bound execution into drawChild()

bug:15698973

This makes native and java implementations match up in the sequence of
clip vs applying other properties / draw calls.

Change-Id: Ia75e00c5b42f81ecd516722ef1c5233d483e0c97
parent f174c6e6
Loading
Loading
Loading
Loading
+21 −14
Original line number Diff line number Diff line
@@ -14647,8 +14647,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                        } else  if (layerType == LAYER_TYPE_NONE) {
                            final int scrollX = hasDisplayList ? 0 : sx;
                            final int scrollY = hasDisplayList ? 0 : sy;
                            canvas.saveLayerAlpha(scrollX, scrollY, scrollX + mRight - mLeft,
                                    scrollY + mBottom - mTop, multipliedAlpha, layerFlags);
                            canvas.saveLayerAlpha(scrollX, scrollY,
                                    scrollX + (mRight - mLeft), scrollY + (mBottom - mTop),
                                    multipliedAlpha, layerFlags);
                        }
                    } else {
                        // Alpha is handled by the child directly, clobber the layer's alpha
@@ -14661,8 +14662,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            mPrivateFlags &= ~PFLAG_ALPHA_SET;
        }
        if ((flags & ViewGroup.FLAG_CLIP_CHILDREN) == ViewGroup.FLAG_CLIP_CHILDREN &&
                !usingRenderNodeProperties && cache == null) {
        if (!usingRenderNodeProperties) {
            // apply clips directly, since RenderNode won't do it for this draw
            if ((flags & ViewGroup.FLAG_CLIP_CHILDREN) == ViewGroup.FLAG_CLIP_CHILDREN
                    && cache == null) {
                if (offsetForScroll) {
                    canvas.clipRect(sx, sy, sx + (mRight - mLeft), sy + (mBottom - mTop));
                } else {
@@ -14674,6 +14677,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                }
            }
            if (mClipBounds != null) {
                // clip bounds ignore scroll
                canvas.clipRect(mClipBounds);
            }
        }
        if (!usingRenderNodeProperties && hasDisplayList) {
            renderNode = getDisplayList();
            if (!renderNode.isValid()) {
@@ -14774,10 +14785,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @param canvas The Canvas to which the View is rendered.
     */
    public void draw(Canvas canvas) {
        boolean usingRenderNodeProperties = canvas.isRecordingFor(mRenderNode);
        if (mClipBounds != null && !usingRenderNodeProperties) {
            canvas.clipRect(mClipBounds);
        }
        final int privateFlags = mPrivateFlags;
        final boolean dirtyOpaque = (privateFlags & PFLAG_DIRTY_MASK) == PFLAG_DIRTY_OPAQUE &&
                (mAttachInfo == null || !mAttachInfo.mIgnoreDirtyState);
+2 −13
Original line number Diff line number Diff line
@@ -3060,24 +3060,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager

        int clipSaveCount = 0;
        final boolean clipToPadding = (flags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK;
        boolean hasClipBounds = mClipBounds != null && !usingRenderNodeProperties;
        boolean clippingNeeded = clipToPadding || hasClipBounds;

        if (clippingNeeded) {
            clipSaveCount = canvas.save();
        }

        if (clipToPadding) {
            clipSaveCount = canvas.save();
            canvas.clipRect(mScrollX + mPaddingLeft, mScrollY + mPaddingTop,
                    mScrollX + mRight - mLeft - mPaddingRight,
                    mScrollY + mBottom - mTop - mPaddingBottom);
        }

        if (hasClipBounds) {
            canvas.clipRect(mClipBounds.left, mClipBounds.top, mClipBounds.right,
                    mClipBounds.bottom);
        }

        // We will draw our child's animation, let's reset the flag
        mPrivateFlags &= ~PFLAG_DRAW_ANIMATION;
        mGroupFlags &= ~FLAG_INVALIDATE_REQUIRED;
@@ -3117,7 +3106,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            onDebugDraw(canvas);
        }

        if (clippingNeeded) {
        if (clipToPadding) {
            canvas.restoreToCount(clipSaveCount);
        }