From 88168fa85dae337410169bf54e6bdf5b20e3023e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tinja=20Paavosepp=C3=A4?= Date: Wed, 10 Apr 2024 15:32:04 +0300 Subject: Android: Add QT_ANDROID_SURFACE_CONTAINER_TYPE env var The Android QPA picks between two types of Views that can provide a Surface for it, SurfaceView and TextureView. Normally, SurfaceView is used if there's just one window in the app, and TextureView is used for any additional windows, since it allows better control over the z order between the windows. Add an environment variable QT_ANDROID_SURFACE_CONTAINER_TYPE that can be used to override the normal choosing strategy, and force the application to use either one of the View classes for all the windows of the app. This helps with testing changes to the Android QPA windowing, as you can use the same app to test both Surface Views easily. Pick-to: 6.7 Change-Id: Icc15fd9675175b854354a379b6ffa7ae5532408e Reviewed-by: Assam Boudjelthia --- .../platforms/android/qandroidplatformwindow.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index e47281664d..979f0fb98a 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -64,11 +64,20 @@ QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window) if (window->isTopLevel()) platformScreen()->addWindow(this); - // TODO should handle case where this changes at runtime -> need to change existing window - // into TextureView (or perhaps not, if the parent window would be SurfaceView, as long as - // onTop was false it would stay below the children) - if (platformScreen()->windows().size() <= 1) + static bool ok = false; + static const int value = qEnvironmentVariableIntValue("QT_ANDROID_SURFACE_CONTAINER_TYPE", &ok); + if (ok) { + static const SurfaceContainer type = static_cast(value); + if (type == SurfaceContainer::SurfaceView || type == SurfaceContainer::TextureView) + m_surfaceContainerType = type; + } else if (platformScreen()->windows().size() <= 1) { + // TODO should handle case where this changes at runtime -> need to change existing window + // into TextureView (or perhaps not, if the parent window would be SurfaceView, as long as + // onTop was false it would stay below the children) m_surfaceContainerType = SurfaceContainer::SurfaceView; + } + qCDebug(lcQpaWindow) << "Window" << m_nativeViewId << "using surface container type" + << static_cast(m_surfaceContainerType); } QAndroidPlatformWindow::~QAndroidPlatformWindow() -- cgit v1.2.3