Remove Flattener::mLayersHash

Bug:163076219
Test: make

This field is computed and then immediately returned by another method.
But it is never read again until it has been rewritten. The client of
Flattener::flattenLayers stores the value, but this class doesn't need
to store it, too. Remove the field, and switch updateLayersHash to
computeLayersHash, which simply computes and returns the value. This is
simpler and clearer.

Change-Id: I065f1968bbe66e94180c57c54ba4f32a3a8ddf40
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Flattener.h
index 5b9a9f0..7a6ceab 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 30b5761..cfc890b 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
@@ -41,7 +41,7 @@
     ++mInitialLayerCounts[layers.size()];
 
     if (mergeWithCachedSets(layers, now)) {
-        hash = mLayersHash;
+        hash = computeLayersHash();
     }
 
     ++mFinalLayerCounts[mLayers.size()];
@@ -169,12 +169,12 @@
     }
 }
 
-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;
 }
 
 bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers, time_point now) {
@@ -280,7 +280,6 @@
     }
 
     mLayers = std::move(merged);
-    updateLayersHash();
     return true;
 }