summaryrefslogtreecommitdiffstats
path: root/src/multimediawidgets
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-02-05 15:54:36 +0100
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-07-29 12:18:37 +0200
commit66ba21971b24942c7481eeb4a4ff156f54ea658a (patch)
tree15cd4c61a7c9966e9a2f2ce7732bf5dcf736daf9 /src/multimediawidgets
parent49cde1b2c4cdc44d1efd5f2d34b58d6a4fda56c8 (diff)
Support dynamic opengl32 - ANGLE switching on Windows
Change-Id: I38532db3ab0ad4fcb8dbabd0cbb528f7d8e4ba06 Reviewed-by: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/multimediawidgets')
-rw-r--r--src/multimediawidgets/qpaintervideosurface.cpp66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/multimediawidgets/qpaintervideosurface.cpp b/src/multimediawidgets/qpaintervideosurface.cpp
index e1dccb2bd..90e3d6063 100644
--- a/src/multimediawidgets/qpaintervideosurface.cpp
+++ b/src/multimediawidgets/qpaintervideosurface.cpp
@@ -50,10 +50,14 @@
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
#include <qglshaderprogram.h>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLFunctions>
#include <QtGui/QWindow>
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#endif
+#ifndef GL_RGB8
+#define GL_RGB8 0x8051
+#endif
#endif
#include <QtDebug>
@@ -97,11 +101,11 @@ QVideoSurfaceGenericPainter::QVideoSurfaceGenericPainter()
{
m_imagePixelFormats
<< QVideoFrame::Format_RGB32
-#ifndef QT_OPENGL_ES // The raster formats should be a subset of the GL formats.
- << QVideoFrame::Format_RGB24
-#endif
<< QVideoFrame::Format_ARGB32
<< QVideoFrame::Format_RGB565;
+ // The raster formats should be a subset of the GL formats.
+ if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGLES)
+ m_imagePixelFormats << QVideoFrame::Format_RGB24;
}
QList<QVideoFrame::PixelFormat> QVideoSurfaceGenericPainter::supportedPixelFormats(
@@ -140,13 +144,11 @@ QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::start(const QVideoSurf
const QAbstractVideoBuffer::HandleType t = format.handleType();
if (t == QAbstractVideoBuffer::NoHandle) {
- if (m_imageFormat != QImage::Format_Invalid
-#ifdef QT_OPENGL_ES
- && format.pixelFormat() != QVideoFrame::Format_RGB24
-#endif
- && !m_imageSize.isEmpty()) {
+ bool ok = m_imageFormat != QImage::Format_Invalid && !m_imageSize.isEmpty();
+ if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES)
+ ok &= format.pixelFormat() != QVideoFrame::Format_RGB24;
+ if (ok)
return QAbstractVideoSurface::NoError;
- }
} else if (t == QAbstractVideoBuffer::QPixmapHandle) {
return QAbstractVideoSurface::NoError;
}
@@ -237,7 +239,7 @@ void QVideoSurfaceGenericPainter::updateColors(int, int, int, int)
# define GL_UNSIGNED_SHORT_5_6_5 33635
#endif
-class QVideoSurfaceGLPainter : public QVideoSurfacePainter
+class QVideoSurfaceGLPainter : public QVideoSurfacePainter, protected QOpenGLFunctions
{
public:
QVideoSurfaceGLPainter(QGLContext *context);
@@ -262,7 +264,7 @@ protected:
void initYuv420PTextureInfo(const QSize &size);
void initYv12TextureInfo(const QSize &size);
-#ifndef QT_OPENGL_ES
+#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
typedef void (APIENTRY *_glActiveTexture) (GLenum);
_glActiveTexture glActiveTexture;
#endif
@@ -300,7 +302,7 @@ QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QGLContext *context)
, m_textureCount(0)
, m_yuv(false)
{
-#ifndef QT_OPENGL_ES
+#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
glActiveTexture = (_glActiveTexture)m_context->getProcAddress(QLatin1String("glActiveTexture"));
#endif
@@ -309,6 +311,7 @@ QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QGLContext *context)
memset(m_textureHeights, 0, sizeof(m_textureHeights));
memset(m_textureOffsets, 0, sizeof(m_textureOffsets));
+ initializeOpenGLFunctions();
}
QVideoSurfaceGLPainter::~QVideoSurfaceGLPainter()
@@ -554,7 +557,7 @@ void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size)
m_textureOffsets[2] = bytesPerLine * size.height();
}
-#ifndef QT_OPENGL_ES
+#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
# ifndef GL_FRAGMENT_PROGRAM_ARB
# define GL_FRAGMENT_PROGRAM_ARB 0x8804
@@ -945,7 +948,7 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint(
return QVideoSurfaceGLPainter::paint(target, painter, source);
}
-#endif
+#endif // !QT_OPENGL_ES && !QT_OPENGL_DYNAMIC
static const char *qt_glsl_vertexShaderProgram =
"attribute highp vec4 vertexCoordArray;\n"
@@ -1057,10 +1060,6 @@ QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context)
<< QVideoFrame::Format_RGB32
<< QVideoFrame::Format_BGR32
<< QVideoFrame::Format_ARGB32
-#ifndef QT_OPENGL_ES
- << QVideoFrame::Format_RGB24
- << QVideoFrame::Format_BGR24
-#endif
<< QVideoFrame::Format_RGB565
<< QVideoFrame::Format_YUV444
<< QVideoFrame::Format_AYUV444
@@ -1069,6 +1068,11 @@ QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context)
m_glPixelFormats
<< QVideoFrame::Format_RGB32
<< QVideoFrame::Format_ARGB32;
+ if (!context->contextHandle()->isOpenGLES()) {
+ m_imagePixelFormats
+ << QVideoFrame::Format_RGB24
+ << QVideoFrame::Format_BGR24;
+ }
}
QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurfaceFormat &format)
@@ -1095,16 +1099,18 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface
initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize());
fragmentProgram = qt_glsl_argbShaderProgram;
break;
-#ifndef QT_OPENGL_ES
case QVideoFrame::Format_RGB24:
- initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize());
- fragmentProgram = qt_glsl_rgbShaderProgram;
+ if (!m_context->contextHandle()->isOpenGLES()) {
+ initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize());
+ fragmentProgram = qt_glsl_rgbShaderProgram;
+ }
break;
case QVideoFrame::Format_BGR24:
- initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize());
- fragmentProgram = qt_glsl_argbShaderProgram;
+ if (!m_context->contextHandle()->isOpenGLES()) {
+ initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize());
+ fragmentProgram = qt_glsl_argbShaderProgram;
+ }
break;
-#endif
case QVideoFrame::Format_RGB565:
initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize());
fragmentProgram = qt_glsl_rgbShaderProgram;
@@ -1577,14 +1583,14 @@ void QPainterVideoSurface::setGLContext(QGLContext *context)
m_glContext->makeCurrent();
- const QByteArray extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
-#ifndef QT_OPENGL_ES
-
+ const QByteArray extensions(reinterpret_cast<const char *>(
+ context->contextHandle()->functions()->glGetString(GL_EXTENSIONS)));
+#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
if (extensions.contains("ARB_fragment_program"))
m_shaderTypes |= FragmentProgramShader;
#endif
if (QGLShaderProgram::hasOpenGLShaderPrograms(m_glContext)
-#ifndef QT_OPENGL_ES_2
+#if !defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_DYNAMIC)
&& extensions.contains("ARB_shader_objects")
#endif
)
@@ -1683,13 +1689,13 @@ void QPainterVideoSurface::createPainter()
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
switch (m_shaderType) {
-#ifndef QT_OPENGL_ES
+#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
case FragmentProgramShader:
Q_ASSERT(m_glContext);
m_glContext->makeCurrent();
m_painter = new QVideoSurfaceArbFpPainter(m_glContext);
break;
-#endif
+#endif // !QT_OPENGL_ES && !QT_OPENGL_DYNAMIC
case GlslShader:
Q_ASSERT(m_glContext);
m_glContext->makeCurrent();