Start removing Current state
Now that we only write to current state from the main thread
we can actually just write directly in to drawing state and
avoid copying current to drawing state on each frame. simpleperf
on bouncing ball indicates this was saving around 8% CPU or so
per frame. As a next target we will eliminate the remaining work
in doTransaction and eliminate the doTransaction pass.
Test: Existing tests pass. simpleperf
Bug: 186200583
Change-Id: I59b75747d7371b3ffe870129c8be100c7daa6c4e
diff --git a/services/surfaceflinger/LayerVector.cpp b/services/surfaceflinger/LayerVector.cpp
index 9b94920..aee820a 100644
--- a/services/surfaceflinger/LayerVector.cpp
+++ b/services/surfaceflinger/LayerVector.cpp
@@ -42,10 +42,8 @@
const auto& l = *reinterpret_cast<const sp<Layer>*>(lhs);
const auto& r = *reinterpret_cast<const sp<Layer>*>(rhs);
- const auto& lState =
- (mStateSet == StateSet::Current) ? l->getCurrentState() : l->getDrawingState();
- const auto& rState =
- (mStateSet == StateSet::Current) ? r->getCurrentState() : r->getDrawingState();
+ const auto& lState = l->getDrawingState();
+ const auto& rState = r->getDrawingState();
uint32_t ls = lState.layerStack;
uint32_t rs = rState.layerStack;
@@ -66,8 +64,7 @@
void LayerVector::traverseInZOrder(StateSet stateSet, const Visitor& visitor) const {
for (size_t i = 0; i < size(); i++) {
const auto& layer = (*this)[i];
- auto& state = (stateSet == StateSet::Current) ? layer->getCurrentState()
- : layer->getDrawingState();
+ auto& state = layer->getDrawingState();
if (state.isRelativeOf) {
continue;
}
@@ -78,8 +75,7 @@
void LayerVector::traverseInReverseZOrder(StateSet stateSet, const Visitor& visitor) const {
for (auto i = static_cast<int64_t>(size()) - 1; i >= 0; i--) {
const auto& layer = (*this)[i];
- auto& state = (stateSet == StateSet::Current) ? layer->getCurrentState()
- : layer->getDrawingState();
+ auto& state = layer->getDrawingState();
if (state.isRelativeOf) {
continue;
}