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

Commit 0bb4ed3d authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Merge "Add a flag that excludes a SurfaceControl from caching" into udc-dev

parents 217600e3 f9c042c9
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -226,6 +226,9 @@ public final class SurfaceControl implements Parcelable {
            @DataSpace.NamedDataSpace int dataSpace);
    private static native void nativeSetExtendedRangeBrightness(long transactionObj,
            long nativeObject, float currentBufferRatio, float desiredRatio);

    private static native void nativeSetCachingHint(long transactionObj,
            long nativeObject, int cachingHint);
    private static native void nativeSetDamageRegion(long transactionObj, long nativeObject,
            Region region);
    private static native void nativeSetDimmingEnabled(long transactionObj, long nativeObject,
@@ -742,6 +745,29 @@ public final class SurfaceControl implements Parcelable {
     */
    public static final int POWER_MODE_ON_SUSPEND = 4;

    /**
     * Hint that this SurfaceControl should not participate in layer caching within SurfaceFlinger.
     *
     * A system layer may request that a layer does not participate in caching when there are known
     * quality limitations when caching via the compositor's GPU path.
     * Use only with {@link SurfaceControl.Transaction#setCachingHint}.
     * @hide
     */
    public static final int CACHING_DISABLED = 0;

    /**
     * Hint that this SurfaceControl should participate in layer caching within SurfaceFlinger.
     *
     * Use only with {@link SurfaceControl.Transaction#setCachingHint}.
     * @hide
     */
    public static final int CACHING_ENABLED = 1;

    /** @hide */
    @IntDef(flag = true, value = {CACHING_DISABLED, CACHING_ENABLED})
    @Retention(RetentionPolicy.SOURCE)
    public @interface CachingHint {}

    private void assignNativeObject(long nativeObject, String callsite) {
        if (mNativeObject != 0) {
            release();
@@ -3880,6 +3906,23 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Sets the caching hint for the layer. By default, the caching hint is
         * {@link CACHING_ENABLED}.
         *
         * @param sc The SurfaceControl to update
         * @param cachingHint The caching hint to apply to the SurfaceControl. The CachingHint is
         *                    not applied to any children of this SurfaceControl.
         * @return this
         * @hide
         */
        public @NonNull Transaction setCachingHint(
                @NonNull SurfaceControl sc, @CachingHint int cachingHint) {
            checkPreconditions(sc);
            nativeSetCachingHint(mNativeObject, sc.mNativeObject, cachingHint);
            return this;
        }

        /**
         * Sets the trusted overlay state on this SurfaceControl and it is inherited to all the
         * children. The caller must hold the ACCESS_SURFACE_FLINGER permission.
+9 −0
Original line number Diff line number Diff line
@@ -639,6 +639,13 @@ static void nativeSetExtendedRangeBrightness(JNIEnv* env, jclass clazz, jlong tr
    transaction->setExtendedRangeBrightness(ctrl, currentBufferRatio, desiredRatio);
}

static void nativeSetCachingHint(JNIEnv* env, jclass clazz, jlong transactionObj,
                                 jlong nativeObject, jint cachingHint) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
    transaction->setCachingHint(ctrl, static_cast<gui::CachingHint>(cachingHint));
}

static void nativeSetBlurRegions(JNIEnv* env, jclass clazz, jlong transactionObj,
                                 jlong nativeObject, jobjectArray regions, jint regionsLength) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -2204,6 +2211,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetDataSpace },
    {"nativeSetExtendedRangeBrightness", "(JJFF)V",
            (void*)nativeSetExtendedRangeBrightness },
            {"nativeSetCachingHint", "(JJI)V",
            (void*)nativeSetCachingHint },
    {"nativeAddWindowInfosReportedListener", "(JLjava/lang/Runnable;)V",
            (void*)nativeAddWindowInfosReportedListener },
    {"nativeGetDisplayBrightnessSupport", "(Landroid/os/IBinder;)Z",