Enable support for OpenVG

This commit re-enables support for OpenVG in Qt, but not in the
same way as in Qt 4.8.  The first part is about adding a test
and using the new configure system to enable OpenVG.

There is still support code in Qt for setting up EGL to provide a
surface and context for rendering with the OpenVG API, this commit
enables a path to do so.

Normally to get access to an EGLContext from a QWindow you do so via
QOpenGLContext, but in setups without OpenGL but with EGL and OpenVG
this doesn't make sense (there would be no QOpenGLContext). So the
intended way is to use a QWindow to get an EGLSurface, then create
an EGLContext directly (without going through QPA).

Change-Id: I0f75aadbaa3cd006deb7e6fd12cfbb574870fba4
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Andy Nichols 2016-09-16 11:26:15 +02:00
parent 1b905b3fa4
commit dafd0955c6
10 changed files with 100 additions and 33 deletions

View File

@ -0,0 +1,49 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <VG/openvg.h>
int main(int, char **)
{
VGint i;
i = 2;
vgFlush();
return 0;
}

View File

@ -0,0 +1,3 @@
SOURCES += openvg.cpp
CONFIG -= qt

View File

@ -1,15 +0,0 @@
!isEmpty(QMAKE_INCDIR_OPENVG): INCLUDEPATH += $$QMAKE_INCDIR_OPENVG
!isEmpty(QMAKE_LIBDIR_OPENVG): QMAKE_LIBDIR += -L$$QMAKE_LIBDIR_OPENVG
!isEmpty(QMAKE_LIBS_OPENVG): LIBS += $$QMAKE_LIBS_OPENVG
qtConfig(egl) {
!isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL
!isEmpty(QMAKE_LIBDIR_EGL): LIBS += -L$$QMAKE_LIBDIR_EGL
!isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL
}
qtConfig(openvg_on_opengl) {
!isEmpty(QMAKE_INCDIR_OPENGL): INCLUDEPATH += $$QMAKE_INCDIR_OPENGL
!isEmpty(QMAKE_LIBDIR_OPENGL): QMAKE_LIBDIR += -L$$QMAKE_LIBDIR_OPENGL
!isEmpty(QMAKE_LIBS_OPENGL): LIBS += $$QMAKE_LIBS_OPENGL
}

View File

@ -1,7 +0,0 @@
QMAKE_LIBS += $$QMAKE_LIBS_OPENVG
QMAKE_LFLAGS += $$QMAKE_LFLAGS_OPENVG
qtConfig(openvg_on_opengl) {
QMAKE_LIBS += $$QMAKE_LIBS_OPENGL
QMAKE_LFLAGS += $$QMAKE_LFLAGS_OPENGL
}

View File

@ -32,6 +32,7 @@
"opengl": { "type": "optionalString", "values": [ "no", "yes", "desktop", "es2", "dynamic" ] },
"opengl-es-2": { "type": "void", "name": "opengl", "value": "es2" },
"opengles3": "boolean",
"openvg": "boolean",
"qpa": { "type": "string", "name": "qpa_default_platform" },
"qpa-platform-guard": "boolean",
"sm": { "type": "boolean", "name": "sessionmanager" },
@ -193,6 +194,14 @@
{ "type": "makeSpec", "spec": "OPENGL_ES2" }
]
},
"openvg": {
"label": "OpenVG",
"test": "unix/openvg",
"sources": [
{ "type": "pkgConfig", "args": "vg" },
{ "type": "makeSpec", "spec": "OPENVG" }
]
},
"tslib": {
"label": "tslib",
"test": "unix/tslib",
@ -588,9 +597,14 @@
"condition": "features.opengl-desktop || features.opengl-dynamic || features.opengles2",
"output": [ "publicFeature", "feature" ]
},
"openvg": {
"label": "OpenVG",
"condition": "libs.openvg",
"output": [ "publicFeature" ]
},
"egl": {
"label": "EGL",
"condition": "features.opengl && (features.angle || libs.egl)",
"condition": "(features.opengl || features.openvg) && (features.angle || libs.egl)",
"output": [ "privateFeature", "feature" ]
},
"egl_x11": {
@ -1030,6 +1044,8 @@ QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your pla
"gif", "ico", "jpeg", "system-jpeg", "png", "system-png"
]
},
"egl",
"openvg",
{
"section": "OpenGL",
"entries": [
@ -1038,7 +1054,6 @@ QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your pla
"args": "angle",
"condition": "config.win32"
},
"egl",
"opengl-desktop",
{
"type": "feature",

View File

@ -76,6 +76,8 @@ QT_BEGIN_NAMESPACE
\value RasterGLSurface The surface can be rendered to using a software rasterizer,
and also supports OpenGL. This surface type is intended for internal Qt use, and
requires the use of private API.
\value OpenVGSurface The surface is an OpenVG compatible surface and can be used
in conjunction with OpenVG contexts.
*/

View File

@ -64,7 +64,8 @@ public:
enum SurfaceType {
RasterSurface,
OpenGLSurface,
RasterGLSurface
RasterGLSurface,
OpenVGSurface,
};
virtual ~QSurface();

View File

@ -100,18 +100,24 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format)
configAttributes.append(EGL_ALPHA_SIZE);
configAttributes.append(alphaSize > 0 ? alphaSize : 0);
configAttributes.append(EGL_DEPTH_SIZE);
configAttributes.append(depthSize > 0 ? depthSize : 0);
configAttributes.append(EGL_STENCIL_SIZE);
configAttributes.append(stencilSize > 0 ? stencilSize : 0);
configAttributes.append(EGL_SAMPLES);
configAttributes.append(sampleCount > 0 ? sampleCount : 0);
configAttributes.append(EGL_SAMPLE_BUFFERS);
configAttributes.append(sampleCount > 0);
if (format.renderableType() != QSurfaceFormat::OpenVG) {
configAttributes.append(EGL_DEPTH_SIZE);
configAttributes.append(depthSize > 0 ? depthSize : 0);
configAttributes.append(EGL_STENCIL_SIZE);
configAttributes.append(stencilSize > 0 ? stencilSize : 0);
} else {
// OpenVG needs alpha mask for clipping
configAttributes.append(EGL_ALPHA_MASK_SIZE);
configAttributes.append(8);
}
return configAttributes;
}

View File

@ -167,6 +167,13 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont
: EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR);
}
}
// Special Options for OpenVG surfaces
if (m_format.renderableType() == QSurfaceFormat::OpenVG) {
contextAttrs.append(EGL_ALPHA_MASK_SIZE);
contextAttrs.append(8);
}
contextAttrs.append(EGL_NONE);
m_contextAttrs = contextAttrs;

View File

@ -279,7 +279,8 @@ enum ResourceType {
EglConfig,
NativeDisplay,
XlibDisplay,
WaylandDisplay
WaylandDisplay,
EglSurface
};
static int resourceType(const QByteArray &key)
@ -291,7 +292,8 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("eglconfig"),
QByteArrayLiteral("nativedisplay"),
QByteArrayLiteral("display"),
QByteArrayLiteral("server_wl_display")
QByteArrayLiteral("server_wl_display"),
QByteArrayLiteral("eglsurface")
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
@ -353,6 +355,10 @@ void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWi
if (window && window->handle())
result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->eglWindow());
break;
case EglSurface:
if (window && window->handle())
result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->surface());
break;
default:
break;
}