summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2019-07-16 14:15:33 -0700
committer Vishnu Nair <vishnun@google.com> 2019-07-16 14:15:33 -0700
commit996bc421ea90965e384c947f5a68394afb95bd88 (patch)
treeb78cf2c9e96ef4b89a2e8d4a7f98cd0d39eccf1b
parentf9f627bf75a0507d760997d417c0b9d9ae2d5a7f (diff)
Properly merge flags when merging transactions
Test: atest SurfaceFlinger_test Change-Id: Ib1446c5afe00fd2588f7682f33cbbc6d6eb6a1ea
-rw-r--r--libs/gui/LayerState.cpp5
-rw-r--r--services/surfaceflinger/tests/Transaction_test.cpp24
2 files changed, 27 insertions, 2 deletions
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 6066421faf..aa07cbe0ab 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -267,8 +267,9 @@ void layer_state_t::merge(const layer_state_t& other) {
}
if (other.what & eFlagsChanged) {
what |= eFlagsChanged;
- flags = other.flags;
- mask = other.mask;
+ flags &= ~other.mask;
+ flags |= (other.flags & other.mask);
+ mask |= other.mask;
}
if (other.what & eLayerStackChanged) {
what |= eLayerStackChanged;
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index d5f65348d8..aed7b40872 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -4427,6 +4427,30 @@ TEST_F(LayerUpdateTest, MergingTransactions) {
}
}
+TEST_F(LayerUpdateTest, MergingTransactionFlags) {
+ Transaction().hide(mFGSurfaceControl).apply();
+ std::unique_ptr<ScreenCapture> sc;
+ {
+ SCOPED_TRACE("before merge");
+ ScreenCapture::captureScreen(&sc);
+ sc->expectBGColor(0, 12);
+ sc->expectBGColor(75, 75);
+ sc->expectBGColor(145, 145);
+ }
+
+ Transaction t1, t2;
+ t1.show(mFGSurfaceControl);
+ t2.setFlags(mFGSurfaceControl, 0 /* flags */, layer_state_t::eLayerSecure /* mask */);
+ t1.merge(std::move(t2));
+ t1.apply();
+
+ {
+ SCOPED_TRACE("after merge");
+ ScreenCapture::captureScreen(&sc);
+ sc->expectFGColor(75, 75);
+ }
+}
+
class ChildLayerTest : public LayerUpdateTest {
protected:
void SetUp() override {