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

Commit 10584fa9 authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceControl: Accept instance rather than handle for reparent

In preparation for public API.

Bug: 111297488
Test: Builds.
Change-Id: I80da54d92989ec0afe9fcdde324847f0de0c5083
parent c2888cbc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public class ActivityView extends ViewGroup {
                }
            } else {
                mTmpTransaction.reparent(mRootSurfaceControl,
                        mSurfaceView.getSurfaceControl().getHandle()).apply();
                        mSurfaceView.getSurfaceControl()).apply();
            }

            if (mVirtualDisplay != null) {
@@ -390,7 +390,7 @@ public class ActivityView extends ViewGroup {
                .build();

        try {
            wm.reparentDisplayContent(displayId, mRootSurfaceControl.getHandle());
            wm.reparentDisplayContent(displayId, mRootSurfaceControl);
            wm.dontOverrideDisplayInfo(displayId);
            if (mSingleTaskInstance) {
                mActivityTaskManager.setDisplayToSingleTaskInstance(displayId);
+3 −2
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.view.IInputFilter;
import android.view.AppTransitionAnimationSpec;
import android.view.WindowContentFrameStats;
import android.view.WindowManager;
import android.view.SurfaceControl;

/**
 * System private interface to the window manager.
@@ -555,8 +556,8 @@ interface IWindowManager
     * display content info to any SurfaceControl, as this would be a security issue.
     *
     * @param displayId The id of the display.
     * @param surfaceControlHandle The SurfaceControl handle that the top level layers for the
     * @param surfaceControlHandle The SurfaceControl that the top level layers for the
     *        display should be re-parented to.
     */
    void reparentDisplayContent(int displayId, in IBinder surfaceControlHandle);
    void reparentDisplayContent(int displayId, in SurfaceControl sc);
}
+18 −8
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ public class SurfaceControl implements Parcelable {
    private static native void nativeReparentChildren(long transactionObj, long nativeObject,
            IBinder handle);
    private static native void nativeReparent(long transactionObj, long nativeObject,
            IBinder parentHandle);
            long newParentNativeObject);
    private static native void nativeSeverChildren(long transactionObj, long nativeObject);
    private static native void nativeSetOverrideScalingMode(long transactionObj, long nativeObject,
            int scalingMode);
@@ -962,9 +962,9 @@ public class SurfaceControl implements Parcelable {
    /**
     * @hide
     */
    public void reparent(IBinder newParentHandle) {
    public void reparent(SurfaceControl newParent) {
        synchronized(SurfaceControl.class) {
            sGlobalTransaction.reparent(this, newParentHandle);
            sGlobalTransaction.reparent(this, newParent);
        }
    }

@@ -2071,13 +2071,23 @@ public class SurfaceControl implements Parcelable {
            return this;
        }

        /** Re-parents a specific child layer to a new parent 
         * @hide
        /**
         * Re-parents a given layer to a new parent. Children inherit transform (position, scaling)
         * crop, visibility, and Z-ordering from their parents, as if the children were pixels within the
         * parent Surface.
         *
         * @param sc The SurfaceControl to reparent
         * @param newParent The new parent for the given control.
         * @return This Transaction
         */
        public Transaction reparent(SurfaceControl sc, IBinder newParentHandle) {
        public Transaction reparent(SurfaceControl sc, SurfaceControl newParent) {
            sc.checkNotReleased();
            nativeReparent(mNativeObject, sc.mNativeObject,
                    newParentHandle);
            long otherObject = 0;
            if (newParent != null) {
                newParent.checkNotReleased();
                otherObject = newParent.mNativeObject;
            }
            nativeReparent(mNativeObject, sc.mNativeObject, otherObject);
            return this;
        }

+4 −4
Original line number Diff line number Diff line
@@ -868,13 +868,13 @@ static void nativeReparentChildren(JNIEnv* env, jclass clazz, jlong transactionO

static void nativeReparent(JNIEnv* env, jclass clazz, jlong transactionObj,
        jlong nativeObject,
        jobject newParentObject) {
        jlong newParentObject) {
    auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    sp<IBinder> parentHandle = ibinderForJavaObject(env, newParentObject);
    auto newParent = reinterpret_cast<SurfaceControl *>(newParentObject);

    {
        auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
        transaction->reparent(ctrl, parentHandle);
        transaction->reparent(ctrl, newParent != NULL ? newParent->getHandle() : NULL);
    }
}

@@ -1063,7 +1063,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeDeferTransactionUntilSurface },
    {"nativeReparentChildren", "(JJLandroid/os/IBinder;)V",
            (void*)nativeReparentChildren } ,
    {"nativeReparent", "(JJLandroid/os/IBinder;)V",
    {"nativeReparent", "(JJJ)V",
            (void*)nativeReparent },
    {"nativeSeverChildren", "(JJ)V",
            (void*)nativeSeverChildren } ,
+2 −2
Original line number Diff line number Diff line
@@ -2407,7 +2407,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    @Override
    protected void reparentSurfaceControl(Transaction t, SurfaceControl newParent) {
        if (!mSurfaceAnimator.hasLeash()) {
            t.reparent(mSurfaceControl, newParent.getHandle());
            t.reparent(mSurfaceControl, newParent);
        }
    }

@@ -2453,7 +2453,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
            t.setWindowCrop(mAnimationBoundsLayer, mTmpRect);

            // Reparent leash to animation bounds layer.
            t.reparent(leash, mAnimationBoundsLayer.getHandle());
            t.reparent(leash, mAnimationBoundsLayer);
        }
    }

Loading