fix another bug where screenshots could end-up all black
SF transactions were always handled on VSYNC which allowed
the screenshot to sneak-in between closing the transaction
and vsync (before it's latched), resulting in a screenshot
with the previous state.
we now always force transactions to happen immediately
before screenhots.
Bug: 7552304
Change-Id: I0afc86b7e8366173daff5b9988bbb4d2a0f43860
diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp
index 3f77f74..c9c7b96 100644
--- a/services/surfaceflinger/MessageQueue.cpp
+++ b/services/surfaceflinger/MessageQueue.cpp
@@ -61,6 +61,12 @@
}
}
+void MessageQueue::Handler::dispatchTransaction() {
+ if ((android_atomic_or(eventMaskTransaction, &mEventMask) & eventMaskTransaction) == 0) {
+ mQueue.mLooper->sendMessage(this, Message(MessageQueue::TRANSACTION));
+ }
+}
+
void MessageQueue::Handler::handleMessage(const Message& message) {
switch (message.what) {
case INVALIDATE:
@@ -71,6 +77,10 @@
android_atomic_and(~eventMaskRefresh, &mEventMask);
mQueue.mFlinger->onMessageReceived(message.what);
break;
+ case TRANSACTION:
+ android_atomic_and(~eventMaskTransaction, &mEventMask);
+ mQueue.mFlinger->onMessageReceived(message.what);
+ break;
}
}
@@ -132,6 +142,7 @@
return NO_ERROR;
}
+
/* when INVALIDATE_ON_VSYNC is set SF only processes
* buffer updates on VSYNC and performs a refresh immediately
* after.
@@ -143,6 +154,10 @@
*/
#define INVALIDATE_ON_VSYNC 1
+void MessageQueue::invalidateTransactionNow() {
+ mHandler->dispatchTransaction();
+}
+
void MessageQueue::invalidate() {
#if INVALIDATE_ON_VSYNC
mEvents->requestNextVsync();