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

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

Merge changes from topic "sc-destruction-cleanup"

* changes:
  SurfaceControl: Provide Transaction#remove() method.
  Replace SurfaceControl#destroy with #remove
  SurfaceControl: Fix release
parents e27f8dab 71200f2c
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -852,12 +852,11 @@ public final class SurfaceControl implements Parcelable {
    }

    /**
     * Free all server-side state associated with this surface and
     * release this object's reference.  This method can only be
     * called from the process that created the service.
     * Release the local resources like {@link #release} but also
     * remove the Surface from the screen.
     * @hide
     */
    public void destroy() {
    public void remove() {
        if (mNativeObject != 0) {
            nativeDestroy(mNativeObject);
            mNativeObject = 0;
@@ -2467,5 +2466,23 @@ public final class SurfaceControl implements Parcelable {
            nativeMergeTransaction(mNativeObject, other.mNativeObject);
            return this;
        }

        /**
         * Equivalent to reparent with a null parent, in that it removes
         * the SurfaceControl from the scene, but it also releases
         * the local resources (by calling {@link SurfaceControl#release})
         * after this method returns, {@link SurfaceControl#isValid} will return
         * false for the argument.
         *
         * @param sc The surface to remove and release.
         * @return This transaction
         * @hide
         */
        @NonNull
        public Transaction remove(@NonNull SurfaceControl sc) {
            reparent(sc, null);
            sc.release();
            return this;
        }
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -334,7 +334,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb

        updateSurface();
        if (mSurfaceControl != null) {
            mSurfaceControl.destroy();
            mSurfaceControl.remove();
        }
        mSurfaceControl = null;

@@ -502,11 +502,11 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb

    private void releaseSurfaces() {
        if (mSurfaceControl != null) {
            mSurfaceControl.destroy();
            mSurfaceControl.remove();
            mSurfaceControl = null;
        }
        if (mBackgroundControl != null) {
            mBackgroundControl.destroy();
            mBackgroundControl.remove();
            mBackgroundControl = null;
        }
    }
@@ -816,7 +816,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
        }

        if (mDeferredDestroySurfaceControl != null) {
            mDeferredDestroySurfaceControl.destroy();
            mDeferredDestroySurfaceControl.remove();
            mDeferredDestroySurfaceControl = null;
        }

+1 −1
Original line number Diff line number Diff line
@@ -1603,7 +1603,7 @@ public final class ViewRootImpl implements ViewParent,
        mSurfaceSession = null;

        if (mBoundsSurfaceControl != null) {
            mBoundsSurfaceControl.destroy();
            mBoundsSurfaceControl.remove();
            mBoundsSurface.release();
            mBoundsSurfaceControl = null;
        }
+1 −1
Original line number Diff line number Diff line
@@ -1013,7 +1013,7 @@ public final class Magnifier {
            }
            synchronized (mLock) {
                mRenderer.destroy();
                mSurfaceControl.destroy();
                mSurfaceControl.remove();
                mSurfaceSession.kill();
                mHandler.removeCallbacks(mMagnifierUpdater);
                if (mBitmap != null) {
+2 −1
Original line number Diff line number Diff line
@@ -178,12 +178,13 @@ static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,

static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
    sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
    ctrl->release();
    ctrl->decStrong((void *)nativeCreate);
}

static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
    sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
    ctrl->clear();
    ctrl->destroy();
    ctrl->decStrong((void *)nativeCreate);
}

Loading