summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qtriangulator.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2017-01-11 11:42:14 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-01-18 14:48:07 +0000
commit8c144298439a6537adc0d67ca03382a305484deb (patch)
treeea9d3cba25fc31aa718b883e75f23785acde94e7 /src/gui/painting/qtriangulator.cpp
parenteba886c32ff5db1a0a737d33447a1f5c97919d57 (diff)
Remove OpenGL dependency from qTriangulate
The original implementation is only suitable as long as the only client is the GL paint engine which will call the function with the GL context current. In other cases this cannot be ensured. For instance, doing triangulation on the gui thread in a Quick application using the threaded render loop will have to deal with not having a current context on that thread at all. Doing triangulation on worker threads has the same problem as well. In addition, in modern Qt versions a -no-opengl build does not imply no accelerated graphics API. Therefore, drop the ElementIndexUint check from qtriangulator.cpp and leave it up to the caller to tell if uint indices are supported or not. Change-Id: I7491d84981ee22d05c5fde08994dbb3a4e2432e9 Reviewed-by: Gunnar Sletta <gunnar@crimson.no>
Diffstat (limited to 'src/gui/painting/qtriangulator.cpp')
-rw-r--r--src/gui/painting/qtriangulator.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/gui/painting/qtriangulator.cpp b/src/gui/painting/qtriangulator.cpp
index 6604d407f0..6d57eba123 100644
--- a/src/gui/painting/qtriangulator.cpp
+++ b/src/gui/painting/qtriangulator.cpp
@@ -50,10 +50,6 @@
#include <QtCore/qglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qalgorithms.h>
-#ifndef QT_NO_OPENGL
-# include <private/qopenglcontext_p.h>
-# include <private/qopenglextensions_p.h>
-#endif
#include <private/qrbtree_p.h>
QT_BEGIN_NAMESPACE
@@ -2266,23 +2262,12 @@ void QTriangulator<T>::MonotoneToTriangles::decompose()
// qTriangulate //
//============================================================================//
-static bool hasElementIndexUint()
-{
-#ifndef QT_NO_OPENGL
- QOpenGLContext *context = QOpenGLContext::currentContext();
- if (!context)
- return false;
- return static_cast<QOpenGLExtensions *>(context->functions())->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint);
-#else
- return false;
-#endif
-}
-
Q_GUI_EXPORT QTriangleSet qTriangulate(const qreal *polygon,
- int count, uint hint, const QTransform &matrix)
+ int count, uint hint, const QTransform &matrix,
+ bool allowUintIndices)
{
QTriangleSet triangleSet;
- if (hasElementIndexUint()) {
+ if (allowUintIndices) {
QTriangulator<quint32> triangulator;
triangulator.initialize(polygon, count, hint, matrix);
QVertexSet<quint32> vertexSet = triangulator.triangulate();
@@ -2300,10 +2285,13 @@ Q_GUI_EXPORT QTriangleSet qTriangulate(const qreal *polygon,
}
Q_GUI_EXPORT QTriangleSet qTriangulate(const QVectorPath &path,
- const QTransform &matrix, qreal lod)
+ const QTransform &matrix, qreal lod, bool allowUintIndices)
{
QTriangleSet triangleSet;
- if (hasElementIndexUint()) {
+ // For now systems that support 32-bit index values will always get 32-bit
+ // index values. This is not necessary ideal since 16-bit would be enough in
+ // many cases. TODO revisit this at a later point.
+ if (allowUintIndices) {
QTriangulator<quint32> triangulator;
triangulator.initialize(path, matrix, lod);
QVertexSet<quint32> vertexSet = triangulator.triangulate();
@@ -2320,10 +2308,10 @@ Q_GUI_EXPORT QTriangleSet qTriangulate(const QVectorPath &path,
}
QTriangleSet qTriangulate(const QPainterPath &path,
- const QTransform &matrix, qreal lod)
+ const QTransform &matrix, qreal lod, bool allowUintIndices)
{
QTriangleSet triangleSet;
- if (hasElementIndexUint()) {
+ if (allowUintIndices) {
QTriangulator<quint32> triangulator;
triangulator.initialize(path, matrix, lod);
QVertexSet<quint32> vertexSet = triangulator.triangulate();
@@ -2340,10 +2328,10 @@ QTriangleSet qTriangulate(const QPainterPath &path,
}
QPolylineSet qPolyline(const QVectorPath &path,
- const QTransform &matrix, qreal lod)
+ const QTransform &matrix, qreal lod, bool allowUintIndices)
{
QPolylineSet polyLineSet;
- if (hasElementIndexUint()) {
+ if (allowUintIndices) {
QTriangulator<quint32> triangulator;
triangulator.initialize(path, matrix, lod);
QVertexSet<quint32> vertexSet = triangulator.polyline();
@@ -2360,10 +2348,10 @@ QPolylineSet qPolyline(const QVectorPath &path,
}
QPolylineSet qPolyline(const QPainterPath &path,
- const QTransform &matrix, qreal lod)
+ const QTransform &matrix, qreal lod, bool allowUintIndices)
{
QPolylineSet polyLineSet;
- if (hasElementIndexUint()) {
+ if (allowUintIndices) {
QTriangulator<quint32> triangulator;
triangulator.initialize(path, matrix, lod);
QVertexSet<quint32> vertexSet = triangulator.polyline();