Loading libs/gui/DisplayEventDispatcher.cpp +17 −2 Original line number Original line Diff line number Diff line Loading @@ -36,7 +36,10 @@ static const size_t EVENT_BUFFER_SIZE = 100; DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper, DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::ConfigChanged configChanged) ISurfaceComposer::ConfigChanged configChanged) : mLooper(looper), mReceiver(vsyncSource, configChanged), mWaitingForVsync(false) { : mLooper(looper), mReceiver(vsyncSource, configChanged), mWaitingForVsync(false), mConfigChangeFlag(configChanged) { ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); } } Loading Loading @@ -86,6 +89,18 @@ status_t DisplayEventDispatcher::scheduleVsync() { return OK; return OK; } } void DisplayEventDispatcher::toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag) { if (mConfigChangeFlag == configChangeFlag) { return; } status_t status = mReceiver.toggleConfigEvents(configChangeFlag); if (status) { ALOGW("Failed enable config events, status=%d", status); return; } mConfigChangeFlag = configChangeFlag; } int DisplayEventDispatcher::handleEvent(int, int events, void*) { int DisplayEventDispatcher::handleEvent(int, int events, void*) { if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) { if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) { ALOGE("Display event receiver pipe was closed or an error occurred. " ALOGE("Display event receiver pipe was closed or an error occurred. " Loading Loading @@ -140,7 +155,7 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, break; break; case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, ev.config.configId); ev.config.configId, ev.config.vsyncPeriod); break; break; default: default: ALOGW("dispatcher %p ~ ignoring unknown event type %#x", this, ev.header.type); ALOGW("dispatcher %p ~ ignoring unknown event type %#x", this, ev.header.type); Loading libs/gui/DisplayEventReceiver.cpp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -79,6 +79,14 @@ status_t DisplayEventReceiver::requestNextVsync() { return NO_INIT; return NO_INIT; } } status_t DisplayEventReceiver::toggleConfigEvents( ISurfaceComposer::ConfigChanged configChangeFlag) { if (mEventConnection != nullptr) { mEventConnection->toggleConfigEvents(configChangeFlag); return NO_ERROR; } return NO_INIT; } ssize_t DisplayEventReceiver::getEvents(DisplayEventReceiver::Event* events, ssize_t DisplayEventReceiver::getEvents(DisplayEventReceiver::Event* events, size_t count) { size_t count) { Loading libs/gui/IDisplayEventConnection.cpp +10 −1 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,8 @@ enum class Tag : uint32_t { STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION, STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION, SET_VSYNC_RATE, SET_VSYNC_RATE, REQUEST_NEXT_VSYNC, REQUEST_NEXT_VSYNC, LAST = REQUEST_NEXT_VSYNC, TOGGLE_CONFIG_EVENTS, LAST = TOGGLE_CONFIG_EVENTS, }; }; } // Anonymous namespace } // Anonymous namespace Loading @@ -53,6 +54,12 @@ public: callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( Tag::REQUEST_NEXT_VSYNC); Tag::REQUEST_NEXT_VSYNC); } } void toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag) override { callRemoteAsync<decltype( &IDisplayEventConnection::toggleConfigEvents)>(Tag::TOGGLE_CONFIG_EVENTS, configChangeFlag); } }; }; // Out-of-line virtual method definition to trigger vtable emission in this translation unit (see // Out-of-line virtual method definition to trigger vtable emission in this translation unit (see Loading @@ -74,6 +81,8 @@ status_t BnDisplayEventConnection::onTransact(uint32_t code, const Parcel& data, return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate); return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate); case Tag::REQUEST_NEXT_VSYNC: case Tag::REQUEST_NEXT_VSYNC: return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync); return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync); case Tag::TOGGLE_CONFIG_EVENTS: return callLocalAsync(data, reply, &IDisplayEventConnection::toggleConfigEvents); } } } } Loading libs/gui/include/gui/DisplayEventDispatcher.h +3 −1 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ public: status_t initialize(); status_t initialize(); void dispose(); void dispose(); status_t scheduleVsync(); status_t scheduleVsync(); void toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag); protected: protected: virtual ~DisplayEventDispatcher() = default; virtual ~DisplayEventDispatcher() = default; Loading @@ -39,12 +40,13 @@ private: sp<Looper> mLooper; sp<Looper> mLooper; DisplayEventReceiver mReceiver; DisplayEventReceiver mReceiver; bool mWaitingForVsync; bool mWaitingForVsync; ISurfaceComposer::ConfigChanged mConfigChangeFlag; virtual void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count) = 0; virtual void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count) = 0; virtual void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, virtual void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, bool connected) = 0; bool connected) = 0; virtual void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId, virtual void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId, int32_t configId) = 0; int32_t configId, nsecs_t vsyncPeriod) = 0; virtual int handleEvent(int receiveFd, int events, void* data); virtual int handleEvent(int receiveFd, int events, void* data); bool processPendingEvents(nsecs_t* outTimestamp, PhysicalDisplayId* outDisplayId, bool processPendingEvents(nsecs_t* outTimestamp, PhysicalDisplayId* outDisplayId, Loading libs/gui/include/gui/DisplayEventReceiver.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -73,6 +73,7 @@ public: struct Config { struct Config { int32_t configId; int32_t configId; nsecs_t vsyncPeriod; }; }; Header header; Header header; Loading Loading @@ -144,6 +145,11 @@ public: */ */ status_t requestNextVsync(); status_t requestNextVsync(); /* * toggleConfigEvents() toggles delivery of config change events. */ status_t toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag); private: private: sp<IDisplayEventConnection> mEventConnection; sp<IDisplayEventConnection> mEventConnection; std::unique_ptr<gui::BitTube> mDataChannel; std::unique_ptr<gui::BitTube> mDataChannel; Loading Loading
libs/gui/DisplayEventDispatcher.cpp +17 −2 Original line number Original line Diff line number Diff line Loading @@ -36,7 +36,10 @@ static const size_t EVENT_BUFFER_SIZE = 100; DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper, DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::VsyncSource vsyncSource, ISurfaceComposer::ConfigChanged configChanged) ISurfaceComposer::ConfigChanged configChanged) : mLooper(looper), mReceiver(vsyncSource, configChanged), mWaitingForVsync(false) { : mLooper(looper), mReceiver(vsyncSource, configChanged), mWaitingForVsync(false), mConfigChangeFlag(configChanged) { ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this); } } Loading Loading @@ -86,6 +89,18 @@ status_t DisplayEventDispatcher::scheduleVsync() { return OK; return OK; } } void DisplayEventDispatcher::toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag) { if (mConfigChangeFlag == configChangeFlag) { return; } status_t status = mReceiver.toggleConfigEvents(configChangeFlag); if (status) { ALOGW("Failed enable config events, status=%d", status); return; } mConfigChangeFlag = configChangeFlag; } int DisplayEventDispatcher::handleEvent(int, int events, void*) { int DisplayEventDispatcher::handleEvent(int, int events, void*) { if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) { if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) { ALOGE("Display event receiver pipe was closed or an error occurred. " ALOGE("Display event receiver pipe was closed or an error occurred. " Loading Loading @@ -140,7 +155,7 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, break; break; case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, ev.config.configId); ev.config.configId, ev.config.vsyncPeriod); break; break; default: default: ALOGW("dispatcher %p ~ ignoring unknown event type %#x", this, ev.header.type); ALOGW("dispatcher %p ~ ignoring unknown event type %#x", this, ev.header.type); Loading
libs/gui/DisplayEventReceiver.cpp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -79,6 +79,14 @@ status_t DisplayEventReceiver::requestNextVsync() { return NO_INIT; return NO_INIT; } } status_t DisplayEventReceiver::toggleConfigEvents( ISurfaceComposer::ConfigChanged configChangeFlag) { if (mEventConnection != nullptr) { mEventConnection->toggleConfigEvents(configChangeFlag); return NO_ERROR; } return NO_INIT; } ssize_t DisplayEventReceiver::getEvents(DisplayEventReceiver::Event* events, ssize_t DisplayEventReceiver::getEvents(DisplayEventReceiver::Event* events, size_t count) { size_t count) { Loading
libs/gui/IDisplayEventConnection.cpp +10 −1 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,8 @@ enum class Tag : uint32_t { STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION, STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION, SET_VSYNC_RATE, SET_VSYNC_RATE, REQUEST_NEXT_VSYNC, REQUEST_NEXT_VSYNC, LAST = REQUEST_NEXT_VSYNC, TOGGLE_CONFIG_EVENTS, LAST = TOGGLE_CONFIG_EVENTS, }; }; } // Anonymous namespace } // Anonymous namespace Loading @@ -53,6 +54,12 @@ public: callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( Tag::REQUEST_NEXT_VSYNC); Tag::REQUEST_NEXT_VSYNC); } } void toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag) override { callRemoteAsync<decltype( &IDisplayEventConnection::toggleConfigEvents)>(Tag::TOGGLE_CONFIG_EVENTS, configChangeFlag); } }; }; // Out-of-line virtual method definition to trigger vtable emission in this translation unit (see // Out-of-line virtual method definition to trigger vtable emission in this translation unit (see Loading @@ -74,6 +81,8 @@ status_t BnDisplayEventConnection::onTransact(uint32_t code, const Parcel& data, return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate); return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate); case Tag::REQUEST_NEXT_VSYNC: case Tag::REQUEST_NEXT_VSYNC: return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync); return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync); case Tag::TOGGLE_CONFIG_EVENTS: return callLocalAsync(data, reply, &IDisplayEventConnection::toggleConfigEvents); } } } } Loading
libs/gui/include/gui/DisplayEventDispatcher.h +3 −1 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ public: status_t initialize(); status_t initialize(); void dispose(); void dispose(); status_t scheduleVsync(); status_t scheduleVsync(); void toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag); protected: protected: virtual ~DisplayEventDispatcher() = default; virtual ~DisplayEventDispatcher() = default; Loading @@ -39,12 +40,13 @@ private: sp<Looper> mLooper; sp<Looper> mLooper; DisplayEventReceiver mReceiver; DisplayEventReceiver mReceiver; bool mWaitingForVsync; bool mWaitingForVsync; ISurfaceComposer::ConfigChanged mConfigChangeFlag; virtual void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count) = 0; virtual void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count) = 0; virtual void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, virtual void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, bool connected) = 0; bool connected) = 0; virtual void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId, virtual void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId, int32_t configId) = 0; int32_t configId, nsecs_t vsyncPeriod) = 0; virtual int handleEvent(int receiveFd, int events, void* data); virtual int handleEvent(int receiveFd, int events, void* data); bool processPendingEvents(nsecs_t* outTimestamp, PhysicalDisplayId* outDisplayId, bool processPendingEvents(nsecs_t* outTimestamp, PhysicalDisplayId* outDisplayId, Loading
libs/gui/include/gui/DisplayEventReceiver.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -73,6 +73,7 @@ public: struct Config { struct Config { int32_t configId; int32_t configId; nsecs_t vsyncPeriod; }; }; Header header; Header header; Loading Loading @@ -144,6 +145,11 @@ public: */ */ status_t requestNextVsync(); status_t requestNextVsync(); /* * toggleConfigEvents() toggles delivery of config change events. */ status_t toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag); private: private: sp<IDisplayEventConnection> mEventConnection; sp<IDisplayEventConnection> mEventConnection; std::unique_ptr<gui::BitTube> mDataChannel; std::unique_ptr<gui::BitTube> mDataChannel; Loading