summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidplatformintegration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformintegration.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index 372b32746d..8048bd6cff 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -44,6 +44,7 @@
#include <QGuiApplication>
#include <QOpenGLContext>
#include <QOffscreenSurface>
+#include <QtGui/private/qoffscreensurface_p.h>
#include <QThread>
#include <QtGui/private/qeglpbuffer_p.h>
@@ -68,6 +69,8 @@
#include "qandroidsystemlocale.h"
#include "qandroidplatformoffscreensurface.h"
+#include <jni.h>
+
#if QT_CONFIG(vulkan)
#include "qandroidplatformvulkanwindow.h"
#include "qandroidplatformvulkaninstance.h"
@@ -322,16 +325,20 @@ QPlatformOffscreenSurface *QAndroidPlatformIntegration::createPlatformOffscreenS
format.setGreenBufferSize(8);
format.setBlueBufferSize(8);
- if (surface->nativeHandle()) {
- // Adopt existing offscreen Surface
- // The expectation is that nativeHandle is an ANativeWindow* representing
- // an android.view.Surface
- return new QAndroidPlatformOffscreenSurface(m_eglDisplay, format, surface);
- }
-
return new QEGLPbuffer(m_eglDisplay, format, surface);
}
+QOffscreenSurface *QAndroidPlatformIntegration::createOffscreenSurface(ANativeWindow *nativeSurface) const
+{
+ if (!QtAndroid::activity() || !nativeSurface)
+ return nullptr;
+
+ auto *surface = new QOffscreenSurface;
+ auto *surfacePrivate = QOffscreenSurfacePrivate::get(surface);
+ surfacePrivate->platformOffscreenSurface = new QAndroidPlatformOffscreenSurface(nativeSurface, m_eglDisplay, surface);
+ return surface;
+}
+
QPlatformWindow *QAndroidPlatformIntegration::createPlatformWindow(QWindow *window) const
{
if (!QtAndroid::activity())