SF: Don't pop pending state into mCurrentState
Let mCurrentState always represent the most up to date state, even if
there are transactions we don't want to commit yet. Past snapshots of
the state are kept in mPendingState. In doTransaction(), grab the
correct pending state from mPendingState, but save it to a local copy
that gets committed rather than overriding mCurrentState.
Bug 27205755
Change-Id: Ib0ea809da1954409787c52b8f41d7963a57a6a4c
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index a2c0462..90ab70d 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1309,16 +1309,16 @@
mPendingStates.push_back(mCurrentState);
}
-void Layer::popPendingState() {
- auto oldFlags = mCurrentState.flags;
- mCurrentState = mPendingStates[0];
- mCurrentState.flags = (oldFlags & ~mCurrentState.mask) |
- (mCurrentState.flags & mCurrentState.mask);
+void Layer::popPendingState(State* stateToCommit) {
+ auto oldFlags = stateToCommit->flags;
+ *stateToCommit = mPendingStates[0];
+ stateToCommit->flags = (oldFlags & ~stateToCommit->mask) |
+ (stateToCommit->flags & stateToCommit->mask);
mPendingStates.removeAt(0);
}
-bool Layer::applyPendingStates() {
+bool Layer::applyPendingStates(State* stateToCommit) {
bool stateUpdateAvailable = false;
while (!mPendingStates.empty()) {
if (mPendingStates[0].handle != nullptr) {
@@ -1327,7 +1327,7 @@
// will be visually wrong, but it should keep us from getting
// into too much trouble.
ALOGE("[%s] No local sync point found", mName.string());
- popPendingState();
+ popPendingState(stateToCommit);
stateUpdateAvailable = true;
continue;
}
@@ -1345,7 +1345,7 @@
if (mRemoteSyncPoints.front()->frameIsAvailable()) {
// Apply the state update
- popPendingState();
+ popPendingState(stateToCommit);
stateUpdateAvailable = true;
// Signal our end of the sync point and then dispose of it
@@ -1355,7 +1355,7 @@
break;
}
} else {
- popPendingState();
+ popPendingState(stateToCommit);
stateUpdateAvailable = true;
}
}
@@ -1385,12 +1385,12 @@
ATRACE_CALL();
pushPendingState();
- if (!applyPendingStates()) {
+ Layer::State c = getCurrentState();
+ if (!applyPendingStates(&c)) {
return 0;
}
const Layer::State& s(getDrawingState());
- const Layer::State& c(getCurrentState());
const bool sizeChanged = (c.requested.w != s.requested.w) ||
(c.requested.h != s.requested.h);
@@ -1454,8 +1454,7 @@
// this is used by Layer, which special cases resizes.
if (flags & eDontUpdateGeometryState) {
} else {
- Layer::State& editCurrentState(getCurrentState());
- editCurrentState.active = c.requested;
+ c.active = c.requested;
}
if (s.active != c.active) {
@@ -1475,12 +1474,12 @@
}
// Commit the transaction
- commitTransaction();
+ commitTransaction(c);
return flags;
}
-void Layer::commitTransaction() {
- mDrawingState = mCurrentState;
+void Layer::commitTransaction(const State& stateToCommit) {
+ mDrawingState = stateToCommit;
}
uint32_t Layer::getTransactionFlags(uint32_t flags) {