summaryrefslogtreecommitdiffstats
path: root/src/plugins/android/src/wrappers
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@qt.io>2016-05-04 15:41:32 +0200
committerYoann Lopes <yoann.lopes@qt.io>2016-05-10 07:37:51 +0000
commitba8127639857232d8a37e953c5cda84203360d97 (patch)
tree441b0882a6846d45f7e98d0da6c37b15c5643bbd /src/plugins/android/src/wrappers
parent37d91ff58d33a573f4d546282c0c5dfe0e5f4aa2 (diff)
Android: improve texture rendering on API level >= 16.
Android API level 16 added SurfaceTexture::attachToGLContext(). This allows to create the OpenGL texture when the first video frame is available, rather than at initialization. This means we can do without the ugly hack that makes the render thread call us back through some custom property. Additionally, it allows to recreate a new OpenGL texture every time the SurfaceTexture is reset. Task-number: QTBUG-51911 Change-Id: I17b04524d426c42ef8aa0288b0731597bc9eba62 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/android/src/wrappers')
-rw-r--r--src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp16
-rw-r--r--src/plugins/android/src/wrappers/jni/androidsurfacetexture.h3
2 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp b/src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp
index 9a25b7e28..2cea896e1 100644
--- a/src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp
+++ b/src/plugins/android/src/wrappers/jni/androidsurfacetexture.cpp
@@ -146,6 +146,22 @@ jobject AndroidSurfaceTexture::surfaceHolder()
return m_surfaceHolder.object();
}
+void AndroidSurfaceTexture::attachToGLContext(int texName)
+{
+ if (QtAndroidPrivate::androidSdkVersion() < 16 || !m_surfaceTexture.isValid())
+ return;
+
+ m_surfaceTexture.callMethod<void>("attachToGLContext", "(I)V", texName);
+}
+
+void AndroidSurfaceTexture::detachFromGLContext()
+{
+ if (QtAndroidPrivate::androidSdkVersion() < 16 || !m_surfaceTexture.isValid())
+ return;
+
+ m_surfaceTexture.callMethod<void>("detachFromGLContext");
+}
+
bool AndroidSurfaceTexture::initJNI(JNIEnv *env)
{
// SurfaceTexture is available since API 11.
diff --git a/src/plugins/android/src/wrappers/jni/androidsurfacetexture.h b/src/plugins/android/src/wrappers/jni/androidsurfacetexture.h
index ac2af694e..a08483e5e 100644
--- a/src/plugins/android/src/wrappers/jni/androidsurfacetexture.h
+++ b/src/plugins/android/src/wrappers/jni/androidsurfacetexture.h
@@ -58,6 +58,9 @@ public:
void release(); // API level 14
void updateTexImage();
+ void attachToGLContext(int texName); // API level 16
+ void detachFromGLContext(); // API level 16
+
static bool initJNI(JNIEnv *env);
Q_SIGNALS: