vulkan: add decoder context

Gather the objects injected to VkDecoder in a separate struct.

Change-Id: I5d78f3624f4af2785351ec098533213bf4908c15
diff --git a/stream-servers/PostWorker.h b/stream-servers/PostWorker.h
index 1c715fb..7f190fe 100644
--- a/stream-servers/PostWorker.h
+++ b/stream-servers/PostWorker.h
@@ -42,8 +42,8 @@
    public:
     using BindSubwinCallback = std::function<bool(void)>;
 
-    PostWorker(BindSubwinCallback&& cb, bool mainThreadPostingOnly,
-               Compositor* compositor, DisplayVk* display);
+    PostWorker(BindSubwinCallback&& cb, bool mainThreadPostingOnly, Compositor* compositor,
+               DisplayVk* display);
     ~PostWorker();
 
     // post: posts the next color buffer.
diff --git a/stream-servers/RenderThread.cpp b/stream-servers/RenderThread.cpp
index ce0f882..3429736 100644
--- a/stream-servers/RenderThread.cpp
+++ b/stream-servers/RenderThread.cpp
@@ -26,6 +26,7 @@
 #include "RenderThreadInfo.h"
 #include "RendererImpl.h"
 #include "RingStream.h"
+#include "VkDecoderContext.h"
 #include "apigen-codec-common/ChecksumCalculatorThreadInfo.h"
 #include "base/HealthMonitor.h"
 #include "base/Lock.h"
@@ -448,10 +449,13 @@
             // Note: It's risky to limit Vulkan decoding to one thread,
             // so we do it outside the limiter
             if (tInfo.m_vkInfo) {
+                VkDecoderContext context = {
+                    .processName = processName,
+                    .gfxApiLogger = &gfxLogger,
+                    .healthMonitor = &FrameBuffer::getFB()->getHealthMonitor(),
+                };
                 last = tInfo.m_vkInfo->m_vkDec.decode(readBuf.buf(), readBuf.validData(), ioStream,
-                                                      seqnoPtr, gfxLogger,
-                                                      FrameBuffer::getFB()->getHealthMonitor(),
-                                                      processName);
+                                                      seqnoPtr, context);
                 if (last > 0) {
                     readBuf.consume(last);
                     progress = true;
diff --git a/stream-servers/vulkan/VkDecoder.cpp b/stream-servers/vulkan/VkDecoder.cpp
index 51d100b..3e5aff5 100644
--- a/stream-servers/vulkan/VkDecoder.cpp
+++ b/stream-servers/vulkan/VkDecoder.cpp
@@ -48,8 +48,6 @@
 #include "host-common/logging.h"
 #include "stream-servers/IOStream.h"
 
-using emugl::GfxApiLogger;
-using emugl::HealthMonitor;
 using emugl::HealthWatchdog;
 using emugl::vkDispatch;
 
@@ -72,8 +70,7 @@
     void setForSnapshotLoad(bool forSnapshotLoad) { m_forSnapshotLoad = forSnapshotLoad; }
 
     size_t decode(void* buf, size_t bufsize, IOStream* stream, uint32_t* seqnoPtr,
-                  GfxApiLogger& gfx_logger, HealthMonitor<>& healthMonitor,
-                  const char* processName);
+                  const VkDecoderContext&);
 
    private:
     bool m_logCalls;
@@ -99,18 +96,18 @@
 }
 
 size_t VkDecoder::decode(void* buf, size_t bufsize, IOStream* stream, uint32_t* seqnoPtr,
-                         GfxApiLogger& gfx_logger, HealthMonitor<>& healthMonitor,
-                         const char* processName) {
-    return mImpl->decode(buf, bufsize, stream, seqnoPtr, gfx_logger, healthMonitor, processName);
+                         const VkDecoderContext& context) {
+    return mImpl->decode(buf, bufsize, stream, seqnoPtr, context);
 }
 
 // VkDecoder::Impl::decode to follow
 
 size_t VkDecoder::Impl::decode(void* buf, size_t len, IOStream* ioStream, uint32_t* seqnoPtr,
-                               GfxApiLogger& gfx_logger, HealthMonitor<>& healthMonitor,
-                               const char* processName) {
+                               const VkDecoderContext& context) {
+    const char* processName = context.processName;
+    auto& gfx_logger = *context.gfxApiLogger;
+    auto& healthMonitor = *context.healthMonitor;
     if (len < 8) return 0;
-    ;
     bool queueSubmitWithCommandsEnabled =
         feature_is_enabled(kFeature_VulkanQueueSubmitWithCommands);
     unsigned char* ptr = (unsigned char*)buf;
diff --git a/stream-servers/vulkan/VkDecoder.h b/stream-servers/vulkan/VkDecoder.h
index 26f55ae..41b9343 100644
--- a/stream-servers/vulkan/VkDecoder.h
+++ b/stream-servers/vulkan/VkDecoder.h
@@ -31,8 +31,7 @@
 
 #include <memory>
 
-#include "base/GfxApiLogger.h"
-#include "base/HealthMonitor.h"
+#include "VkDecoderContext.h"
 #include "vk_android_native_buffer.h"
 #include "vulkan_gfxstream.h"
 
@@ -50,8 +49,7 @@
     ~VkDecoder();
     void setForSnapshotLoad(bool forSnapshotLoad);
     size_t decode(void* buf, size_t bufsize, IOStream* stream, uint32_t* seqnoPtr,
-                  emugl::GfxApiLogger& gfx_logger, emugl::HealthMonitor<>& healthMonitor,
-                  const char* processName);
+                  const VkDecoderContext&);
 
    private:
     class Impl;
diff --git a/stream-servers/vulkan/VkDecoderContext.h b/stream-servers/vulkan/VkDecoderContext.h
new file mode 100644
index 0000000..a80d6a4
--- /dev/null
+++ b/stream-servers/vulkan/VkDecoderContext.h
@@ -0,0 +1,25 @@
+// Copyright (C) 2022 The Android Open Source Project
+// Copyright (C) 2022 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma once
+
+#include "base/GfxApiLogger.h"
+#include "base/HealthMonitor.h"
+
+struct VkDecoderContext {
+    const char* processName = nullptr;
+    emugl::GfxApiLogger* gfxApiLogger = nullptr;
+    emugl::HealthMonitor<>* healthMonitor = nullptr;
+};
\ No newline at end of file
diff --git a/stream-servers/vulkan/VkReconstruction.cpp b/stream-servers/vulkan/VkReconstruction.cpp
index 2e9ba41..718814c 100644
--- a/stream-servers/vulkan/VkReconstruction.cpp
+++ b/stream-servers/vulkan/VkReconstruction.cpp
@@ -251,8 +251,13 @@
 
     // TODO: This needs to be the puid seqno ptr
     uint32_t seqno;
+    VkDecoderContext context = {
+        .processName = nullptr,
+        .gfxApiLogger = &gfxLogger,
+        .healthMonitor = &healthMonitor,
+    };
     decoderForLoading.decode(mLoadedTrace.data(), mLoadedTrace.size(), &trivialStream, &seqno,
-                             gfxLogger, healthMonitor, nullptr);
+                             context);
 
     DEBUG_RECON("finished decoding trace");
 }