diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-09-20 14:31:31 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-09-20 15:02:30 (GMT) |
commit | 89cbb165600de9a557a8a621dc41b93c2a7a2b52 (patch) | |
tree | 6c330d4d1c7b19def2280aebd3011750e4253b8b /src/opengl/gl2paintengineex | |
parent | 6ecb1be99ff951f35d7b391d6ffb033da696ca74 (diff) | |
download | Qt-89cbb165600de9a557a8a621dc41b93c2a7a2b52.zip Qt-89cbb165600de9a557a8a621dc41b93c2a7a2b52.tar.gz Qt-89cbb165600de9a557a8a621dc41b93c2a7a2b52.tar.bz2 |
Fixed painter path drawing on FBO without stencil buffer.
Task-number: QTBUG-13450
Reviewed-by: Samuel
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index aa217f6..2347e66 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -866,6 +866,32 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) if (do_vectorpath_cache) path.makeCacheable(); + if (!device->format().stencil()) { + // If there is no stencil buffer, triangulate the path instead. + + QRectF bbox = path.controlPointRect(); + // If the path doesn't fit within these limits, it is possible that the triangulation will fail. + bool withinLimits = (bbox.left() > -0x8000 * inverseScale) + && (bbox.right() < 0x8000 * inverseScale) + && (bbox.top() > -0x8000 * inverseScale) + && (bbox.bottom() < 0x8000 * inverseScale); + if (withinLimits) { + QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); + + QVarLengthArray<float> vertices(polys.vertices.size()); + for (int i = 0; i < polys.vertices.size(); ++i) + vertices[i] = float(inverseScale * polys.vertices.at(i)); + + prepareForDraw(currentBrush.isOpaque()); + setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertices.constData()); + glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_INT, polys.indices.constData()); + } else { + // We can't handle big, concave painter paths with OpenGL without stencil buffer. + qWarning("Painter path exceeds +/-32767 pixels."); + } + return; + } + // The path is too complicated & needs the stencil technique vertexCoordinateArray.clear(); vertexCoordinateArray.addPath(path, inverseScale, false); |