Inform SurfaceFlinger about displays which receive input
Right now, multiple display devices can share a layerstack.
This means that when constructing InputWindowInfo, its
impossible to know which display transform matches the
display viewport that inputflinger dispatches against. To
remedy this, have displaymanager inform surfaceflinger
which displays "receiveInput" using the same logic that
controls which display viewport it sends to inputflinger.
Bug: 179274888
Test: atest SetDisplayStateLockedTest
Change-Id: If0ffb1b5405f7e7dcdf8ea2f12c109d661a540fe
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index e65c721..d102e07 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -315,6 +315,7 @@
DisplayState::DisplayState()
: what(0),
layerStack(0),
+ flags(0),
layerStackSpaceRect(Rect::EMPTY_RECT),
orientedDisplaySpaceRect(Rect::EMPTY_RECT),
width(0),
@@ -325,6 +326,7 @@
SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(surface));
SAFE_PARCEL(output.writeUint32, what);
SAFE_PARCEL(output.writeUint32, layerStack);
+ SAFE_PARCEL(output.writeUint32, flags);
SAFE_PARCEL(output.writeUint32, toRotationInt(orientation));
SAFE_PARCEL(output.write, layerStackSpaceRect);
SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
@@ -341,6 +343,7 @@
SAFE_PARCEL(input.readUint32, &what);
SAFE_PARCEL(input.readUint32, &layerStack);
+ SAFE_PARCEL(input.readUint32, &flags);
uint32_t tmpUint = 0;
SAFE_PARCEL(input.readUint32, &tmpUint);
orientation = ui::toRotation(tmpUint);
@@ -361,6 +364,10 @@
what |= eLayerStackChanged;
layerStack = other.layerStack;
}
+ if (other.what & eFlagsChanged) {
+ what |= eFlagsChanged;
+ flags = other.flags;
+ }
if (other.what & eDisplayProjectionChanged) {
what |= eDisplayProjectionChanged;
orientation = other.orientation;
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index aa93808..25d9b2b 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1730,6 +1730,12 @@
s.what |= DisplayState::eLayerStackChanged;
}
+void SurfaceComposerClient::Transaction::setDisplayFlags(const sp<IBinder>& token, uint32_t flags) {
+ DisplayState& s(getDisplayState(token));
+ s.flags = flags;
+ s.what |= DisplayState::eFlagsChanged;
+}
+
void SurfaceComposerClient::Transaction::setDisplayProjection(const sp<IBinder>& token,
ui::Rotation orientation,
const Rect& layerStackRect,
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 16430b3..869c082 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -247,7 +247,8 @@
eSurfaceChanged = 0x01,
eLayerStackChanged = 0x02,
eDisplayProjectionChanged = 0x04,
- eDisplaySizeChanged = 0x08
+ eDisplaySizeChanged = 0x08,
+ eFlagsChanged = 0x10
};
DisplayState();
@@ -257,6 +258,7 @@
sp<IBinder> token;
sp<IGraphicBufferProducer> surface;
uint32_t layerStack;
+ uint32_t flags;
// These states define how layers are projected onto the physical display.
//
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 0940e9d..ccd59a4 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -562,6 +562,8 @@
void setDisplayLayerStack(const sp<IBinder>& token, uint32_t layerStack);
+ void setDisplayFlags(const sp<IBinder>& token, uint32_t flags);
+
/* setDisplayProjection() defines the projection of layer stacks
* to a given display.
*