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

Commit 271de040 authored by Alec Mouri's avatar Alec Mouri
Browse files

Receive refresh rate callbacks from DMS

AChoreographer will use DMS as the source of truth for these callbacks
instead of SurfaceFlinger.

Bug: 154874011
Test: ChoreographerNativeTest
Tes: Manually verify that HWUI is processing refresh rate callbacks
Change-Id: I961a7d1ab335800d3e260ba7564ddca9c0595cfc
parent 5a1f5498
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -75,14 +75,16 @@ AChoreographer* AChoreographer_getInstance() __INTRODUCED_IN(24);
 * Deprecated: Use AChoreographer_postFrameCallback64 instead.
 */
void AChoreographer_postFrameCallback(AChoreographer* choreographer,
        AChoreographer_frameCallback callback, void* data) __INTRODUCED_IN(24) __DEPRECATED_IN(29);
                                      AChoreographer_frameCallback callback, void* data)
        __INTRODUCED_IN(24) __DEPRECATED_IN(29);

/**
 * Deprecated: Use AChoreographer_postFrameCallbackDelayed64 instead.
 */
void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
                                             AChoreographer_frameCallback callback, void* data,
                long delayMillis) __INTRODUCED_IN(24) __DEPRECATED_IN(29);
                                             long delayMillis) __INTRODUCED_IN(24)
        __DEPRECATED_IN(29);

#endif /* __ANDROID_API__ >= 24 */

@@ -95,7 +97,8 @@ void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
 * Available since API level 29.
 */
void AChoreographer_postFrameCallback64(AChoreographer* choreographer,
                AChoreographer_frameCallback64 callback, void* data) __INTRODUCED_IN(29);
                                        AChoreographer_frameCallback64 callback, void* data)
        __INTRODUCED_IN(29);

/**
 * Post a callback to be run on the frame following the specified delay.  The
@@ -105,7 +108,8 @@ void AChoreographer_postFrameCallback64(AChoreographer* choreographer,
 * Available since API level 29.
 */
void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer,
                AChoreographer_frameCallback64 callback, void* data, uint32_t delayMillis) __INTRODUCED_IN(29);
                                               AChoreographer_frameCallback64 callback, void* data,
                                               uint32_t delayMillis) __INTRODUCED_IN(29);

#endif /* __ANDROID_API__ >= 29 */

+3 −10
Original line number Diff line number Diff line
@@ -36,10 +36,7 @@ static const size_t EVENT_BUFFER_SIZE = 100;
DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper,
                                               ISurfaceComposer::VsyncSource vsyncSource,
                                               ISurfaceComposer::ConfigChanged configChanged)
      : mLooper(looper),
        mReceiver(vsyncSource, configChanged),
        mWaitingForVsync(false),
        mConfigChangeFlag(configChanged) {
      : mLooper(looper), mReceiver(vsyncSource, configChanged), mWaitingForVsync(false) {
    ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this);
}

@@ -92,16 +89,12 @@ status_t DisplayEventDispatcher::scheduleVsync() {
    return OK;
}

void DisplayEventDispatcher::toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag) {
    if (mConfigChangeFlag == configChangeFlag) {
        return;
    }
    status_t status = mReceiver.toggleConfigEvents(configChangeFlag);
void DisplayEventDispatcher::requestLatestConfig() {
    status_t status = mReceiver.requestLatestConfig();
    if (status) {
        ALOGW("Failed enable config events, status=%d", status);
        return;
    }
    mConfigChangeFlag = configChangeFlag;
}

int DisplayEventDispatcher::getFd() const {
+2 −3
Original line number Diff line number Diff line
@@ -79,10 +79,9 @@ status_t DisplayEventReceiver::requestNextVsync() {
    return NO_INIT;
}

status_t DisplayEventReceiver::toggleConfigEvents(
        ISurfaceComposer::ConfigChanged configChangeFlag) {
status_t DisplayEventReceiver::requestLatestConfig() {
    if (mEventConnection != nullptr) {
        mEventConnection->toggleConfigEvents(configChangeFlag);
        mEventConnection->requestLatestConfig();
        return NO_ERROR;
    }
    return NO_INIT;
+7 −8
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ enum class Tag : uint32_t {
    STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION,
    SET_VSYNC_RATE,
    REQUEST_NEXT_VSYNC,
    TOGGLE_CONFIG_EVENTS,
    LAST = TOGGLE_CONFIG_EVENTS,
    REQUEST_LATEST_CONFIG,
    LAST = REQUEST_LATEST_CONFIG,
};

} // Anonymous namespace
@@ -55,10 +55,9 @@ public:
                Tag::REQUEST_NEXT_VSYNC);
    }

    void toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag) override {
        callRemoteAsync<decltype(
                &IDisplayEventConnection::toggleConfigEvents)>(Tag::TOGGLE_CONFIG_EVENTS,
                                                               configChangeFlag);
    void requestLatestConfig() override {
        callRemoteAsync<decltype(&IDisplayEventConnection::requestLatestConfig)>(
                Tag::REQUEST_LATEST_CONFIG);
    }
};

@@ -81,8 +80,8 @@ status_t BnDisplayEventConnection::onTransact(uint32_t code, const Parcel& data,
            return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate);
        case Tag::REQUEST_NEXT_VSYNC:
            return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync);
        case Tag::TOGGLE_CONFIG_EVENTS:
            return callLocalAsync(data, reply, &IDisplayEventConnection::toggleConfigEvents);
        case Tag::REQUEST_LATEST_CONFIG:
            return callLocalAsync(data, reply, &IDisplayEventConnection::requestLatestConfig);
    }
}

+1 −2
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public:
    status_t initialize();
    void dispose();
    status_t scheduleVsync();
    void toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag);
    void requestLatestConfig();
    int getFd() const;
    virtual int handleEvent(int receiveFd, int events, void* data);

@@ -42,7 +42,6 @@ private:
    sp<Looper> mLooper;
    DisplayEventReceiver mReceiver;
    bool mWaitingForVsync;
    ISurfaceComposer::ConfigChanged mConfigChangeFlag;

    virtual void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count) = 0;
    virtual void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId,
Loading