commit | 844fa677e7138c4585e562cbaac0734856c301eb | [log] [tgz] |
---|---|---|
author | Edgar Arriaga <edgararriaga@google.com> | Thu Jan 16 14:21:42 2020 -0800 |
committer | Edgar Arriaga GarcĂa <edgararriaga@google.com> | Thu Jan 30 18:31:23 2020 +0000 |
tree | 415fe6aad406a8db3196645dfca5a3c3479f3846 | |
parent | abd1a135f2a8c988209c30731d4da3d99788ff00 [diff] [blame] |
Use new traversal function when order doesn't matter The new traversal function just handles traversing children and ignores relative layers. It also doesn't care about the z order. We continue to use the traverseInZOrder functions for cases when z order matters. This optimization reduces total CPU time spent in SurfaceFlinger. Total ~2% savings The savings where measured sampling over a 20 second period while TouchLatency bouncy ball app was running. Baseline https://pprof.corp.google.com/?id=2ec0b6ac8e24e1571a3173c763ecd7e1&focus=LayerVector%3A%3AtraverseInZOrder Optimized https://pprof.corp.google.com/?id=23596aeb3e9db163956dc621dd19d7a4&focus=LayerVector%3A%3Atraverse Test: manual. checked that normal use on the phone did not have graphical corruptions. Test: atest SurfaceFlinger_test libcompositionengine_test libsurfaceflinger_unittest Test: go/wm-smoke Port from ag/10112179 Change-Id: I60cc6b58efc0e95c5ccc204830a3d76d2e7633c7
diff --git a/services/surfaceflinger/LayerVector.cpp b/services/surfaceflinger/LayerVector.cpp index 7c959b9..9b94920 100644 --- a/services/surfaceflinger/LayerVector.cpp +++ b/services/surfaceflinger/LayerVector.cpp
@@ -86,6 +86,14 @@ layer->traverseInReverseZOrder(stateSet, visitor); } } + +void LayerVector::traverse(const Visitor& visitor) const { + for (auto i = static_cast<int64_t>(size()) - 1; i >= 0; i--) { + const auto& layer = (*this)[i]; + layer->traverse(mStateSet, visitor); + } +} + } // namespace android // TODO(b/129481165): remove the #pragma below and fix conversion issues