Fix: bad-looking scaled rendering of painterpath in OpenGL paint engine

For performance, the triangulation of a painter path is stored for
reuse. Re-triangulation was only done if the path was to be painted at
a significantly different scale AND it contained a curve (bezier)
element. But also the triangulation of a path with only straight lines
can lose precision if rendered at a small scale, and so look bad when
used at a higher scale factor.

Fix by removing the mentioned curve element condition.

Task-number: QTBUG-68873
Change-Id: Id3492514e9382a5828377b7bafea8cfac7b850a6
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Eirik Aavitsland 2018-06-22 15:56:15 +02:00
parent 80a550dd79
commit e5b3db841d

View File

@ -797,8 +797,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
if (data) { if (data) {
cache = (QOpenGL2PEVectorPathCache *) data->data; cache = (QOpenGL2PEVectorPathCache *) data->data;
// Check if scale factor is exceeded for curved paths and generate curves if so... // Check if scale factor is exceeded and regenerate if so...
if (path.isCurved()) {
qreal scaleFactor = cache->iscale / inverseScale; qreal scaleFactor = cache->iscale / inverseScale;
if (scaleFactor < 0.5 || scaleFactor > 2.0) { if (scaleFactor < 0.5 || scaleFactor > 2.0) {
#ifdef QT_OPENGL_CACHE_AS_VBOS #ifdef QT_OPENGL_CACHE_AS_VBOS
@ -811,7 +810,6 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
#endif #endif
updateCache = true; updateCache = true;
} }
}
} else { } else {
cache = new QOpenGL2PEVectorPathCache; cache = new QOpenGL2PEVectorPathCache;
data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath); data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath);
@ -879,8 +877,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
if (data) { if (data) {
cache = (QOpenGL2PEVectorPathCache *) data->data; cache = (QOpenGL2PEVectorPathCache *) data->data;
// Check if scale factor is exceeded for curved paths and generate curves if so... // Check if scale factor is exceeded and regenerate if so...
if (path.isCurved()) {
qreal scaleFactor = cache->iscale / inverseScale; qreal scaleFactor = cache->iscale / inverseScale;
if (scaleFactor < 0.5 || scaleFactor > 2.0) { if (scaleFactor < 0.5 || scaleFactor > 2.0) {
#ifdef QT_OPENGL_CACHE_AS_VBOS #ifdef QT_OPENGL_CACHE_AS_VBOS
@ -892,7 +889,6 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path)
#endif #endif
updateCache = true; updateCache = true;
} }
}
} else { } else {
cache = new QOpenGL2PEVectorPathCache; cache = new QOpenGL2PEVectorPathCache;
data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath); data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath);