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 <assam.boudjelthia@qt.io>
bb10
Tinja Paavoseppä 2024-04-10 15:32:04 +03:00
parent ecc9516d15
commit 88168fa85d
1 changed files with 13 additions and 4 deletions

View File

@ -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<SurfaceContainer>(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<int>(m_surfaceContainerType);
}
QAndroidPlatformWindow::~QAndroidPlatformWindow()