Optimize mirror layer management

We currently have to traverse the whole hierarchy twice to
update mirror layer info. While a long term rearchitecture may avoid
this entirely, we can optimize the hotpath by avoiding both traversals
when there are no mirror layers in existence.

Bug: 186200583
Test: Existing tests pass
Change-Id: I63f1fb239aa51e6db4fb1f4cb3cd3a87113d35d9
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index ec9bb7c..e726d37 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -863,6 +863,8 @@
     // The layers in the cloned hierarchy will match the lifetime of the real layers. That is
     // if the real layer is destroyed, then the clone layer will also be destroyed.
     sp<Layer> mClonedChild;
+    bool mHadClonedChild = false;
+    void setClonedChild(const sp<Layer>& mClonedChild);
 
     mutable bool contentDirty{false};
     Region surfaceDamageRegion;