Make SkiaVulkanPipeline go through RenderThread to get VulkanManger.

Previously the pipeline held a referance to the VulkanManager on
the RenderThread. However if the RenderThread ever deleted or
recreated its VulkanManager the pipline would not update its
reference and cause crashes when accessed. This change makes it
so the pipeline always goes through the RenderThread to get the
VulkanManager.

Test: Manual build and running on phone
Bug: b/184287126, b/183289296
Change-Id: I52b37d0aa85b553e358285fa3654c2169971ffde
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
index 1bd943f..30a3fc5 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
@@ -43,8 +43,7 @@
 namespace uirenderer {
 namespace skiapipeline {
 
-SkiaVulkanPipeline::SkiaVulkanPipeline(renderthread::RenderThread& thread)
-        : SkiaPipeline(thread), mVkManager(thread.vulkanManager()) {
+SkiaVulkanPipeline::SkiaVulkanPipeline(renderthread::RenderThread& thread) : SkiaPipeline(thread) {
     thread.renderState().registerContextCallback(this);
 }
 
@@ -52,13 +51,17 @@
     mRenderThread.renderState().removeContextCallback(this);
 }
 
+VulkanManager& SkiaVulkanPipeline::vulkanManager() {
+    return mRenderThread.vulkanManager();
+}
+
 MakeCurrentResult SkiaVulkanPipeline::makeCurrent() {
     return MakeCurrentResult::AlreadyCurrent;
 }
 
 Frame SkiaVulkanPipeline::getFrame() {
     LOG_ALWAYS_FATAL_IF(mVkSurface == nullptr, "getFrame() called on a context with no surface!");
-    return mVkManager.dequeueNextBuffer(mVkSurface);
+    return vulkanManager().dequeueNextBuffer(mVkSurface);
 }
 
 bool SkiaVulkanPipeline::draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
@@ -85,7 +88,7 @@
 
     {
         ATRACE_NAME("flush commands");
-        mVkManager.finishFrame(backBuffer.get());
+        vulkanManager().finishFrame(backBuffer.get());
     }
     layerUpdateQueue->clear();
 
@@ -106,7 +109,7 @@
     currentFrameInfo->markSwapBuffers();
 
     if (*requireSwap) {
-        mVkManager.swapBuffers(mVkSurface, screenDirty);
+        vulkanManager().swapBuffers(mVkSurface, screenDirty);
     }
 
     return *requireSwap;
@@ -122,15 +125,15 @@
 
 bool SkiaVulkanPipeline::setSurface(ANativeWindow* surface, SwapBehavior swapBehavior) {
     if (mVkSurface) {
-        mVkManager.destroySurface(mVkSurface);
+        vulkanManager().destroySurface(mVkSurface);
         mVkSurface = nullptr;
     }
 
     if (surface) {
         mRenderThread.requireVkContext();
         mVkSurface =
-                mVkManager.createSurface(surface, mColorMode, mSurfaceColorSpace, mSurfaceColorType,
-                                         mRenderThread.getGrContext(), 0);
+                vulkanManager().createSurface(surface, mColorMode, mSurfaceColorSpace,
+                                              mSurfaceColorType, mRenderThread.getGrContext(), 0);
     }
 
     return mVkSurface != nullptr;
@@ -141,7 +144,7 @@
 }
 
 bool SkiaVulkanPipeline::isContextReady() {
-    return CC_LIKELY(mVkManager.hasVkContext());
+    return CC_LIKELY(vulkanManager().hasVkContext());
 }
 
 void SkiaVulkanPipeline::invokeFunctor(const RenderThread& thread, Functor* functor) {
@@ -156,7 +159,7 @@
 
 void SkiaVulkanPipeline::onContextDestroyed() {
     if (mVkSurface) {
-        mVkManager.destroySurface(mVkSurface);
+        vulkanManager().destroySurface(mVkSurface);
         mVkSurface = nullptr;
     }
 }