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

Commit c9fd5fc4 authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge changes from topic "sf-remove-remove-layer"

* changes:
  SurfaceFlinger: Remove removeLayer
  Fix memory leak in SurfaceControl#copyFrom
parents 972da3c7 8810b69f
Loading
Loading
Loading
Loading
+11 −30
Original line number Diff line number Diff line
@@ -158,7 +158,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);

@@ -360,11 +359,18 @@ public class SurfaceControl implements Parcelable {
     */
    public static final int WINDOW_TYPE_DONT_SCREENSHOT = 441731;

    private void assignNativeObject(long nativeObject) {
        if (mNativeObject != 0) {
            release();
        }
        mNativeObject = nativeObject;
    }

    public void copyFrom(SurfaceControl other) {
        mName = other.mName;
        mWidth = other.mWidth;
        mHeight = other.mHeight;
        mNativeObject = nativeCopyFromSurfaceControl(other.mNativeObject);
        assignNativeObject(nativeCopyFromSurfaceControl(other.mNativeObject));
    }

    /**
@@ -685,12 +691,11 @@ public class SurfaceControl implements Parcelable {
        mWidth = in.readInt();
        mHeight = in.readInt();

        release();
        long object = 0;
        if (in.readInt() != 0) {
            mNativeObject = nativeReadFromParcel(in);
        } else {
            mNativeObject = 0;
            object = nativeReadFromParcel(in);
        }
        assignNativeObject(object);
    }

    @Override
@@ -1765,30 +1770,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();

            /**
             * Perhaps it's safer to transfer the close guard to the Transaction
             * but then we have a whole wonky scenario regarding merging, multiple
             * close-guards per transaction etc...the whole scenario is kind of wonky
             * and it seems really we'd like to just be able to call release here
             * but the WindowManager has some code that looks like
             * --- destroyInTransaction(a)
             * --- reparentChildrenInTransaction(a)
             * so we need to ensure the SC remains valid until the transaction
             * is applied.
             */
            sc.mCloseGuard.close();

            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
@@ -870,14 +870,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());
@@ -1048,8 +1040,6 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSeverChildren } ,
    {"nativeSetOverrideScalingMode", "(JJI)V",
            (void*)nativeSetOverrideScalingMode },
    {"nativeDestroy", "(JJ)V",
            (void*)nativeDestroyInTransaction },
    {"nativeGetHandle", "(J)Landroid/os/IBinder;",
            (void*)nativeGetHandle },
    {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/graphics/Rect;IIZI)Landroid/graphics/GraphicBuffer;",
+1 −1
Original line number Diff line number Diff line
@@ -2356,7 +2356,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    public void onAnimationLeashDestroyed(Transaction t) {
        super.onAnimationLeashDestroyed(t);
        if (mAnimationBoundsLayer != null) {
            t.destroy(mAnimationBoundsLayer);
            t.reparent(mAnimationBoundsLayer, null);
            mAnimationBoundsLayer = null;
        }

+2 −2
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ class Dimmer {
            final DimAnimatable dimAnimatable = new DimAnimatable(dimLayer);
            mSurfaceAnimator = new SurfaceAnimator(dimAnimatable, () -> {
                if (!mDimming) {
                    dimAnimatable.getPendingTransaction().destroy(mDimLayer);
                    dimAnimatable.getPendingTransaction().reparent(mDimLayer, null);
                }
            }, mHost.mWmService);
        }
@@ -300,7 +300,7 @@ class Dimmer {

        if (!mDimState.mDimming) {
            if (!mDimState.mAnimateExit) {
                t.destroy(mDimState.mDimLayer);
                t.reparent(mDimState.mDimLayer, null);
            } else {
                startDimExit(mLastRequestedDimContainer, mDimState.mSurfaceAnimator, t);
            }
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ class SurfaceAnimator {
        }
        mService.mAnimationTransferMap.remove(mAnimation);
        if (mLeash != null && destroyLeash) {
            t.destroy(mLeash);
            t.reparent(mLeash, null);
            scheduleAnim = true;
        }
        mLeash = null;
Loading