diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-08-30 08:38:24 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-06 10:27:13 +0200 |
commit | bedd2b43782b919ad8646238d43623b539af25cd (patch) | |
tree | 711e20c578790db25d80c335a4a10afe8e3a6647 /src/quick/scenegraph/qsgcontext.cpp | |
parent | 39c8c8b682c1af858cd4bfc0543057da5c9e1e07 (diff) |
Prefer multisample antialiasing when we have a msaa context
Task-number: QTBUG-32699
Change-Id: Id4382c154954cb114af2cc29b075ddab8df9f387
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/quick/scenegraph/qsgcontext.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index 070a8422d0..4c2cb8a877 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -118,6 +118,7 @@ public: , atlasManager(0) , flashMode(qmlFlashMode()) , distanceFieldDisabled(qmlDisableDistanceField()) + , msaa(false) { renderAlpha = qmlTranslucentMode() ? 0.5 : 1; } @@ -141,6 +142,8 @@ public: bool flashMode; float renderAlpha; bool distanceFieldDisabled; + + bool msaa; }; class QSGTextureCleanupEvent : public QEvent @@ -151,6 +154,20 @@ public: QSGTexture *texture; }; +namespace QSGMultisampleAntialiasing { + class ImageNode : public QSGDefaultImageNode { + public: + void setAntialiasing(bool) { } + }; + + + class RectangleNode : public QSGDefaultRectangleNode { + public: + void setAntialiasing(bool) { } + }; +} + + /*! \class QSGContext @@ -275,6 +292,18 @@ void QSGContext::initialize(QOpenGLContext *context) { Q_D(QSGContext); + QByteArray aaType = qgetenv("QSG_ANTIALIASING_METHOD"); + if (aaType == "msaa") { + d->msaa = true; + } else if (aaType == "vertex") { + d->msaa = false; + } else { + if (context->format().samples() > 0) + d->msaa = true; + else + d->msaa = false; + } + // Sanity check the surface format, in case it was overridden by the application QSurfaceFormat requested = defaultSurfaceFormat(); QSurfaceFormat actual = context->format(); @@ -345,7 +374,9 @@ void QSGContext::renderNextFrame(QSGRenderer *renderer, GLuint fboId) */ QSGRectangleNode *QSGContext::createRectangleNode() { - return new QSGDefaultRectangleNode; + Q_D(QSGContext); + return d->msaa ? new QSGMultisampleAntialiasing::RectangleNode + : new QSGDefaultRectangleNode; } /*! @@ -353,7 +384,9 @@ QSGRectangleNode *QSGContext::createRectangleNode() */ QSGImageNode *QSGContext::createImageNode() { - return new QSGDefaultImageNode; + Q_D(QSGContext); + return d->msaa ? new QSGMultisampleAntialiasing::ImageNode + : new QSGDefaultImageNode; } /*! |