diff options
author | Santos Cordon <santoscordon@google.com> | 2019-02-20 18:09:00 +0000 |
---|---|---|
committer | Santos Cordon <santoscordon@google.com> | 2019-03-06 16:24:55 +0000 |
commit | 458d3df21f49df7b14a7040e0a56441c32e9bd21 (patch) | |
tree | 909dfde2be899a7602ce98366dbac7252523c5b5 /native/android/choreographer.cpp | |
parent | 4fa13a19e447c1ef8111c751779ea63e9c12849b (diff) |
Add explicit 64-bit postFrameCallback APIs
Bug: 123660572
Test: atest -a android.view.cts.ChoreographerNativeTest
Change-Id: Idff869a435ddb9b858a95993c1e4c6a5c668322f
Diffstat (limited to 'native/android/choreographer.cpp')
-rw-r--r-- | native/android/choreographer.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/native/android/choreographer.cpp b/native/android/choreographer.cpp index 3fecd53b43e2..63e073405fe0 100644 --- a/native/android/choreographer.cpp +++ b/native/android/choreographer.cpp @@ -37,6 +37,7 @@ static inline const char* toString(bool value) { struct FrameCallback { AChoreographer_frameCallback callback; + AChoreographer_frameCallback64 callback64; void* data; nsecs_t dueTime; @@ -50,8 +51,8 @@ struct FrameCallback { 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 @@ Choreographer::Choreographer(const sp<Looper>& looper) : 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 @@ void Choreographer::dispatchVsync(nsecs_t timestamp, PhysicalDisplayId, uint32_t } } 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 @@ AChoreographer* AChoreographer_getInstance() { 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)); } |