SF: Update transform hint from current state
Transform hint is updated before current state is
committed to drawing state. Fix this by looking
at current state when getting the layer's layerStack.
Test: open app on non active display
Fixes: 255246561
Change-Id: Ib002e4ed4cae1b5258bea761fda605b25138b77d
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index def0dfa..b47188f 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1014,8 +1014,10 @@
return priority == PRIORITY_FOCUSED_WITH_MODE || priority == PRIORITY_FOCUSED_WITHOUT_MODE;
};
-ui::LayerStack Layer::getLayerStack() const {
- if (const auto parent = mDrawingParent.promote()) {
+ui::LayerStack Layer::getLayerStack(LayerVector::StateSet state) const {
+ bool useDrawing = state == LayerVector::StateSet::Drawing;
+ const auto parent = useDrawing ? mDrawingParent.promote() : mCurrentParent.promote();
+ if (parent) {
return parent->getLayerStack();
}
return getDrawingState().layerStack;
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 1773c03..336b4ff 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -320,7 +320,9 @@
virtual bool setTrustedOverlay(bool);
virtual bool setFlags(uint32_t flags, uint32_t mask);
virtual bool setLayerStack(ui::LayerStack);
- virtual ui::LayerStack getLayerStack() const;
+ virtual ui::LayerStack getLayerStack(
+ LayerVector::StateSet state = LayerVector::StateSet::Drawing) const;
+
virtual bool setMetadata(const LayerMetadata& data);
virtual void setChildrenDrawingParent(const sp<Layer>&);
virtual bool reparent(const sp<IBinder>& newParentHandle);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 46cd031..52e8542 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4123,7 +4123,7 @@
return 0;
}
- ui::LayerStack oldLayerStack = layer->getLayerStack();
+ ui::LayerStack oldLayerStack = layer->getLayerStack(LayerVector::StateSet::Current);
// Only set by BLAST adapter layers
if (what & layer_state_t::eProducerDisconnect) {
@@ -4392,7 +4392,8 @@
// setTransactionCompletedListener
// if the layer has been parented on to a new display, update its transform hint.
- if (((flags & eTransformHintUpdateNeeded) == 0) && oldLayerStack != layer->getLayerStack()) {
+ if (((flags & eTransformHintUpdateNeeded) == 0) &&
+ oldLayerStack != layer->getLayerStack(LayerVector::StateSet::Current)) {
flags |= eTransformHintUpdateNeeded;
}
@@ -6892,7 +6893,7 @@
parent->addChild(layer);
}
- ui::LayerStack layerStack = layer->getLayerStack();
+ ui::LayerStack layerStack = layer->getLayerStack(LayerVector::StateSet::Current);
sp<const DisplayDevice> hintDisplay;
// Find the display that includes the layer.
for (const auto& [token, display] : mDisplays) {