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

Commit 2fbf90c6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add explicit 64-bit postFrameCallback APIs"

parents a7010101 458d3df2
Loading
Loading
Loading
Loading
+23 −11
Original line number Diff line number Diff line
@@ -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,9 +153,13 @@ void Choreographer::dispatchVsync(nsecs_t timestamp, PhysicalDisplayId, uint32_t
        }
    }
    for (const auto& cb : callbacks) {
        if (cb.callback64 != nullptr) {
            cb.callback64(timestamp, cb.data);
        } else if (cb.callback != nullptr) {
            cb.callback(timestamp, cb.data);
        }
    }
}

void Choreographer::dispatchHotplug(nsecs_t, PhysicalDisplayId displayId, bool connected) {
    ALOGV("choreographer %p ~ received hotplug event (displayId=%"
@@ -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));
}
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ LIBANDROID {
    AChoreographer_getInstance; # introduced=24
    AChoreographer_postFrameCallback; # introduced=24
    AChoreographer_postFrameCallbackDelayed; # introduced=24
    AChoreographer_postFrameCallback64; # introduced=29
    AChoreographer_postFrameCallbackDelayed64; # introduced=29
    AConfiguration_copy;
    AConfiguration_delete;
    AConfiguration_diff;