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

Commit a8601413 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Revert "Use destroy in transaction for animation""

parents 142f5717 38804384
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -152,7 +152,6 @@ public class SurfaceControl implements Parcelable {
    private static native void nativeSeverChildren(long transactionObj, long nativeObject);
    private static native void nativeSetOverrideScalingMode(long transactionObj, long nativeObject,
            int scalingMode);
    private static native void nativeDestroy(long transactionObj, long nativeObject);
    private static native IBinder nativeGetHandle(long nativeObject);
    private static native boolean nativeGetTransformToDisplayInverse(long nativeObject);

@@ -1571,16 +1570,6 @@ public class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Same as {@link #destroy()} except this is invoked in a transaction instead of
         * immediately.
         */
        public Transaction destroy(SurfaceControl sc) {
            sc.checkNotReleased();
            nativeDestroy(mNativeObject, sc.mNativeObject);
            return this;
        }

        public Transaction setDisplaySurface(IBinder displayToken, Surface surface) {
            if (displayToken == null) {
                throw new IllegalArgumentException("displayToken must not be null");
+0 −10
Original line number Diff line number Diff line
@@ -846,14 +846,6 @@ static void nativeSetOverrideScalingMode(JNIEnv* env, jclass clazz, jlong transa
    transaction->setOverrideScalingMode(ctrl, scalingMode);
}

static void nativeDestroyInTransaction(JNIEnv* env, jclass clazz,
                                       jlong transactionObj,
                                       jlong nativeObject) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    auto ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
    transaction->destroySurface(ctrl);
}

static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
    auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    return javaObjectForIBinder(env, ctrl->getHandle());
@@ -1005,8 +997,6 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSeverChildren } ,
    {"nativeSetOverrideScalingMode", "(JJI)V",
            (void*)nativeSetOverrideScalingMode },
    {"nativeDestroy", "(JJ)V",
            (void*)nativeDestroyInTransaction },
    {"nativeGetHandle", "(J)Landroid/os/IBinder;",
            (void*)nativeGetHandle },
    {"nativeScreenshotToBuffer",
+7 −1
Original line number Diff line number Diff line
@@ -53,7 +53,8 @@ class AppWindowThumbnail implements Animatable {

    AppWindowThumbnail(Transaction t, AppWindowToken appToken, GraphicBuffer thumbnailHeader) {
        mAppToken = appToken;
        mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished, appToken.mService);
        mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished,
                appToken.mService.mAnimator::addAfterPrepareSurfacesRunnable, appToken.mService);
        mWidth = thumbnailHeader.getWidth();
        mHeight = thumbnailHeader.getHeight();

@@ -143,6 +144,11 @@ class AppWindowThumbnail implements Animatable {
        mAppToken.commitPendingTransaction();
    }

    @Override
    public void destroyAfterPendingTransaction(SurfaceControl surface) {
        mAppToken.destroyAfterPendingTransaction(surface);
    }

    @Override
    public void onAnimationLeashCreated(Transaction t, SurfaceControl leash) {
        t.setLayer(leash, Integer.MAX_VALUE);
+6 −1
Original line number Diff line number Diff line
@@ -54,6 +54,11 @@ class Dimmer {
        public void onAnimationLeashDestroyed(SurfaceControl.Transaction t) {
        }

        @Override
        public void destroyAfterPendingTransaction(SurfaceControl surface) {
            mHost.destroyAfterPendingTransaction(surface);
        }

        @Override
        public SurfaceControl.Builder makeAnimationLeash() {
            return mHost.makeAnimationLeash();
@@ -114,7 +119,7 @@ class Dimmer {
                if (!mDimming) {
                    mDimLayer.destroy();
                }
            }, mHost.mService);
            }, mHost.mService.mAnimator::addAfterPrepareSurfacesRunnable, mHost.mService);
        }
    }

+25 −1
Original line number Diff line number Diff line
@@ -380,6 +380,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
     */
    private int mSurfaceSize;

    /**
     * A list of surfaces to be destroyed after {@link #mPendingTransaction} is applied.
     */
    private final ArrayList<SurfaceControl> mPendingDestroyingSurfaces = new ArrayList<>();

    /** Temporary float array to retrieve 3x3 matrix values. */
    private final float[] mTmpFloats = new float[9];

@@ -1930,6 +1935,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                }
            }
            mService.mAnimator.removeDisplayLocked(mDisplayId);

            // The pending transaction won't be applied so we should
            // just clean up any surfaces pending destruction.
            onPendingTransactionApplied();
        } finally {
            mRemovingDisplay = false;
        }
@@ -3845,6 +3854,22 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        t.setRelativeLayer(child.getSurfaceControl(), mImeWindowsContainers.getSurfaceControl(), 1);
    }

    @Override
    public void destroyAfterPendingTransaction(SurfaceControl surface) {
        mPendingDestroyingSurfaces.add(surface);
    }

    /**
     * Destroys any surfaces that have been put into the pending list with
     * {@link #destroyAfterPendingTransaction}.
     */
    void onPendingTransactionApplied() {
        for (int i = mPendingDestroyingSurfaces.size() - 1; i >= 0; i--) {
            mPendingDestroyingSurfaces.get(i).destroy();
        }
        mPendingDestroyingSurfaces.clear();
    }

    @Override
    void prepareSurfaces() {
        final ScreenRotationAnimation screenRotationAnimation =
@@ -3859,7 +3884,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            mPendingTransaction.setAlpha(mWindowingLayer,
                    screenRotationAnimation.getEnterTransformation().getAlpha());
        }

        super.prepareSurfaces();
    }

Loading