summaryrefslogtreecommitdiff
path: root/libs/gui/BitTube.cpp
diff options
context:
space:
mode:
author Dan Stoza <stoza@google.com> 2017-04-03 13:09:08 -0700
committer Dan Stoza <stoza@google.com> 2017-04-06 11:52:11 -0700
commit6b698e4fe4ff50dcef818452283637f9870ae770 (patch)
treedacce20234785575e8df1446f3ef0f7adc5bad99 /libs/gui/BitTube.cpp
parent7d290174b08a56ae6bc6719bec58805ca38b348b (diff)
libgui: Remove RefBase from BitTube
Removes RefBase from BitTube, since because it is not a Binder object, it doesn't need to be reference-counted in this way. In the process, we rename IDisplayEventConnection::getDataChannel to IDEC::stealReceiveChannel to make it clearer that this is a non-const operation on the remote end that removes its access to the receive channel. This also adds a couple of methods for moving the receive file descriptor out of one BitTube and into another, since this is the essence of the IDisplayEventConnection::stealReceiveChannel method, and now with C++11 move semantics, we can do this without needing to return an sp<> from EventThread's implementation of stealReceiveChannel. Test: m -j + manual testing Change-Id: Ibaaca2a14fb6155052fe5434c14bc3e671b43743
Diffstat (limited to 'libs/gui/BitTube.cpp')
-rw-r--r--libs/gui/BitTube.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/libs/gui/BitTube.cpp b/libs/gui/BitTube.cpp
index c0237116ab..ef7a6f54d9 100644
--- a/libs/gui/BitTube.cpp
+++ b/libs/gui/BitTube.cpp
@@ -78,6 +78,14 @@ int BitTube::getSendFd() const {
return mSendFd;
}
+base::unique_fd BitTube::moveReceiveFd() {
+ return std::move(mReceiveFd);
+}
+
+void BitTube::setReceiveFd(base::unique_fd&& receiveFd) {
+ mReceiveFd = std::move(receiveFd);
+}
+
ssize_t BitTube::write(void const* vaddr, size_t size) {
ssize_t err, len;
do {
@@ -121,8 +129,7 @@ status_t BitTube::readFromParcel(const Parcel* parcel) {
return NO_ERROR;
}
-ssize_t BitTube::sendObjects(const sp<BitTube>& tube, void const* events, size_t count,
- size_t objSize) {
+ssize_t BitTube::sendObjects(BitTube* tube, void const* events, size_t count, size_t objSize) {
const char* vaddr = reinterpret_cast<const char*>(events);
ssize_t size = tube->write(vaddr, count * objSize);
@@ -136,7 +143,7 @@ ssize_t BitTube::sendObjects(const sp<BitTube>& tube, void const* events, size_t
return size < 0 ? size : size / static_cast<ssize_t>(objSize);
}
-ssize_t BitTube::recvObjects(const sp<BitTube>& tube, void* events, size_t count, size_t objSize) {
+ssize_t BitTube::recvObjects(BitTube* tube, void* events, size_t count, size_t objSize) {
char* vaddr = reinterpret_cast<char*>(events);
ssize_t size = tube->read(vaddr, count * objSize);