Merge changes Id305effe,I065f1968,I18b6d921 into sc-dev
* changes:
SF: Only buildCachedSets if (mergeWithCachedSets)
Remove Flattener::mLayersHash
Mark CachedSet::mFingerprint as const
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
index afa02cd..c5d03a7 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
@@ -108,7 +108,7 @@
private:
CachedSet() = default;
- NonBufferHash mFingerprint = 0;
+ const NonBufferHash mFingerprint;
std::chrono::steady_clock::time_point mLastUpdate = std::chrono::steady_clock::now();
std::vector<Layer> mLayers;
Rect mBounds = Rect::EMPTY_RECT;
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h
index 313a180..2f2ad4c 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h
@@ -54,7 +54,7 @@
void resetActivities(NonBufferHash, std::chrono::steady_clock::time_point now);
- void updateLayersHash();
+ NonBufferHash computeLayersHash() const;
bool mergeWithCachedSets(const std::vector<const LayerState*>& layers,
std::chrono::steady_clock::time_point now);
@@ -69,7 +69,6 @@
std::chrono::steady_clock::time_point mLastGeometryUpdate;
std::vector<CachedSet> mLayers;
- NonBufferHash mLayersHash = 0;
std::optional<CachedSet> mNewCachedSet;
// Statistics
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp b/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
index ffca5ba..9c9649c 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
@@ -40,13 +40,17 @@
++mInitialLayerCounts[layers.size()];
- if (mergeWithCachedSets(layers, now)) {
- hash = mLayersHash;
- }
+ // Only buildCachedSets if these layers are already stored in mLayers.
+ // Otherwise (i.e. mergeWithCachedSets returns false), the time has not
+ // changed, so buildCachedSets will never find any runs.
+ const bool alreadyHadCachedSets = mergeWithCachedSets(layers, now);
++mFinalLayerCounts[mLayers.size()];
- buildCachedSets(now);
+ if (alreadyHadCachedSets) {
+ buildCachedSets(now);
+ hash = computeLayersHash();
+ }
return hash;
}
@@ -157,14 +161,17 @@
}
}
-void Flattener::updateLayersHash() {
+NonBufferHash Flattener::computeLayersHash() const{
size_t hash = 0;
for (const auto& layer : mLayers) {
android::hashCombineSingleHashed(hash, layer.getNonBufferHash());
}
- mLayersHash = hash;
+ return hash;
}
+// Only called if the geometry matches the last frame. Return true if mLayers
+// was already populated with these layers, i.e. on the second and following
+// calls with the same geometry.
bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers, time_point now) {
std::vector<CachedSet> merged;
@@ -272,7 +279,6 @@
}
mLayers = std::move(merged);
- updateLayersHash();
return true;
}