summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
diff options
context:
space:
mode:
authorAndy Nichols <nezticle@gmail.com>2016-12-06 22:36:30 +0100
committerAndy Nichols <andy.nichols@qt.io>2016-12-14 15:51:23 +0000
commit9d8db91ada0ab340ae781862f567c9b104e83c63 (patch)
tree9796e5b28a786a35567983c041869682b40b68c7 /src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
parentb750a3786f42395f0cddd8ed8f92a2bcfda1b270 (diff)
Android: Enable Adoption of ANativeWindow handle as a QOffscreenSurface
This is done by adding an API to QOffscreenSurface to enable setting a native handle which can represent a native offscreen surface. When using the TexureView it is necessary to render to SurfaceTexture objects which are exposed as offscreen window surfaces. After wraping a SurfaceTexture in a android.view.Surface object and passing it to C++ via the JNI, it is possible to get the needed ANativeWindow* handle required to pass to eglCreateWindowSurface. So by setting this native handle Qt can then render to this "native" offscreen surface. Change-Id: If7fc5ac7ac588fe6c3a6fb883ea7e439d095470f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformopenglcontext.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglcontext.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
index eeec7a8106..d9ecdfac3d 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
+++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
@@ -41,11 +41,13 @@
#include "qandroidplatformopenglcontext.h"
#include "qandroidplatformopenglwindow.h"
#include "qandroidplatformintegration.h"
+#include "qandroidplatformoffscreensurface.h"
#include <QtEglSupport/private/qeglpbuffer_p.h>
#include <QSurface>
#include <QtGui/private/qopenglcontext_p.h>
+#include <QtGui/QOffscreenSurface>
QT_BEGIN_NAMESPACE
@@ -110,10 +112,15 @@ bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface)
EGLSurface QAndroidPlatformOpenGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
{
- if (surface->surface()->surfaceClass() == QSurface::Window)
+ if (surface->surface()->surfaceClass() == QSurface::Window) {
return static_cast<QAndroidPlatformOpenGLWindow *>(surface)->eglSurface(eglConfig());
- else
- return static_cast<QEGLPbuffer *>(surface)->pbuffer();
+ } else {
+ auto platformOffscreenSurface = static_cast<QPlatformOffscreenSurface*>(surface);
+ if (platformOffscreenSurface->offscreenSurface()->nativeHandle())
+ return static_cast<QAndroidPlatformOffscreenSurface *>(surface)->surface();
+ else
+ return static_cast<QEGLPbuffer *>(surface)->pbuffer();
+ }
}
QT_END_NAMESPACE