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

Commit ccb24a27 authored by Patrick Williams's avatar Patrick Williams
Browse files

Expose interface for setting stop layer

Bug: 403312802
Flag: com.android.graphics.surfaceflinger.flags.stop_layer
Test: MirrorLayerTest
Change-Id: I2b7360bc9b35ad0daebaace18e2c5696c4681d9b
parent f72d2dc9
Loading
Loading
Loading
Loading
+34 −2
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public final class SurfaceControl implements Parcelable {
    private static native void nativeDisconnect(long nativeObject);
    private static native void nativeUpdateDefaultBufferSize(long nativeObject, int width, int height);

    private static native long nativeMirrorSurface(long mirrorOfObject);
    private static native long nativeMirrorSurface(long mirrorOfObject, long stopAtObject);
    private static native long nativeCreateTransaction();
    private static native long nativeGetNativeTransactionFinalizer();
    private static native void nativeApplyTransaction(long transactionObj, boolean sync,
@@ -2774,7 +2774,39 @@ public final class SurfaceControl implements Parcelable {
     * @hide
     */
    public static SurfaceControl mirrorSurface(SurfaceControl mirrorOf) {
        long nativeObj = nativeMirrorSurface(mirrorOf.mNativeObject);
        return mirrorSurface(mirrorOf, null);
    }

    /**
     * Creates a mirrored hierarchy for the mirrorOf {@link SurfaceControl}.
     *
     * Real Hierarchy    Mirror
     *                     SC (value that's returned)
     *                      |
     *      A               A'
     *      |               |
     *      B               B'
     *
     * With stopAt specified as layer B:
     *
     * Real Hierarchy    Mirror
     *      A              SC
     *      |               |
     *      B               A'
     *      |
     *      C
     *
     * @param mirrorOf The root of the hierarchy that should be mirrored.
     * @param stopAt An optional SurfaceControl. When non-null the mirrored
     * hierarchy won't include the specified SurfaceControl or anything z-ordered
     * above it.
     * @return A SurfaceControl that's the parent of the root of the mirrored hierarchy.
     *
     * @hide
     */
    public static SurfaceControl mirrorSurface(SurfaceControl mirrorOf, SurfaceControl stopAt) {
        long stopAtObj = stopAt != null ? stopAt.mNativeObject : 0;
        long nativeObj = nativeMirrorSurface(mirrorOf.mNativeObject, stopAtObj);
        SurfaceControl sc = new SurfaceControl();
        sc.mName = mirrorOf.mName + " (mirror)";
        sc.assignNativeObject(nativeObj, "mirrorSurface");
+4 −3
Original line number Diff line number Diff line
@@ -2094,10 +2094,11 @@ static jlong nativeReadTransactionFromParcel(JNIEnv* env, jclass clazz, jobject
    return reinterpret_cast<jlong>(transaction.release());
}

static jlong nativeMirrorSurface(JNIEnv* env, jclass clazz, jlong mirrorOfObj) {
static jlong nativeMirrorSurface(JNIEnv* env, jclass clazz, jlong mirrorOfObj, jlong stopAtObj) {
    sp<SurfaceComposerClient> client = SurfaceComposerClient::getDefault();
    SurfaceControl *mirrorOf = reinterpret_cast<SurfaceControl*>(mirrorOfObj);
    sp<SurfaceControl> surface = client->mirrorSurface(mirrorOf);
    SurfaceControl* stopAt = reinterpret_cast<SurfaceControl*>(stopAtObj);
    sp<SurfaceControl> surface = client->mirrorSurface(mirrorOf, stopAt);

    surface->incStrong((void *)nativeCreate);
    return reinterpret_cast<jlong>(surface.get());
@@ -2718,7 +2719,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeWriteTransactionToParcel },
    {"nativeClearTransaction", "(J)V",
            (void*)nativeClearTransaction },
    {"nativeMirrorSurface", "(J)J",
    {"nativeMirrorSurface", "(JJ)J",
            (void*)nativeMirrorSurface },
    {"nativeSetGlobalShadowSettings", "([F[FFFF)V",
            (void*)nativeSetGlobalShadowSettings },