videonode: imx6: clear texture cache when the format changes
authorMichael Olbrich <m.olbrich@pengutronix.de>
Wed, 26 Feb 2014 18:00:05 +0000 (19:00 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 4 Mar 2014 16:54:22 +0000 (17:54 +0100)
The old textures won't match anyways. So there is no need to keep them.

Change-Id: Id3482333d10cf022d04076ec0f5c7df475c522ae
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp
src/plugins/videonode/imx6/qsgvivantevideomaterial.h

index 0ed4e1a..44f9f4d 100644 (file)
@@ -56,6 +56,9 @@
 
 QSGVivanteVideoMaterial::QSGVivanteVideoMaterial() :
     mOpacity(1.0),
+    mWidth(0),
+    mHeight(0),
+    mFormat(QVideoFrame::Format_Invalid),
     mCurrentTexture(0)
 {
 #ifdef QT_VIVANTE_VIDEO_DEBUG
@@ -147,6 +150,18 @@ GLuint QSGVivanteVideoMaterial::vivanteMapping(QVideoFrame vF)
         return 0;
     }
 
+    if (mWidth != vF.width() || mHeight != vF.height() || mFormat != vF.pixelFormat()) {
+        mWidth = vF.width();
+        mHeight = vF.height();
+        mFormat = vF.pixelFormat();
+        for (GLuint id : mBitsToTextureMap.values()) {
+#ifdef QT_VIVANTE_VIDEO_DEBUG
+            qDebug() << "delete texture: " << id;
+#endif
+            glDeleteTextures(1, &id);
+        }
+        mBitsToTextureMap.clear();
+    }
 
     if (vF.map(QAbstractVideoBuffer::ReadOnly)) {
 
index 9d792b7..0c1c445 100644 (file)
@@ -70,6 +70,10 @@ public:
 private:
     qreal mOpacity;
 
+    int mWidth;
+    int mHeight;
+    QVideoFrame::PixelFormat mFormat;
+
     QMap<const uchar*, GLuint> mBitsToTextureMap;
     QVideoFrame mCurrentFrame, mNextFrame;
     GLuint mCurrentTexture;