From 53d8269529e139996f2c7d7b85d24b6b96ff226e Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Thu, 2 May 2019 22:52:06 +0300 Subject: [PATCH] [vulkan] Added changing native window support --- .../vulkan/android_vulkan_context_factory.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/android/jni/com/mapswithme/vulkan/android_vulkan_context_factory.cpp b/android/jni/com/mapswithme/vulkan/android_vulkan_context_factory.cpp index fb11714dfe..d58417b251 100644 --- a/android/jni/com/mapswithme/vulkan/android_vulkan_context_factory.cpp +++ b/android/jni/com/mapswithme/vulkan/android_vulkan_context_factory.cpp @@ -376,9 +376,21 @@ void AndroidVulkanContextFactory::ChangeSurface(JNIEnv * env, jobject jsurface, return; auto nativeWindow = ANativeWindow_fromSurface(env, jsurface); - CHECK(nativeWindow == m_nativeWindow, ("Native window changing is not supported.")); + if (m_nativeWindow == nullptr) + { + CHECK(!m_windowSurfaceValid, ()); + m_nativeWindow = nativeWindow; + } + else + { + ResetVulkanSurface(false /* allowPipelineDump */); + if (nativeWindow != m_nativeWindow) + { + ANativeWindow_release(m_nativeWindow); + m_nativeWindow = nativeWindow; + } + } - ResetVulkanSurface(false /* allowPipelineDump */); SetVulkanSurface(); LOG(LINFO, ("Surface changed", m_surfaceWidth, m_surfaceHeight)); }