diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-01-11 11:42:14 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-01-18 14:48:07 +0000 |
commit | 8c144298439a6537adc0d67ca03382a305484deb (patch) | |
tree | ea9d3cba25fc31aa718b883e75f23785acde94e7 /src/gui/opengl/qopenglpaintengine.cpp | |
parent | eba886c32ff5db1a0a737d33447a1f5c97919d57 (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/opengl/qopenglpaintengine.cpp')
-rw-r--r-- | src/gui/opengl/qopenglpaintengine.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 5c05a05d80..8db806f1d5 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -761,6 +761,8 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path) if (matrixDirty) updateMatrix(); + const bool supportsElementIndexUint = funcs.hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint); + const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); // Check to see if there's any hints @@ -881,7 +883,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path) // Flatten the path at the current scale factor and fill it into the cache struct. if (updateCache) { - QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); + QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale), 1, supportsElementIndexUint); cache->vertexCount = polys.vertices.size() / 2; cache->indexCount = polys.indices.size(); cache->primitiveType = GL_TRIANGLES; @@ -950,7 +952,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path) && (bbox.top() > -0x8000 * inverseScale) && (bbox.bottom() < 0x8000 * inverseScale); if (withinLimits) { - QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); + QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale), 1, supportsElementIndexUint); QVarLengthArray<float> vertices(polys.vertices.size()); for (int i = 0; i < polys.vertices.size(); ++i) |