summaryrefslogtreecommitdiff
path: root/include/android/choreographer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/android/choreographer.h')
-rw-r--r--include/android/choreographer.h37
1 files changed, 24 insertions, 13 deletions
diff --git a/include/android/choreographer.h b/include/android/choreographer.h
index c1c4a72cd3..b743f491e4 100644
--- a/include/android/choreographer.h
+++ b/include/android/choreographer.h
@@ -32,6 +32,11 @@
__BEGIN_DECLS
struct AChoreographer;
+/**
+ * Opaque type that provides access to an AChoreographer object.
+ *
+ * A pointer can be obtained using {@link AChoreographer_getInstance()}.
+ */
typedef struct AChoreographer AChoreographer;
/**
@@ -61,8 +66,6 @@ typedef void (*AChoreographer_frameCallback64)(int64_t frameTimeNanos, void* dat
*/
typedef void (*AChoreographer_refreshRateCallback)(int64_t vsyncPeriodNanos, void* data);
-#if __ANDROID_API__ >= 24
-
/**
* Get the AChoreographer instance for the current thread. This must be called
* on an ALooper thread.
@@ -86,10 +89,6 @@ void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
long delayMillis) __INTRODUCED_IN(24)
__DEPRECATED_IN(29);
-#endif /* __ANDROID_API__ >= 24 */
-
-#if __ANDROID_API__ >= 29
-
/**
* Power a callback to be run on the next frame. The data pointer provided will
* be passed to the callback function when it's called.
@@ -111,10 +110,6 @@ void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer,
AChoreographer_frameCallback64 callback, void* data,
uint32_t delayMillis) __INTRODUCED_IN(29);
-#endif /* __ANDROID_API__ >= 29 */
-
-#if __ANDROID_API__ >= 30
-
/**
* Registers a callback to be run when the display refresh rate changes. The
* data pointer provided will be passed to the callback function when it's
@@ -129,9 +124,23 @@ void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer,
*
* This api is thread-safe. Any thread is allowed to register a new refresh
* rate callback for the choreographer instance.
+ *
+ * Note that in API level 30, this api is not guaranteed to be atomic with
+ * DisplayManager. That is, calling Display#getRefreshRate very soon after
+ * a refresh rate callback is invoked may return a stale refresh rate. If any
+ * Display properties would be required by this callback, then it is recommended
+ * to listen directly to DisplayManager.DisplayListener#onDisplayChanged events
+ * instead.
+ *
+ * As of API level 31, this api is guaranteed to have a consistent view with DisplayManager;
+ * Display#getRefreshRate is guaranteed to not return a stale refresh rate when invoked from this
+ * callback.
+ *
+ * Available since API level 30.
*/
void AChoreographer_registerRefreshRateCallback(AChoreographer* choreographer,
- AChoreographer_refreshRateCallback, void* data);
+ AChoreographer_refreshRateCallback, void* data)
+ __INTRODUCED_IN(30);
/**
* Unregisters a callback to be run when the display refresh rate changes, along
@@ -144,10 +153,12 @@ void AChoreographer_registerRefreshRateCallback(AChoreographer* choreographer,
* callback and associated data pointer are unregistered, then there is a
* guarantee that when the unregistration completes that that callback will not
* be run with the data pointer passed.
+ *
+ * Available since API level 30.
*/
void AChoreographer_unregisterRefreshRateCallback(AChoreographer* choreographer,
- AChoreographer_refreshRateCallback, void* data);
-#endif /* __ANDROID_API__ >= 30 */
+ AChoreographer_refreshRateCallback, void* data)
+ __INTRODUCED_IN(30);
__END_DECLS