Layer: Use raw pointers for Current/Drawing parent
We should only be reading/writing this from the main thread
and likewise we only delete layers on the main thread and
so using raw pointers and managing the lifetime from the
Layer destructor will be safe. This significantly decreases
overhead in various code that traverses via parent (getAlpha,
isVisible, etc...).
Test: Existing tests pass. simpleperf
Bug: 186200583
Change-Id: I45745f7c865177ddfe9105d1440a9fa8f3470823
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 81f20ed..acb81dc 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3412,6 +3412,7 @@
states.add(composerState);
lbc->updateTransformHint(mActiveDisplayTransformHint);
+
if (outTransformHint) {
*outTransformHint = mActiveDisplayTransformHint;
}
@@ -3956,7 +3957,7 @@
}
if (what & layer_state_t::eLayerChanged) {
// NOTE: index needs to be calculated before we update the state
- const auto& p = layer->getParent();
+ auto p = layer->getParent();
if (p == nullptr) {
ssize_t idx = mCurrentState.layersSortedByZ.indexOf(layer);
if (layer->setLayer(s.z) && idx >= 0) {
@@ -3974,7 +3975,7 @@
}
if (what & layer_state_t::eRelativeLayerChanged) {
// NOTE: index needs to be calculated before we update the state
- const auto& p = layer->getParent();
+ auto p = layer->getParent();
const auto& relativeHandle = s.relativeLayerSurfaceControl ?
s.relativeLayerSurfaceControl->getHandle() : nullptr;
if (p == nullptr) {
@@ -6125,7 +6126,7 @@
return;
}
- sp<Layer> p = layer;
+ auto p = layer;
while (p != nullptr) {
if (excludeLayers.count(p) != 0) {
return;