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

Commit 125072dc authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Automerger Merge Worker
Browse files

Merge "Re-apply local client state when leash changes" into rvc-dev am: 9c50a64e

Change-Id: Idbe4ab483b7cfaaf35c1af2f7b49061c6cb534cf
parents ed30ba68 9c50a64e
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -4860,7 +4860,9 @@ package android.view {
  }
  }


  public final class SurfaceControl implements android.os.Parcelable {
  public final class SurfaceControl implements android.os.Parcelable {
    ctor public SurfaceControl(@NonNull android.view.SurfaceControl);
    method public static long acquireFrameRateFlexibilityToken();
    method public static long acquireFrameRateFlexibilityToken();
    method public boolean isSameSurface(@NonNull android.view.SurfaceControl);
    method public static void releaseFrameRateFlexibilityToken(long);
    method public static void releaseFrameRateFlexibilityToken(long);
  }
  }


+8 −0
Original line number Original line Diff line number Diff line
@@ -91,6 +91,8 @@ public class InsetsSourceConsumer {
        if (mSourceControl == control) {
        if (mSourceControl == control) {
            return;
            return;
        }
        }
        SurfaceControl oldLeash = mSourceControl != null ? mSourceControl.getLeash() : null;

        final InsetsSourceControl lastControl = mSourceControl;
        final InsetsSourceControl lastControl = mSourceControl;
        mSourceControl = control;
        mSourceControl = control;


@@ -116,6 +118,12 @@ public class InsetsSourceConsumer {
                // However make sure that the leash visibility is still up to date.
                // However make sure that the leash visibility is still up to date.
                if (applyLocalVisibilityOverride()) {
                if (applyLocalVisibilityOverride()) {
                    mController.notifyVisibilityChanged();
                    mController.notifyVisibilityChanged();
                }

                // If we have a new leash, make sure visibility is up-to-date, even though we
                // didn't want to run an animation above.
                SurfaceControl newLeash = mSourceControl.getLeash();
                if (oldLeash == null || newLeash == null || !oldLeash.isSameSurface(newLeash)) {
                    applyHiddenToControl();
                    applyHiddenToControl();
                }
                }
            }
            }
+1 −2
Original line number Original line Diff line number Diff line
@@ -44,8 +44,7 @@ public class InsetsSourceControl implements Parcelable {
    public InsetsSourceControl(InsetsSourceControl other) {
    public InsetsSourceControl(InsetsSourceControl other) {
        mType = other.mType;
        mType = other.mType;
        if (other.mLeash != null) {
        if (other.mLeash != null) {
            mLeash = new SurfaceControl();
            mLeash = new SurfaceControl(other.mLeash);
            mLeash.copyFrom(other.mLeash);
        } else {
        } else {
            mLeash = null;
            mLeash = null;
        }
        }
+25 −13
Original line number Original line Diff line number Diff line
@@ -216,6 +216,7 @@ public final class SurfaceControl implements Parcelable {


    private static native void nativeSetFrameRate(
    private static native void nativeSetFrameRate(
            long transactionObj, long nativeObject, float frameRate, int compatibility);
            long transactionObj, long nativeObject, float frameRate, int compatibility);
    private static native long nativeGetHandle(long nativeObject);


    private static native long nativeAcquireFrameRateFlexibilityToken();
    private static native long nativeAcquireFrameRateFlexibilityToken();
    private static native void nativeReleaseFrameRateFlexibilityToken(long token);
    private static native void nativeReleaseFrameRateFlexibilityToken(long token);
@@ -226,6 +227,7 @@ public final class SurfaceControl implements Parcelable {
     * @hide
     * @hide
     */
     */
    public long mNativeObject;
    public long mNativeObject;
    private long mNativeHandle;


    // TODO: Move this to native.
    // TODO: Move this to native.
    private final Object mSizeLock = new Object();
    private final Object mSizeLock = new Object();
@@ -428,12 +430,13 @@ public final class SurfaceControl implements Parcelable {
            mCloseGuard.open("release");
            mCloseGuard.open("release");
        }
        }
        mNativeObject = nativeObject;
        mNativeObject = nativeObject;
        mNativeHandle = mNativeObject != 0 ? nativeGetHandle(nativeObject) : 0;
    }
    }


    /**
    /**
     * @hide
     * @hide
     */
     */
    public void copyFrom(SurfaceControl other) {
    public void copyFrom(@NonNull SurfaceControl other) {
        mName = other.mName;
        mName = other.mName;
        mWidth = other.mWidth;
        mWidth = other.mWidth;
        mHeight = other.mHeight;
        mHeight = other.mHeight;
@@ -853,23 +856,19 @@ public final class SurfaceControl implements Parcelable {
            throw new OutOfResourcesException(
            throw new OutOfResourcesException(
                    "Couldn't allocate SurfaceControl native object");
                    "Couldn't allocate SurfaceControl native object");
        }
        }

        mNativeHandle = nativeGetHandle(mNativeObject);
        mCloseGuard.open("release");
        mCloseGuard.open("release");
    }
    }


    /** This is a transfer constructor, useful for transferring a live SurfaceControl native
    /**
     * object to another Java wrapper which could have some different behavior, e.g.
     * Copy constructor. Creates a new native object pointing to the same surface as {@code other}.
     * event logging.
     *
     * @param other The object to copy the surface from.
     * @hide
     * @hide
     */
     */
    public SurfaceControl(SurfaceControl other) {
    @TestApi
        mName = other.mName;
    public SurfaceControl(@NonNull SurfaceControl other) {
        mWidth = other.mWidth;
        copyFrom(other);
        mHeight = other.mHeight;
        mNativeObject = other.mNativeObject;
        other.mCloseGuard.close();
        other.mNativeObject = 0;
        mCloseGuard.open("release");
    }
    }


    private SurfaceControl(Parcel in) {
    private SurfaceControl(Parcel in) {
@@ -920,6 +919,18 @@ public final class SurfaceControl implements Parcelable {
        }
        }
    }
    }


    /**
     * Checks whether two {@link SurfaceControl} objects represent the same surface.
     *
     * @param other The other object to check
     * @return {@code true} if these two {@link SurfaceControl} objects represent the same surface.
     * @hide
     */
    @TestApi
    public boolean isSameSurface(@NonNull SurfaceControl other) {
        return other.mNativeHandle == mNativeHandle;
    }

    /**
    /**
     * Write to a protocol buffer output stream. Protocol buffer message definition is at {@link
     * Write to a protocol buffer output stream. Protocol buffer message definition is at {@link
     * android.view.SurfaceControlProto}.
     * android.view.SurfaceControlProto}.
@@ -977,6 +988,7 @@ public final class SurfaceControl implements Parcelable {
        if (mNativeObject != 0) {
        if (mNativeObject != 0) {
            nativeRelease(mNativeObject);
            nativeRelease(mNativeObject);
            mNativeObject = 0;
            mNativeObject = 0;
            mNativeHandle = 0;
            mCloseGuard.close();
            mCloseGuard.close();
        }
        }
    }
    }
+8 −0
Original line number Original line Diff line number Diff line
@@ -1430,6 +1430,12 @@ static void nativeSetGlobalShadowSettings(JNIEnv* env, jclass clazz, jfloatArray


    client->setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ, lightRadius);
    client->setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ, lightRadius);
}
}

static jlong nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
    SurfaceControl *surfaceControl = reinterpret_cast<SurfaceControl*>(nativeObject);
    return reinterpret_cast<jlong>(surfaceControl->getHandle().get());
}

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


static const JNINativeMethod sSurfaceControlMethods[] = {
static const JNINativeMethod sSurfaceControlMethods[] = {
@@ -1606,6 +1612,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeMirrorSurface },
            (void*)nativeMirrorSurface },
    {"nativeSetGlobalShadowSettings", "([F[FFFF)V",
    {"nativeSetGlobalShadowSettings", "([F[FFFF)V",
            (void*)nativeSetGlobalShadowSettings },
            (void*)nativeSetGlobalShadowSettings },
    {"nativeGetHandle", "(J)J",
            (void*)nativeGetHandle },
};
};


int register_android_view_SurfaceControl(JNIEnv* env)
int register_android_view_SurfaceControl(JNIEnv* env)
Loading