From c33134bd530ab549b6e20fca11a5b20f965ae6b3 Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Wed, 21 Oct 2015 11:26:37 -0400 Subject: [PATCH] Fixing Android build. --- src/VideoStreaming/VideoStreaming.pri | 1 + .../delegates/qtvideosinkdelegate.cpp | 7 ++- .../painters/openglsurfacepainter.cpp | 34 +++++++-------- .../gstqtvideosink/painters/videomaterial.cpp | 11 ++--- .../gstqtvideosink/utils/glutils.h | 43 +++++++++++++++++++ 5 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 src/VideoStreaming/gstqtvideosink/utils/glutils.h diff --git a/src/VideoStreaming/VideoStreaming.pri b/src/VideoStreaming/VideoStreaming.pri index 32b2cfa94..9f09c6cbc 100644 --- a/src/VideoStreaming/VideoStreaming.pri +++ b/src/VideoStreaming/VideoStreaming.pri @@ -132,6 +132,7 @@ VideoEnabled { $$PWD/gstqtvideosink/painters/videonode.h \ $$PWD/gstqtvideosink/utils/bufferformat.h \ $$PWD/gstqtvideosink/utils/utils.h \ + $$PWD/gstqtvideosink/utils/glutils.h \ SOURCES += \ $$PWD/gstqtvideosink/delegates/basedelegate.cpp \ diff --git a/src/VideoStreaming/gstqtvideosink/delegates/qtvideosinkdelegate.cpp b/src/VideoStreaming/gstqtvideosink/delegates/qtvideosinkdelegate.cpp index ef2e9e843..fd46d2a6f 100644 --- a/src/VideoStreaming/gstqtvideosink/delegates/qtvideosinkdelegate.cpp +++ b/src/VideoStreaming/gstqtvideosink/delegates/qtvideosinkdelegate.cpp @@ -27,7 +27,8 @@ #include #include -#include + +#include "glutils.h" QtVideoSinkDelegate::QtVideoSinkDelegate(GstElement *sink, QObject *parent) : BaseDelegate(sink, parent) @@ -138,7 +139,7 @@ void QtVideoSinkDelegate::setGLContext(QGLContext *context) if (m_glContext) { m_glContext->makeCurrent(); - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (funcs) { const QByteArray extensions(reinterpret_cast(funcs->glGetString(GL_EXTENSIONS))); GST_LOG_OBJECT(m_sink, "Available GL extensions: %s", extensions.constData()); @@ -230,7 +231,6 @@ void QtVideoSinkDelegate::changePainter(const BufferFormat & format) void QtVideoSinkDelegate::destroyPainter() { GST_LOG_OBJECT(m_sink, "Destroying painter"); - delete m_painter; m_painter = 0; } @@ -243,6 +243,5 @@ bool QtVideoSinkDelegate::event(QEvent *event) destroyPainter(); } } - return BaseDelegate::event(event); } diff --git a/src/VideoStreaming/gstqtvideosink/painters/openglsurfacepainter.cpp b/src/VideoStreaming/gstqtvideosink/painters/openglsurfacepainter.cpp index cd320d44d..dbdad9ba3 100644 --- a/src/VideoStreaming/gstqtvideosink/painters/openglsurfacepainter.cpp +++ b/src/VideoStreaming/gstqtvideosink/painters/openglsurfacepainter.cpp @@ -23,7 +23,8 @@ #include "openglsurfacepainter.h" #include -#include + +#include "glutils.h" #ifndef GL_TEXTURE0 # define GL_TEXTURE0 0x84C0 @@ -178,7 +179,7 @@ void OpenGLSurfacePainter::paint(quint8 *data, QPainter *painter, const PaintAreas & areas) { - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (!funcs) return; @@ -396,22 +397,17 @@ ArbFpSurfacePainter::ArbFpSurfacePainter() , m_programId(0) { const QGLContext *context = QGLContext::currentContext(); - glProgramStringARB = (_glProgramStringARB) context->getProcAddress( - QLatin1String("glProgramStringARB")); - glBindProgramARB = (_glBindProgramARB) context->getProcAddress( - QLatin1String("glBindProgramARB")); - glDeleteProgramsARB = (_glDeleteProgramsARB) context->getProcAddress( - QLatin1String("glDeleteProgramsARB")); - glGenProgramsARB = (_glGenProgramsARB) context->getProcAddress( - QLatin1String("glGenProgramsARB")); - glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) context->getProcAddress( - QLatin1String("glProgramLocalParameter4fARB")); + glProgramStringARB = (_glProgramStringARB) context->getProcAddress(QLatin1String("glProgramStringARB")); + glBindProgramARB = (_glBindProgramARB) context->getProcAddress(QLatin1String("glBindProgramARB")); + glDeleteProgramsARB = (_glDeleteProgramsARB) context->getProcAddress(QLatin1String("glDeleteProgramsARB")); + glGenProgramsARB = (_glGenProgramsARB) context->getProcAddress(QLatin1String("glGenProgramsARB")); + glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) context->getProcAddress(QLatin1String("glProgramLocalParameter4fARB")); } void ArbFpSurfacePainter::init(const BufferFormat &format) { Q_ASSERT(m_textureCount == 0); - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (!funcs) return; @@ -501,7 +497,7 @@ void ArbFpSurfacePainter::init(const BufferFormat &format) void ArbFpSurfacePainter::cleanup() { - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (funcs) { funcs->glDeleteTextures(m_textureCount, m_textureIds); @@ -516,7 +512,7 @@ void ArbFpSurfacePainter::paintImpl(const QPainter *painter, const GLfloat *textureCoordArray) { Q_UNUSED(painter); - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (!funcs) return; @@ -734,14 +730,14 @@ void GlslSurfacePainter::init(const BufferFormat &format) throw QString("Shader link error ") + m_program.log(); } - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (funcs) funcs->glGenTextures(m_textureCount, m_textureIds); } void GlslSurfacePainter::cleanup() { - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (funcs) { funcs->glDeleteTextures(m_textureCount, m_textureIds); @@ -795,8 +791,8 @@ void GlslSurfacePainter::paintImpl(const QPainter *painter, m_program.setAttributeArray("textureCoordArray", textureCoordArray, 2); m_program.setUniformValue("positionMatrix", positionMatrix); - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); - if (funcs) + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); + if (!funcs) return; if (m_textureCount == 3) { diff --git a/src/VideoStreaming/gstqtvideosink/painters/videomaterial.cpp b/src/VideoStreaming/gstqtvideosink/painters/videomaterial.cpp index ef360cace..67daa4fc4 100644 --- a/src/VideoStreaming/gstqtvideosink/painters/videomaterial.cpp +++ b/src/VideoStreaming/gstqtvideosink/painters/videomaterial.cpp @@ -26,9 +26,10 @@ #include #include -#include #include +#include "glutils.h" + static const char * const qtvideosink_glsl_vertexShader = "uniform highp mat4 qt_Matrix; \n" "attribute highp vec4 qt_VertexPosition; \n" @@ -257,7 +258,7 @@ VideoMaterial::~VideoMaterial() { if (!m_textureSize.isEmpty()) { - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (funcs) { funcs->glDeleteTextures(m_textureCount, m_textureIds); @@ -329,7 +330,7 @@ void VideoMaterial::initYuv420PTextureInfo(bool uvSwapped, const QSize &size) void VideoMaterial::init(GstVideoColorMatrix colorMatrixType) { - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (funcs) { funcs->glGenTextures(m_textureCount, m_textureIds); @@ -421,7 +422,7 @@ void VideoMaterial::updateColors(int brightness, int contrast, int hue, int satu void VideoMaterial::bind() { - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (!funcs) return; @@ -455,7 +456,7 @@ void VideoMaterial::bind() void VideoMaterial::bindTexture(int i, const quint8 *data) { - QOpenGLFunctions_2_0 *funcs = QOpenGLContext::currentContext()->versionFunctions(); + QOpenGLFunctionsDef *funcs = getQOpenGLFunctions(); if (!funcs) return; diff --git a/src/VideoStreaming/gstqtvideosink/utils/glutils.h b/src/VideoStreaming/gstqtvideosink/utils/glutils.h new file mode 100644 index 000000000..2ff461d20 --- /dev/null +++ b/src/VideoStreaming/gstqtvideosink/utils/glutils.h @@ -0,0 +1,43 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +/** + * @file + * @brief QGC Video Item + * @author Gus Grubba + */ + +#ifndef GLUTILS_H +#define GLUTILS_H + +#ifdef __android__ +#include +#define getQOpenGLFunctions() QOpenGLContext::currentContext()->functions() +#define QOpenGLFunctionsDef QOpenGLFunctions +#else +#include +#define getQOpenGLFunctions() QOpenGLContext::currentContext()->versionFunctions() +#define QOpenGLFunctionsDef QOpenGLFunctions_2_0 +#endif + +#endif -- 2.22.0