summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@theqtcompany.com>2015-06-08 17:46:10 +0200
committerYoann Lopes <yoann.lopes@theqtcompany.com>2015-06-10 11:37:30 +0000
commit269c64f47a0e356bc91a261b61f4e23f0b08fcfc (patch)
tree7a4c2bf9e9bc186e234d85bd1b92596b903d1a92
parent2ee7db851978e93490102ee90a93485721a20a85 (diff)
downloadqtmultimedia-269c64f47a0e356bc91a261b61f4e23f0b08fcfc.tar.gz
Support BGR format for OpenGL textures in QPainterVideoSurface.
Also, use the correct shader for RGB formats, we should be using the one that does swizzling in that case. Change-Id: I77b6327501f833fb2f7b30411fbe853e975a59c7 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--src/multimediawidgets/qpaintervideosurface.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/multimediawidgets/qpaintervideosurface.cpp b/src/multimediawidgets/qpaintervideosurface.cpp
index 2dfbf3414..c9fa206a2 100644
--- a/src/multimediawidgets/qpaintervideosurface.cpp
+++ b/src/multimediawidgets/qpaintervideosurface.cpp
@@ -38,6 +38,7 @@
#include <qpainter.h>
#include <qvariant.h>
#include <qvideosurfaceformat.h>
+#include <private/qmediaopenglhelper_p.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
#include <qglshaderprogram.h>
@@ -261,6 +262,12 @@ protected:
void initYuv420PTextureInfo(const QSize &size);
void initYv12TextureInfo(const QSize &size);
+ bool needsSwizzling(const QVideoSurfaceFormat &format) const {
+ return !QMediaOpenGLHelper::isANGLE()
+ && (format.pixelFormat() == QVideoFrame::Format_RGB32
+ || format.pixelFormat() == QVideoFrame::Format_ARGB32);
+ }
+
#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
typedef void (APIENTRY *_glActiveTexture) (GLenum);
_glActiveTexture glActiveTexture;
@@ -702,7 +709,9 @@ QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QGLContext *context)
<< QVideoFrame::Format_YUV420P;
m_glPixelFormats
<< QVideoFrame::Format_RGB32
- << QVideoFrame::Format_ARGB32;
+ << QVideoFrame::Format_ARGB32
+ << QVideoFrame::Format_BGR32
+ << QVideoFrame::Format_BGRA32;
}
QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfaceFormat &format)
@@ -766,9 +775,14 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac
switch (format.pixelFormat()) {
case QVideoFrame::Format_RGB32:
case QVideoFrame::Format_ARGB32:
+ case QVideoFrame::Format_BGR32:
+ case QVideoFrame::Format_BGRA32:
m_yuv = false;
m_textureCount = 1;
- program = qt_arbfp_rgbShaderProgram;
+ if (needsSwizzling(format))
+ program = qt_arbfp_xrgbShaderProgram;
+ else
+ program = qt_arbfp_rgbShaderProgram;
break;
default:
break;
@@ -1070,7 +1084,9 @@ QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context)
<< QVideoFrame::Format_YUV420P;
m_glPixelFormats
<< QVideoFrame::Format_RGB32
- << QVideoFrame::Format_ARGB32;
+ << QVideoFrame::Format_ARGB32
+ << QVideoFrame::Format_BGR32
+ << QVideoFrame::Format_BGRA32;
}
QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurfaceFormat &format)
@@ -1138,9 +1154,14 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface
switch (format.pixelFormat()) {
case QVideoFrame::Format_RGB32:
case QVideoFrame::Format_ARGB32:
+ case QVideoFrame::Format_BGR32:
+ case QVideoFrame::Format_BGRA32:
m_yuv = false;
m_textureCount = 1;
- fragmentProgram = qt_glsl_rgbShaderProgram;
+ if (needsSwizzling(format))
+ fragmentProgram = qt_glsl_xrgbShaderProgram;
+ else
+ fragmentProgram = qt_glsl_rgbShaderProgram;
break;
default:
break;