Do not create new LayerTracing instance within LayerTraceGenerator

LayerDataSource holds a reference to LayerTracing in order to notify
LayerTracing about perfetto events (OnSetup, OnStart, OnFlush, OnStop).

Having multiple instances of LayerTracing complicates things, as it arises
the question of which instance(s) should be referenced and notified
by LayerDataSource.

This commit eliminates the problem at its root, by avoiding to create
an extra LayerTracing instance within LayerTraceGenerator.

Bug: b/293429094
Test: atest transactiontrace_testsuite && atest SurfaceFlinger_test

Change-Id: Id2cf232d1198f9470b476d9a9d9eb86c21246c61
diff --git a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
index 7a07634..2fcb9e0 100644
--- a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
+++ b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
@@ -23,6 +23,7 @@
 #include <unordered_map>
 
 #include <LayerProtoHelper.h>
+#include <Tracing/LayerTracing.h>
 #include <Tracing/TransactionProtoParser.h>
 #include <Tracing/tools/LayerTraceGenerator.h>
 #include <layerproto/LayerProtoHeader.h>
@@ -62,7 +63,8 @@
         {
             auto traceFlags = LayerTracing::TRACE_INPUT | LayerTracing::TRACE_BUFFERS;
             std::ofstream outStream{actualLayersTracePath, std::ios::binary | std::ios::app};
-            EXPECT_TRUE(LayerTraceGenerator().generate(mTransactionTrace, traceFlags, outStream,
+            auto layerTracing = LayerTracing{outStream};
+            EXPECT_TRUE(LayerTraceGenerator().generate(mTransactionTrace, traceFlags, layerTracing,
                                                        /*onlyLastEntry=*/true))
                     << "Failed to generate layers trace from " << transactionTracePath;
         }