Add explicit 64-bit postFrameCallback APIs
Bug: 123660572
Test: atest -a android.view.cts.ChoreographerNativeTest
Change-Id: Idff869a435ddb9b858a95993c1e4c6a5c668322f
diff --git a/native/android/choreographer.cpp b/native/android/choreographer.cpp
index 3fecd53..63e0734 100644
--- a/native/android/choreographer.cpp
+++ b/native/android/choreographer.cpp
@@ -37,6 +37,7 @@
struct FrameCallback {
AChoreographer_frameCallback callback;
+ AChoreographer_frameCallback64 callback64;
void* data;
nsecs_t dueTime;
@@ -50,8 +51,8 @@
class Choreographer : public DisplayEventDispatcher, public MessageHandler {
public:
- void postFrameCallback(AChoreographer_frameCallback cb, void* data);
- void postFrameCallbackDelayed(AChoreographer_frameCallback cb, void* data, nsecs_t delay);
+ void postFrameCallbackDelayed(AChoreographer_frameCallback cb,
+ AChoreographer_frameCallback64 cb64, void* data, nsecs_t delay);
enum {
MSG_SCHEDULE_CALLBACKS = 0,
@@ -107,14 +108,10 @@
DisplayEventDispatcher(looper), mLooper(looper), mThreadId(std::this_thread::get_id()) {
}
-void Choreographer::postFrameCallback(AChoreographer_frameCallback cb, void* data) {
- postFrameCallbackDelayed(cb, data, 0);
-}
-
void Choreographer::postFrameCallbackDelayed(
- AChoreographer_frameCallback cb, void* data, nsecs_t delay) {
+ AChoreographer_frameCallback cb, AChoreographer_frameCallback64 cb64, void* data, nsecs_t delay) {
nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
- FrameCallback callback{cb, data, now + delay};
+ FrameCallback callback{cb, cb64, data, now + delay};
{
AutoMutex _l{mLock};
mCallbacks.push(callback);
@@ -156,7 +153,11 @@
}
}
for (const auto& cb : callbacks) {
- cb.callback(timestamp, cb.data);
+ if (cb.callback64 != nullptr) {
+ cb.callback64(timestamp, cb.data);
+ } else if (cb.callback != nullptr) {
+ cb.callback(timestamp, cb.data);
+ }
}
}
@@ -204,10 +205,21 @@
void AChoreographer_postFrameCallback(AChoreographer* choreographer,
AChoreographer_frameCallback callback, void* data) {
- AChoreographer_to_Choreographer(choreographer)->postFrameCallback(callback, data);
+ AChoreographer_to_Choreographer(choreographer)->postFrameCallbackDelayed(
+ callback, nullptr, data, 0);
}
void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
AChoreographer_frameCallback callback, void* data, long delayMillis) {
AChoreographer_to_Choreographer(choreographer)->postFrameCallbackDelayed(
- callback, data, ms2ns(delayMillis));
+ callback, nullptr, data, ms2ns(delayMillis));
+}
+void AChoreographer_postFrameCallback64(AChoreographer* choreographer,
+ AChoreographer_frameCallback64 callback, void* data) {
+ AChoreographer_to_Choreographer(choreographer)->postFrameCallbackDelayed(
+ nullptr, callback, data, 0);
+}
+void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer,
+ AChoreographer_frameCallback64 callback, void* data, uint32_t delayMillis) {
+ AChoreographer_to_Choreographer(choreographer)->postFrameCallbackDelayed(
+ nullptr, callback, data, ms2ns(delayMillis));
}