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

Commit 447052e2 authored by Ady Abraham's avatar Ady Abraham
Browse files

SurfaceFlinger: add DISPLAY_EVENT_CONFIG_CHANGED

Add a new event to DisplayEventReceiver for display
configuration change. This event is sent by SF when display config
is changed.

Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest
Bug: 122905403
Change-Id: Ibb7e0ce7b83b91259ccb0e9c982f5e378b0ebfaf
parent 838de062
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public:
    enum {
        DISPLAY_EVENT_VSYNC = fourcc('v', 's', 'y', 'n'),
        DISPLAY_EVENT_HOTPLUG = fourcc('p', 'l', 'u', 'g'),
        DISPLAY_EVENT_CONFIG_CHANGED = fourcc('c', 'o', 'n', 'f'),
    };

    struct Event {
@@ -70,10 +71,15 @@ public:
            bool connected;
        };

        struct Config {
            int32_t configId;
        };

        Header header;
        union {
            VSync vsync;
            Hotplug hotplug;
            Config config;
        };
    };

+15 −0
Original line number Diff line number Diff line
@@ -97,6 +97,13 @@ DisplayEventReceiver::Event makeVSync(PhysicalDisplayId displayId, nsecs_t times
    return event;
}

DisplayEventReceiver::Event makeConfigChanged(uint32_t displayId, int32_t configId) {
    DisplayEventReceiver::Event event;
    event.header = {DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED, displayId, systemTime()};
    event.config.configId = configId;
    return event;
}

} // namespace

EventThreadConnection::EventThreadConnection(EventThread* eventThread,
@@ -307,6 +314,13 @@ void EventThread::onHotplugReceived(PhysicalDisplayId displayId, bool connected)
    mCondition.notify_all();
}

void EventThread::onConfigChanged(PhysicalDisplayId displayId, int32_t configId) {
    std::lock_guard<std::mutex> lock(mMutex);

    mPendingEvents.push_back(makeConfigChanged(displayId, configId));
    mCondition.notify_all();
}

void EventThread::threadMain(std::unique_lock<std::mutex>& lock) {
    DisplayEventConsumers consumers;

@@ -404,6 +418,7 @@ bool EventThread::shouldConsumeEvent(const DisplayEventReceiver::Event& event,
                                     const sp<EventThreadConnection>& connection) const {
    switch (event.header.type) {
        case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG:
        case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED:
            return true;

        case DisplayEventReceiver::DISPLAY_EVENT_VSYNC:
+5 −0
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@ public:

    virtual void onHotplugReceived(PhysicalDisplayId displayId, bool connected) = 0;

    // called when SF changes the active config and apps needs to be notified about the change
    virtual void onConfigChanged(PhysicalDisplayId displayId, int32_t configId) = 0;

    virtual void dump(std::string& result) const = 0;

    virtual void setPhaseOffset(nsecs_t phaseOffset) = 0;
@@ -153,6 +156,8 @@ public:

    void onHotplugReceived(PhysicalDisplayId displayId, bool connected) override;

    void onConfigChanged(PhysicalDisplayId displayId, int32_t configId) override;

    void dump(std::string& result) const override;

    void setPhaseOffset(nsecs_t phaseOffset) override;
+6 −0
Original line number Diff line number Diff line
@@ -153,6 +153,12 @@ void Scheduler::onScreenReleased(const sp<Scheduler::ConnectionHandle>& handle)
    mConnections[handle->id]->thread->onScreenReleased();
}

void Scheduler::onConfigChanged(const sp<ConnectionHandle>& handle, PhysicalDisplayId displayId,
                                int32_t configId) {
    RETURN_IF_INVALID();
    mConnections[handle->id]->thread->onConfigChanged(displayId, configId);
}

void Scheduler::dump(const sp<Scheduler::ConnectionHandle>& handle, std::string& result) const {
    RETURN_IF_INVALID();
    mConnections.at(handle->id)->thread->dump(result);
+4 −0
Original line number Diff line number Diff line
@@ -105,6 +105,10 @@ public:
    // Should be called before the screen is turned off.
    void onScreenReleased(const sp<ConnectionHandle>& handle);

    // Should be called when display config changed
    void onConfigChanged(const sp<ConnectionHandle>& handle, PhysicalDisplayId displayId,
                         int32_t configId);

    // Should be called when dumpsys command is received.
    void dump(const sp<ConnectionHandle>& handle, std::string& result) const;

Loading