From 269c64f47a0e356bc91a261b61f4e23f0b08fcfc Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 8 Jun 2015 17:46:10 +0200 Subject: 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 --- src/multimediawidgets/qpaintervideosurface.cpp | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/multimediawidgets') 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 #include #include +#include #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) #include @@ -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; -- cgit v1.2.3