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

Commit b5daa910 authored by Tim Murray's avatar Tim Murray
Browse files

EventThread: wake for two frames after vsync request by default

The common case seems to be that many frames are rendered in a row
before the system quiesces, but EventThread assumes that only a single
frame will be rendered after a call to requestNextVsync. This patch
moves requestNextVsync to wake for two frames by default, allowing it to
skip the EventThread wakeup when there's a pending wakeup for that
EventThread already.

Test: no EventThread wakeups from requestNextVsync in BouncyBall
bug: 169368457
Change-Id: I5cb880dad27062e158de640540a73cba59b223e5
parent d7016343
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ std::string toString(VSyncRequest request) {
            return "VSyncRequest::None";
        case VSyncRequest::Single:
            return "VSyncRequest::Single";
        case VSyncRequest::SingleSuppressCallback:
            return "VSyncRequest::SingleSuppressCallback";
        default:
            return StringPrintf("VSyncRequest::Periodic{period=%d}", vsyncPeriod(request));
    }
@@ -267,6 +269,8 @@ void EventThread::requestNextVsync(const sp<EventThreadConnection>& connection)
    if (connection->vsyncRequest == VSyncRequest::None) {
        connection->vsyncRequest = VSyncRequest::Single;
        mCondition.notify_all();
    } else if (connection->vsyncRequest == VSyncRequest::SingleSuppressCallback) {
        connection->vsyncRequest = VSyncRequest::Single;
    }
}

@@ -451,8 +455,11 @@ bool EventThread::shouldConsumeEvent(const DisplayEventReceiver::Event& event,
            switch (connection->vsyncRequest) {
                case VSyncRequest::None:
                    return false;
                case VSyncRequest::Single:
                case VSyncRequest::SingleSuppressCallback:
                    connection->vsyncRequest = VSyncRequest::None;
                    return false;
                case VSyncRequest::Single:
                    connection->vsyncRequest = VSyncRequest::SingleSuppressCallback;
                    return true;
                case VSyncRequest::Periodic:
                    return true;
+5 −2
Original line number Diff line number Diff line
@@ -50,8 +50,11 @@ class TokenManager;
using ResyncCallback = std::function<void()>;

enum class VSyncRequest {
    None = -1,
    Single = 0,
    None = -2,
    // Single wakes up for the next two frames to avoid scheduler overhead
    Single = -1,
    // SingleSuppressCallback only wakes up for the next frame
    SingleSuppressCallback = 0,
    Periodic = 1,
    // Subsequent values are periods.
};