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

Commit b6e426e1 authored by Marzia Favaro's avatar Marzia Favaro Committed by Android (Google) Code Review
Browse files

Merge "Edge extension effect: extend surfaces (reland)" into main

parents b8481144 57ad5460
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.os.Handler;
import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.WindowInsets;

import dalvik.system.CloseGuard;

@@ -881,12 +882,13 @@ public abstract class Animation implements Cloneable {
    }

    /**
     * @return if a window animation has outsets applied to it.
     * @return the edges to which outsets should be applied if run as a windoow animation.
     *
     * @hide
     */
    public boolean hasExtension() {
        return false;
    @WindowInsets.Side.InsetsSide
    public int getExtensionEdges() {
        return 0x0;
    }

    /**
+6 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.res.TypedArray;
import android.graphics.RectF;
import android.os.Build;
import android.util.AttributeSet;
import android.view.WindowInsets;

import java.util.ArrayList;
import java.util.List;
@@ -540,12 +541,12 @@ public class AnimationSet extends Animation {

    /** @hide */
    @Override
    public boolean hasExtension() {
    @WindowInsets.Side.InsetsSide
    public int getExtensionEdges() {
        int edge = 0x0;
        for (Animation animation : mAnimations) {
            if (animation.hasExtension()) {
                return true;
            edge |= animation.getExtensionEdges();
        }
        }
        return false;
        return edge;
    }
}
+7 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Insets;
import android.util.AttributeSet;
import android.view.WindowInsets;

/**
 * An animation that controls the outset of an object.
@@ -151,9 +152,12 @@ public class ExtendAnimation extends Animation {

    /** @hide */
    @Override
    public boolean hasExtension() {
        return mFromInsets.left < 0 || mFromInsets.top < 0 || mFromInsets.right < 0
                || mFromInsets.bottom < 0;
    @WindowInsets.Side.InsetsSide
    public int getExtensionEdges() {
        return (mFromInsets.left < 0 || mToInsets.left < 0 ?  WindowInsets.Side.LEFT : 0)
            | (mFromInsets.right < 0 || mToInsets.right < 0 ?  WindowInsets.Side.RIGHT : 0)
            | (mFromInsets.top < 0 || mToInsets.top < 0 ?  WindowInsets.Side.TOP : 0)
            | (mFromInsets.bottom < 0 || mToInsets.bottom < 0 ? WindowInsets.Side.BOTTOM : 0);
    }

    @Override
+14 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.activityembedding;

import static android.graphics.Matrix.MTRANS_X;
import static android.graphics.Matrix.MTRANS_Y;
import static android.window.TransitionInfo.FLAG_TRANSLUCENT;

import android.annotation.CallSuper;
import android.graphics.Point;
@@ -146,6 +147,14 @@ class ActivityEmbeddingAnimationAdapter {
    /** To be overridden by subclasses to adjust the animation surface change. */
    void onAnimationUpdateInner(@NonNull SurfaceControl.Transaction t) {
        // Update the surface position and alpha.
        if (com.android.graphics.libgui.flags.Flags.edgeExtensionShader()
                && mAnimation.getExtensionEdges() != 0x0
                && !(mChange.hasFlags(FLAG_TRANSLUCENT)
                        && mChange.getActivityComponent() != null)) {
            // Extend non-translucent activities
            t.setEdgeExtensionEffect(mLeash, mAnimation.getExtensionEdges());
        }

        mTransformation.getMatrix().postTranslate(mContentRelOffset.x, mContentRelOffset.y);
        t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix);
        t.setAlpha(mLeash, mTransformation.getAlpha());
@@ -165,7 +174,7 @@ class ActivityEmbeddingAnimationAdapter {
        if (!cropRect.intersect(mWholeAnimationBounds)) {
            // Hide the surface when it is outside of the animation area.
            t.setAlpha(mLeash, 0);
        } else if (mAnimation.hasExtension()) {
        } else if (mAnimation.getExtensionEdges() != 0) {
            // Allow the surface to be shown in its original bounds in case we want to use edge
            // extensions.
            cropRect.union(mContentBounds);
@@ -180,6 +189,10 @@ class ActivityEmbeddingAnimationAdapter {
    @CallSuper
    void onAnimationEnd(@NonNull SurfaceControl.Transaction t) {
        onAnimationUpdate(t, mAnimation.getDuration());
        if (com.android.graphics.libgui.flags.Flags.edgeExtensionShader()
                && mAnimation.getExtensionEdges() != 0x0) {
            t.setEdgeExtensionEffect(mLeash, /* edge */ 0);
        }
    }

    final long getDurationHint() {
+5 −3
Original line number Diff line number Diff line
@@ -144,8 +144,10 @@ class ActivityEmbeddingAnimationRunner {
            // ending states.
            prepareForJumpCut(info, startTransaction);
        } else {
            if (!com.android.graphics.libgui.flags.Flags.edgeExtensionShader()) {
                addEdgeExtensionIfNeeded(startTransaction, finishTransaction,
                        postStartTransactionCallbacks, adapters);
            }
            addBackgroundColorIfNeeded(info, startTransaction, finishTransaction, adapters);
            for (ActivityEmbeddingAnimationAdapter adapter : adapters) {
                duration = Math.max(duration, adapter.getDurationHint());
@@ -341,7 +343,7 @@ class ActivityEmbeddingAnimationRunner {
            @NonNull List<ActivityEmbeddingAnimationAdapter> adapters) {
        for (ActivityEmbeddingAnimationAdapter adapter : adapters) {
            final Animation animation = adapter.mAnimation;
            if (!animation.hasExtension()) {
            if (animation.getExtensionEdges() == 0) {
                continue;
            }
            if (adapter.mChange.hasFlags(FLAG_TRANSLUCENT)
Loading