Don't add offscreen layer twice to proto.

Fixes: 147691800
Test: Only one offscreen layer per id in dump
Change-Id: I9c741e87531ec0ed166dd1cdafc0961e243d1c96
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 5386644..26efde1 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1893,7 +1893,7 @@
     setTransactionFlags(eTransactionNeeded);
 }
 
-void Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) const {
+LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) const {
     LayerProto* layerProto = layersProto.add_layers();
     writeToProtoDrawingState(layerProto, traceFlags);
     writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags);
@@ -1901,6 +1901,8 @@
     for (const sp<Layer>& layer : mDrawingChildren) {
         layer->writeToProto(layersProto, traceFlags);
     }
+
+    return layerProto;
 }
 
 void Layer::writeToProtoDrawingState(LayerProto* layerInfo, uint32_t traceFlags) const {