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

Commit 476dc9c6 authored by Rachel Lee's avatar Rachel Lee Committed by Android (Google) Code Review
Browse files

Merge "Add SurfaceControl.Transaction#setFrameRate API" into main

parents 936238b3 f10ce6c9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -52613,6 +52613,7 @@ package android.view {
    method @NonNull public android.view.SurfaceControl.Transaction setExtendedRangeBrightness(@NonNull android.view.SurfaceControl, float, float);
    method @NonNull public android.view.SurfaceControl.Transaction setFrameRate(@NonNull android.view.SurfaceControl, @FloatRange(from=0.0) float, int);
    method @NonNull public android.view.SurfaceControl.Transaction setFrameRate(@NonNull android.view.SurfaceControl, @FloatRange(from=0.0) float, int, int);
    method @FlaggedApi("com.android.graphics.surfaceflinger.flags.arr_surfacecontrol_setframerate_api") @NonNull public android.view.SurfaceControl.Transaction setFrameRate(@NonNull android.view.SurfaceControl, @NonNull android.view.Surface.FrameRateParams);
    method @FlaggedApi("com.android.window.flags.sdk_desired_present_time") @NonNull public android.view.SurfaceControl.Transaction setFrameTimeline(long);
    method @Deprecated @NonNull public android.view.SurfaceControl.Transaction setGeometry(@NonNull android.view.SurfaceControl, @Nullable android.graphics.Rect, @Nullable android.graphics.Rect, int);
    method @NonNull public android.view.SurfaceControl.Transaction setLayer(@NonNull android.view.SurfaceControl, @IntRange(from=java.lang.Integer.MIN_VALUE, to=java.lang.Integer.MAX_VALUE) int);
+46 −0
Original line number Diff line number Diff line
@@ -3918,6 +3918,52 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Sets the intended frame rate for the surface {@link SurfaceControl}.
         *
         * <p>On devices that are capable of running the display at different frame rates,
         * the system may choose a display refresh rate to better match this surface's frame
         * rate. Usage of this API won't introduce frame rate throttling, or affect other
         * aspects of the application's frame production pipeline. However, because the system
         * may change the display refresh rate, calls to this function may result in changes
         * to {@link Choreographer} callback timings, and changes to the time interval at which the
         * system releases buffers back to the application.</p>
         *
         * <p>Note that this only has an effect for surfaces presented on the display. If this
         * surface is consumed by something other than the system compositor, e.g. a media
         * codec, this call has no effect.</p>
         *
         * @param sc The SurfaceControl to specify the frame rate of.
         * @param frameRateParams The parameters describing the intended frame rate of this surface.
         *         Refer to {@link Surface.FrameRateParams} for details.
         * @return This transaction object.
         *
         * @see #clearFrameRate(SurfaceControl)
         */
        @NonNull
        @FlaggedApi(com.android.graphics.surfaceflinger.flags.Flags
                        .FLAG_ARR_SURFACECONTROL_SETFRAMERATE_API)
        public Transaction setFrameRate(@NonNull SurfaceControl sc,
                @NonNull Surface.FrameRateParams frameRateParams) {
            checkPreconditions(sc);

            if (com.android.graphics.surfaceflinger.flags.Flags.arrSetframerateApi()) {
                // TODO(b/362798998): Logic currently incomplete: it uses fixed source rate over the
                // desired min/max rates. Fix when plumbing is upgraded.
                int compatibility = frameRateParams.getFixedSourceRate() == 0
                        ? Surface.FRAME_RATE_COMPATIBILITY_DEFAULT
                        : Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
                float frameRate = compatibility == Surface.FRAME_RATE_COMPATIBILITY_DEFAULT
                        ? frameRateParams.getDesiredMinRate()
                        : frameRateParams.getFixedSourceRate();
                nativeSetFrameRate(mNativeObject, sc.mNativeObject, frameRate, compatibility,
                        frameRateParams.getChangeFrameRateStrategy());
            } else {
                Log.w(TAG, "setFrameRate was called but flag arr_setframerate_api is disabled");
            }
            return this;
        }

        /**
         * Clears the frame rate which was set for the surface {@link SurfaceControl}.
         *