summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/MessageQueue.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2013-04-10 16:27:17 -0700
committer Mathias Agopian <mathias@google.com> 2013-04-10 16:27:17 -0700
commit9eb1f0558b5fc78920602afe7bcfa3115bb1f6be (patch)
tree2bcc946139e627de49b4e67121e7f5d5ce9c3174 /services/surfaceflinger/MessageQueue.cpp
parent1df59c93fea8bec21b8084c34aface086f1e0896 (diff)
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
Diffstat (limited to 'services/surfaceflinger/MessageQueue.cpp')
-rw-r--r--services/surfaceflinger/MessageQueue.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp
index 3f77f74c38..c9c7b964fa 100644
--- a/services/surfaceflinger/MessageQueue.cpp
+++ b/services/surfaceflinger/MessageQueue.cpp
@@ -61,6 +61,12 @@ void MessageQueue::Handler::dispatchInvalidate() {
}
}
+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 @@ void MessageQueue::Handler::handleMessage(const Message& message) {
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 @@ status_t MessageQueue::postMessage(
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 @@ status_t MessageQueue::postMessage(
*/
#define INVALIDATE_ON_VSYNC 1
+void MessageQueue::invalidateTransactionNow() {
+ mHandler->dispatchTransaction();
+}
+
void MessageQueue::invalidate() {
#if INVALIDATE_ON_VSYNC
mEvents->requestNextVsync();