summaryrefslogtreecommitdiff
path: root/libs/gui/DisplayEventDispatcher.cpp
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2019-11-19 16:23:59 -0800
committer Alec Mouri <alecmouri@google.com> 2019-12-26 10:28:59 -0800
commit50a931da82f9652ed8adc11360faede693da0aaf (patch)
tree99a45c1aec1c2749ef9bc3c5118e9783657910d0 /libs/gui/DisplayEventDispatcher.cpp
parent60aee1c46b52852e140f05748f69e38f4e3de36e (diff)
[AChoreographer] Add private api that decouples from ALooper.
For ease of use by HWUI, we'll get rid of the reliance of a thread-local ALooper: * Rather than using AChoreographer_getInstance to access a thread-local AChoreographer instance, the caller will be expected to create and destroy its own instnace. * For use by HWUI's own looper instance, _getFd() will expose the underlying file descriptor from which events can be listened. The corresponding choreographer combined callback can be called to flush pending display events. Bug: 136262896 Test: builds Change-Id: I94f102da22974cbad37f21a68d2f04ac0cec5c78
Diffstat (limited to 'libs/gui/DisplayEventDispatcher.cpp')
-rw-r--r--libs/gui/DisplayEventDispatcher.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/libs/gui/DisplayEventDispatcher.cpp b/libs/gui/DisplayEventDispatcher.cpp
index 208d729812..8af1a1c6ef 100644
--- a/libs/gui/DisplayEventDispatcher.cpp
+++ b/libs/gui/DisplayEventDispatcher.cpp
@@ -50,17 +50,20 @@ status_t DisplayEventDispatcher::initialize() {
return result;
}
- int rc = mLooper->addFd(mReceiver.getFd(), 0, Looper::EVENT_INPUT, this, NULL);
- if (rc < 0) {
- return UNKNOWN_ERROR;
+ if (mLooper != nullptr) {
+ int rc = mLooper->addFd(mReceiver.getFd(), 0, Looper::EVENT_INPUT, this, NULL);
+ if (rc < 0) {
+ return UNKNOWN_ERROR;
+ }
}
+
return OK;
}
void DisplayEventDispatcher::dispose() {
ALOGV("dispatcher %p ~ Disposing display event dispatcher.", this);
- if (!mReceiver.initCheck()) {
+ if (!mReceiver.initCheck() && mLooper != nullptr) {
mLooper->removeFd(mReceiver.getFd());
}
}
@@ -101,6 +104,10 @@ void DisplayEventDispatcher::toggleConfigEvents(ISurfaceComposer::ConfigChanged
mConfigChangeFlag = configChangeFlag;
}
+int DisplayEventDispatcher::getFd() {
+ return mReceiver.getFd();
+}
+
int DisplayEventDispatcher::handleEvent(int, int events, void*) {
if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) {
ALOGE("Display event receiver pipe was closed or an error occurred. "