Loading libs/gui/BitTube.cpp +16 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,10 @@ void BitTube::setReceiveFd(base::unique_fd&& receiveFd) { mReceiveFd = std::move(receiveFd); mReceiveFd = std::move(receiveFd); } } void BitTube::setSendFd(base::unique_fd&& sendFd) { mSendFd = std::move(sendFd); } ssize_t BitTube::write(void const* vaddr, size_t size) { ssize_t BitTube::write(void const* vaddr, size_t size) { ssize_t err, len; ssize_t err, len; do { do { Loading Loading @@ -115,6 +119,11 @@ status_t BitTube::writeToParcel(Parcel* reply) const { status_t result = reply->writeDupFileDescriptor(mReceiveFd); status_t result = reply->writeDupFileDescriptor(mReceiveFd); mReceiveFd.reset(); mReceiveFd.reset(); if (result != NO_ERROR) { return result; } result = reply->writeDupFileDescriptor(mSendFd); mSendFd.reset(); return result; return result; } } Loading @@ -126,6 +135,13 @@ status_t BitTube::readFromParcel(const Parcel* parcel) { ALOGE("BitTube::readFromParcel: can't dup file descriptor (%s)", strerror(error)); ALOGE("BitTube::readFromParcel: can't dup file descriptor (%s)", strerror(error)); return -error; return -error; } } mSendFd.reset(dup(parcel->readFileDescriptor())); if (mSendFd < 0) { mSendFd.reset(); int error = errno; ALOGE("BitTube::readFromParcel: can't dup file descriptor (%s)", strerror(error)); return -error; } return NO_ERROR; return NO_ERROR; } } Loading libs/gui/DisplayEventDispatcher.cpp +6 −6 Original line number Original line Diff line number Diff line Loading @@ -89,12 +89,8 @@ status_t DisplayEventDispatcher::scheduleVsync() { return OK; return OK; } } void DisplayEventDispatcher::requestLatestConfig() { void DisplayEventDispatcher::injectEvent(const DisplayEventReceiver::Event& event) { status_t status = mReceiver.requestLatestConfig(); mReceiver.sendEvents(&event, 1); if (status) { ALOGW("Failed enable config events, status=%d", status); return; } } } int DisplayEventDispatcher::getFd() const { int DisplayEventDispatcher::getFd() const { Loading Loading @@ -157,6 +153,9 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, ev.config.configId, ev.config.vsyncPeriod); ev.config.configId, ev.config.vsyncPeriod); break; break; case DisplayEventReceiver::DISPLAY_EVENT_NULL: dispatchNullEvent(ev.header.timestamp, ev.header.displayId); 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); break; break; Loading @@ -168,4 +167,5 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, } } return gotVsync; return gotVsync; } } } // namespace android } // namespace android libs/gui/DisplayEventReceiver.cpp +4 −8 Original line number Original line Diff line number Diff line Loading @@ -79,14 +79,6 @@ status_t DisplayEventReceiver::requestNextVsync() { return NO_INIT; return NO_INIT; } } status_t DisplayEventReceiver::requestLatestConfig() { if (mEventConnection != nullptr) { mEventConnection->requestLatestConfig(); 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) { return DisplayEventReceiver::getEvents(mDataChannel.get(), events, count); return DisplayEventReceiver::getEvents(mDataChannel.get(), events, count); Loading @@ -98,6 +90,10 @@ ssize_t DisplayEventReceiver::getEvents(gui::BitTube* dataChannel, return gui::BitTube::recvObjects(dataChannel, events, count); return gui::BitTube::recvObjects(dataChannel, events, count); } } ssize_t DisplayEventReceiver::sendEvents(Event const* events, size_t count) { return DisplayEventReceiver::sendEvents(mDataChannel.get(), events, count); } ssize_t DisplayEventReceiver::sendEvents(gui::BitTube* dataChannel, ssize_t DisplayEventReceiver::sendEvents(gui::BitTube* dataChannel, Event const* events, size_t count) Event const* events, size_t count) { { Loading libs/gui/IDisplayEventConnection.cpp +1 −9 Original line number Original line Diff line number Diff line Loading @@ -26,8 +26,7 @@ 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, REQUEST_LATEST_CONFIG, LAST = REQUEST_NEXT_VSYNC, LAST = REQUEST_LATEST_CONFIG, }; }; } // Anonymous namespace } // Anonymous namespace Loading @@ -54,11 +53,6 @@ public: callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( Tag::REQUEST_NEXT_VSYNC); Tag::REQUEST_NEXT_VSYNC); } } void requestLatestConfig() override { callRemoteAsync<decltype(&IDisplayEventConnection::requestLatestConfig)>( Tag::REQUEST_LATEST_CONFIG); } }; }; // 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 @@ -80,8 +74,6 @@ 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::REQUEST_LATEST_CONFIG: return callLocalAsync(data, reply, &IDisplayEventConnection::requestLatestConfig); } } } } Loading libs/gui/include/gui/DisplayEventDispatcher.h +4 −1 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,7 @@ public: status_t initialize(); status_t initialize(); void dispose(); void dispose(); status_t scheduleVsync(); status_t scheduleVsync(); void requestLatestConfig(); void injectEvent(const DisplayEventReceiver::Event& event); int getFd() const; int getFd() const; virtual int handleEvent(int receiveFd, int events, void* data); virtual int handleEvent(int receiveFd, int events, void* data); Loading @@ -48,6 +48,9 @@ private: 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, nsecs_t vsyncPeriod) = 0; int32_t configId, nsecs_t vsyncPeriod) = 0; // AChoreographer-specific hook for processing null-events so that looper // can be properly poked. virtual void dispatchNullEvent(nsecs_t timestamp, PhysicalDisplayId displayId) = 0; bool processPendingEvents(nsecs_t* outTimestamp, PhysicalDisplayId* outDisplayId, bool processPendingEvents(nsecs_t* outTimestamp, PhysicalDisplayId* outDisplayId, uint32_t* outCount); uint32_t* outCount); Loading Loading
libs/gui/BitTube.cpp +16 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,10 @@ void BitTube::setReceiveFd(base::unique_fd&& receiveFd) { mReceiveFd = std::move(receiveFd); mReceiveFd = std::move(receiveFd); } } void BitTube::setSendFd(base::unique_fd&& sendFd) { mSendFd = std::move(sendFd); } ssize_t BitTube::write(void const* vaddr, size_t size) { ssize_t BitTube::write(void const* vaddr, size_t size) { ssize_t err, len; ssize_t err, len; do { do { Loading Loading @@ -115,6 +119,11 @@ status_t BitTube::writeToParcel(Parcel* reply) const { status_t result = reply->writeDupFileDescriptor(mReceiveFd); status_t result = reply->writeDupFileDescriptor(mReceiveFd); mReceiveFd.reset(); mReceiveFd.reset(); if (result != NO_ERROR) { return result; } result = reply->writeDupFileDescriptor(mSendFd); mSendFd.reset(); return result; return result; } } Loading @@ -126,6 +135,13 @@ status_t BitTube::readFromParcel(const Parcel* parcel) { ALOGE("BitTube::readFromParcel: can't dup file descriptor (%s)", strerror(error)); ALOGE("BitTube::readFromParcel: can't dup file descriptor (%s)", strerror(error)); return -error; return -error; } } mSendFd.reset(dup(parcel->readFileDescriptor())); if (mSendFd < 0) { mSendFd.reset(); int error = errno; ALOGE("BitTube::readFromParcel: can't dup file descriptor (%s)", strerror(error)); return -error; } return NO_ERROR; return NO_ERROR; } } Loading
libs/gui/DisplayEventDispatcher.cpp +6 −6 Original line number Original line Diff line number Diff line Loading @@ -89,12 +89,8 @@ status_t DisplayEventDispatcher::scheduleVsync() { return OK; return OK; } } void DisplayEventDispatcher::requestLatestConfig() { void DisplayEventDispatcher::injectEvent(const DisplayEventReceiver::Event& event) { status_t status = mReceiver.requestLatestConfig(); mReceiver.sendEvents(&event, 1); if (status) { ALOGW("Failed enable config events, status=%d", status); return; } } } int DisplayEventDispatcher::getFd() const { int DisplayEventDispatcher::getFd() const { Loading Loading @@ -157,6 +153,9 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, ev.config.configId, ev.config.vsyncPeriod); ev.config.configId, ev.config.vsyncPeriod); break; break; case DisplayEventReceiver::DISPLAY_EVENT_NULL: dispatchNullEvent(ev.header.timestamp, ev.header.displayId); 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); break; break; Loading @@ -168,4 +167,5 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, } } return gotVsync; return gotVsync; } } } // namespace android } // namespace android
libs/gui/DisplayEventReceiver.cpp +4 −8 Original line number Original line Diff line number Diff line Loading @@ -79,14 +79,6 @@ status_t DisplayEventReceiver::requestNextVsync() { return NO_INIT; return NO_INIT; } } status_t DisplayEventReceiver::requestLatestConfig() { if (mEventConnection != nullptr) { mEventConnection->requestLatestConfig(); 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) { return DisplayEventReceiver::getEvents(mDataChannel.get(), events, count); return DisplayEventReceiver::getEvents(mDataChannel.get(), events, count); Loading @@ -98,6 +90,10 @@ ssize_t DisplayEventReceiver::getEvents(gui::BitTube* dataChannel, return gui::BitTube::recvObjects(dataChannel, events, count); return gui::BitTube::recvObjects(dataChannel, events, count); } } ssize_t DisplayEventReceiver::sendEvents(Event const* events, size_t count) { return DisplayEventReceiver::sendEvents(mDataChannel.get(), events, count); } ssize_t DisplayEventReceiver::sendEvents(gui::BitTube* dataChannel, ssize_t DisplayEventReceiver::sendEvents(gui::BitTube* dataChannel, Event const* events, size_t count) Event const* events, size_t count) { { Loading
libs/gui/IDisplayEventConnection.cpp +1 −9 Original line number Original line Diff line number Diff line Loading @@ -26,8 +26,7 @@ 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, REQUEST_LATEST_CONFIG, LAST = REQUEST_NEXT_VSYNC, LAST = REQUEST_LATEST_CONFIG, }; }; } // Anonymous namespace } // Anonymous namespace Loading @@ -54,11 +53,6 @@ public: callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( Tag::REQUEST_NEXT_VSYNC); Tag::REQUEST_NEXT_VSYNC); } } void requestLatestConfig() override { callRemoteAsync<decltype(&IDisplayEventConnection::requestLatestConfig)>( Tag::REQUEST_LATEST_CONFIG); } }; }; // 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 @@ -80,8 +74,6 @@ 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::REQUEST_LATEST_CONFIG: return callLocalAsync(data, reply, &IDisplayEventConnection::requestLatestConfig); } } } } Loading
libs/gui/include/gui/DisplayEventDispatcher.h +4 −1 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,7 @@ public: status_t initialize(); status_t initialize(); void dispose(); void dispose(); status_t scheduleVsync(); status_t scheduleVsync(); void requestLatestConfig(); void injectEvent(const DisplayEventReceiver::Event& event); int getFd() const; int getFd() const; virtual int handleEvent(int receiveFd, int events, void* data); virtual int handleEvent(int receiveFd, int events, void* data); Loading @@ -48,6 +48,9 @@ private: 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, nsecs_t vsyncPeriod) = 0; int32_t configId, nsecs_t vsyncPeriod) = 0; // AChoreographer-specific hook for processing null-events so that looper // can be properly poked. virtual void dispatchNullEvent(nsecs_t timestamp, PhysicalDisplayId displayId) = 0; bool processPendingEvents(nsecs_t* outTimestamp, PhysicalDisplayId* outDisplayId, bool processPendingEvents(nsecs_t* outTimestamp, PhysicalDisplayId* outDisplayId, uint32_t* outCount); uint32_t* outCount); Loading