3333#ifndef ANDROID_NATIVE_WINDOW_H
3434#define ANDROID_NATIVE_WINDOW_H
3535
36- #include <stdint.h>
3736#include <stdbool.h>
37+ #include <stdint.h>
3838#include <sys/cdefs.h>
3939
4040#include <android/data_space.h>
@@ -282,7 +282,7 @@ int32_t ANativeWindow_setFrameRate(ANativeWindow* window, float frameRate, int8_
282282void ANativeWindow_tryAllocateBuffers (ANativeWindow * window ) __INTRODUCED_IN (30 );
283283
284284/** Change frame rate strategy value for ANativeWindow_setFrameRate. */
285- enum ANativeWindow_ChangeFrameRateStrategy {
285+ typedef enum ANativeWindow_ChangeFrameRateStrategy : int8_t {
286286 /**
287287 * Change the frame rate only if the transition is going to be seamless.
288288 */
@@ -292,7 +292,7 @@ enum ANativeWindow_ChangeFrameRateStrategy {
292292 * i.e. with visual interruptions for the user.
293293 */
294294 ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS = 1
295- } __INTRODUCED_IN (31 );
295+ } ANativeWindow_ChangeFrameRateStrategy __INTRODUCED_IN (31 );
296296
297297/**
298298 * Sets the intended frame rate for this window.
@@ -344,6 +344,76 @@ int32_t ANativeWindow_setFrameRateWithChangeStrategy(ANativeWindow* window, floa
344344 int8_t compatibility , int8_t changeFrameRateStrategy )
345345 __INTRODUCED_IN (31 );
346346
347+ /**
348+ * Sets the intended frame rate for this window.
349+ *
350+ * On devices that are capable of running the display at different frame rates,
351+ * the system may choose a display refresh rate to better match this surface's frame
352+ * rate. Usage of this API won't introduce frame rate throttling, or affect other
353+ * aspects of the application's frame production pipeline. However, because the system
354+ * may change the display refresh rate, calls to this function may result in changes
355+ * to Choreographer callback timings, and changes to the time interval at which the
356+ * system releases buffers back to the application.
357+ *
358+ * Note that this only has an effect for surfaces presented on the display. If this
359+ * surface is consumed by something other than the system compositor, e.g. a media
360+ * codec, this call has no effect.
361+ *
362+ * You can register for changes in the refresh rate using
363+ * \a AChoreographer_registerRefreshRateCallback.
364+ *
365+ * See ANativeWindow_clearFrameRate().
366+ *
367+ * Available since API level 36.
368+ *
369+ * \param window pointer to an ANativeWindow object.
370+ *
371+ * \param desiredMinRate The desired minimum frame rate (inclusive) for the window, specifying that
372+ * the surface prefers the device render rate to be at least `desiredMinRate`.
373+ *
374+ * <p>Set `desiredMinRate` = `desiredMaxRate` to indicate the surface prefers an exact frame rate.
375+ *
376+ * <p>Set `desiredMinRate` = 0 to indicate the window has no preference
377+ * and any frame rate is acceptable.
378+ *
379+ * <p>The value should be greater than or equal to 0.
380+ *
381+ * \param desiredMaxRate The desired maximum frame rate (inclusive) for the window, specifying that
382+ * the surface prefers the device render rate to be at most `desiredMaxRate`.
383+ *
384+ * <p>Set `desiredMaxRate` = `desiredMinRate` to indicate the surface prefers an exact frame rate.
385+ *
386+ * <p>Set `desiredMaxRate` = positive infinity to indicate the window has no preference
387+ * and any frame rate is acceptable.
388+ *
389+ * <p>The value should be greater than or equal to `desiredMinRate`.
390+ *
391+ * \param fixedSourceRate The "fixed source" frame rate of the window if the content has an
392+ * inherently fixed frame rate, e.g. a video that has a specific frame rate.
393+ *
394+ * <p>When the frame rate chosen for the surface is the `fixedSourceRate` or a
395+ * multiple, the surface can render without frame pulldown, for optimal smoothness. For
396+ * example, a 30 fps video (`fixedSourceRate`=30) renders just as smoothly on 30 fps,
397+ * 60 fps, 90 fps, 120 fps, and so on.
398+ *
399+ * <p>Setting the fixed source rate can also be used together with a desired
400+ * frame rate min and max via setting `desiredMinRate` and `desiredMaxRate`. This still
401+ * means the window's content has a fixed frame rate of `fixedSourceRate`, but additionally
402+ * specifies the preference to be in the range [`desiredMinRate`, `desiredMaxRate`]. For example, an
403+ * app might want to specify there is 30 fps video (`fixedSourceRate`=30) as well as a smooth
404+ * animation on the same window which looks good when drawing within a frame rate range such as
405+ * [`desiredMinRate`, `desiredMaxRate`] = [60,120].
406+ *
407+ * \param changeFrameRateStrategy Whether display refresh rate transitions caused by this surface
408+ * should be seamless. A seamless transition is one that doesn't have any visual interruptions, such
409+ * as a black screen for a second or two.
410+ *
411+ * \return 0 for success, -EINVAL if the arguments are invalid.
412+ */
413+ int32_t ANativeWindow_setFrameRateParams (
414+ ANativeWindow * window , float desiredMinRate , float desiredMaxRate , float fixedSourceRate ,
415+ ANativeWindow_ChangeFrameRateStrategy changeFrameRateStrategy ) __INTRODUCED_IN (36 );
416+
347417/**
348418 * Clears the frame rate which is set for this window.
349419 *
0 commit comments