GpuMem perfetto producer

To overcome the problem of ftrace gpumem events not emitting anything
during MEC (with apps that do launch-time allocations), this change adds
a perfetto producer to emit initial counter values at the start of a
trace, so that the visualization won't so zero usage.

Test: adb shell perfetto --query | grep gpu.
Test: Take a perfetto trace with android.gpumem enabled
Bug: 157142645
Change-Id: I5c8278754549399ffa51e6e6fc2ca69b51976cb2
diff --git a/services/gpuservice/GpuService.cpp b/services/gpuservice/GpuService.cpp
index c36e4b9..18c819f 100644
--- a/services/gpuservice/GpuService.cpp
+++ b/services/gpuservice/GpuService.cpp
@@ -27,6 +27,7 @@
 #include <gpumem/GpuMem.h>
 #include <gpustats/GpuStats.h>
 #include <private/android_filesystem_config.h>
+#include <tracing/GpuMemTracer.h>
 #include <utils/String8.h>
 #include <utils/Trace.h>
 #include <vkjson.h>
@@ -48,8 +49,13 @@
 const char* const GpuService::SERVICE_NAME = "gpu";
 
 GpuService::GpuService()
-      : mGpuMem(std::make_unique<GpuMem>()), mGpuStats(std::make_unique<GpuStats>()) {
-    std::thread asyncInitThread([this]() { mGpuMem->initialize(); });
+      : mGpuMem(std::make_shared<GpuMem>()),
+        mGpuStats(std::make_unique<GpuStats>()),
+        mGpuMemTracer(std::make_unique<GpuMemTracer>()) {
+    std::thread asyncInitThread([this]() {
+        mGpuMem->initialize();
+        mGpuMemTracer->initialize(mGpuMem);
+    });
     asyncInitThread.detach();
 };