summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-07-31 22:59:38 -0700
committerMathias Agopian <mathias@google.com>2012-08-02 22:24:12 -0700
commitbe246f86bd6378a5110e81e9d9068ab03c3b077e (patch)
treec91f69d478cadb83e69139c79ab2a18ccd274dc8 /services
parent52bbb1ae239c8a4d05543a23fa8c08467d09c3b2 (diff)
downloadframeworks_native-be246f86bd6378a5110e81e9d9068ab03c3b077e.zip
frameworks_native-be246f86bd6378a5110e81e9d9068ab03c3b077e.tar.gz
frameworks_native-be246f86bd6378a5110e81e9d9068ab03c3b077e.tar.bz2
Layers are now sorted by layer-stack first, then by z-order
Change-Id: I7a82929df5ba87b9d88cc5be87e1a233bc4628e9
Diffstat (limited to 'services')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 198beeb..7081d58 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1515,6 +1515,7 @@ uint32_t SurfaceFlinger::setClientStateLocked(
flags |= eTraversalNeeded;
}
if (what & eLayerChanged) {
+ // NOTE: index needs to be calculated before we update the state
ssize_t idx = mCurrentState.layersSortedByZ.indexOf(layer);
if (layer->setLayer(s.z)) {
mCurrentState.layersSortedByZ.removeAt(idx);
@@ -1550,8 +1551,15 @@ uint32_t SurfaceFlinger::setClientStateLocked(
flags |= eTraversalNeeded;
}
if (what & eLayerStackChanged) {
- if (layer->setLayerStack(s.layerStack))
- flags |= eTraversalNeeded;
+ // NOTE: index needs to be calculated before we update the state
+ ssize_t idx = mCurrentState.layersSortedByZ.indexOf(layer);
+ if (layer->setLayerStack(s.layerStack)) {
+ mCurrentState.layersSortedByZ.removeAt(idx);
+ mCurrentState.layersSortedByZ.add(layer);
+ // we need traversal (state changed)
+ // AND transaction (list changed)
+ flags |= eTransactionNeeded|eTraversalNeeded;
+ }
}
}
return flags;
@@ -2694,13 +2702,21 @@ SurfaceFlinger::LayerVector::LayerVector(const LayerVector& rhs)
int SurfaceFlinger::LayerVector::do_compare(const void* lhs,
const void* rhs) const
{
+ // sort layers per layer-stack, then by z-order and finally by sequence
const sp<LayerBase>& l(*reinterpret_cast<const sp<LayerBase>*>(lhs));
const sp<LayerBase>& r(*reinterpret_cast<const sp<LayerBase>*>(rhs));
- // sort layers by Z order
+
+ uint32_t ls = l->currentState().layerStack;
+ uint32_t rs = r->currentState().layerStack;
+ if (ls != rs)
+ return ls - rs;
+
uint32_t lz = l->currentState().z;
uint32_t rz = r->currentState().z;
- // then by sequence, so we get a stable ordering
- return (lz != rz) ? (lz - rz) : (l->sequence - r->sequence);
+ if (lz != rz)
+ return lz - rz;
+
+ return l->sequence - r->sequence;
}
// ---------------------------------------------------------------------------