diff options
author | Christian Strømme <christian.stromme@qt.io> | 2016-07-05 13:46:01 +0200 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@qt.io> | 2016-08-12 11:20:41 +0000 |
commit | 124987e4bc4b39cae7074eb75e2bb3e3436aded0 (patch) | |
tree | 769ac2d77600a6b087d9b28f88851f94f78cebb2 /src/plugins/android/src/common/qandroidvideooutput.h | |
parent | 95e1012c9dc49e0afbed52d17ff32a4a59a723f7 (diff) |
Android: Fix texture leak in QAndroidTextureVideoOutput
Simplify the ownership of the OpenGL resources and make it simpler
to release individual resources as needed. Previously we would
reset the texture handle without releasing it back to the system, making
us leak texture each time the video output was reset.
Also, be consistent with the type used for the texture handle.
Task-number: QTBUG-54340
Change-Id: Ic3b3c7322677a909e51aa5983fa99ccf8b290302
Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
Diffstat (limited to 'src/plugins/android/src/common/qandroidvideooutput.h')
-rw-r--r-- | src/plugins/android/src/common/qandroidvideooutput.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/android/src/common/qandroidvideooutput.h b/src/plugins/android/src/common/qandroidvideooutput.h index 0068a5809..09bd5d87e 100644 --- a/src/plugins/android/src/common/qandroidvideooutput.h +++ b/src/plugins/android/src/common/qandroidvideooutput.h @@ -44,7 +44,6 @@ class AndroidSurfaceTexture; class AndroidSurfaceHolder; class QOpenGLFramebufferObject; class QOpenGLShaderProgram; -class OpenGLResourcesDeleter; class QAbstractVideoSurface; class QAndroidVideoOutput : public QObject @@ -69,6 +68,19 @@ protected: QAndroidVideoOutput(QObject *parent) : QObject(parent) { } }; +class OpenGLResourcesDeleter : public QObject +{ + Q_OBJECT +public: + void deleteTexture(quint32 id) { QMetaObject::invokeMethod(this, "deleteTextureHelper", Qt::AutoConnection, Q_ARG(quint32, id)); } + void deleteFbo(QOpenGLFramebufferObject *fbo) { QMetaObject::invokeMethod(this, "deleteFboHelper", Qt::AutoConnection, Q_ARG(void *, fbo)); } + void deleteShaderProgram(QOpenGLShaderProgram *prog) { QMetaObject::invokeMethod(this, "deleteShaderProgramHelper", Qt::AutoConnection, Q_ARG(void *, prog)); } + +private: + Q_INVOKABLE void deleteTextureHelper(quint32 id); + Q_INVOKABLE void deleteFboHelper(void *fbo); + Q_INVOKABLE void deleteShaderProgramHelper(void *prog); +}; class QAndroidTextureVideoOutput : public QAndroidVideoOutput { @@ -108,7 +120,7 @@ private: quint32 m_externalTex; QOpenGLFramebufferObject *m_fbo; QOpenGLShaderProgram *m_program; - OpenGLResourcesDeleter *m_glDeleter; + QScopedPointer<OpenGLResourcesDeleter, QScopedPointerDeleteLater> m_glDeleter; bool m_surfaceTextureCanAttachToContext; |