summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-05-22 21:04:18 +0200
committerGunnar Sletta <gunnar.sletta@digia.com>2013-05-23 10:20:48 +0200
commit4081f6d232fcf7423306b375b6d75449b362f0d1 (patch)
treed807094fd06d624c03b089b70490e1912a4b36cf
parenta0d9130228916a47b404653365fe0c0487be6966 (diff)
Add msaa option to use multisampling instead of normal antialiasing
Change-Id: Ie4b17b971fe83daf5eaa5ceb1741710e0c27aa33 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
-rw-r--r--customcontext/context.cpp42
-rw-r--r--customcontext/context.h11
-rw-r--r--customcontext/customcontext.pro7
3 files changed, 59 insertions, 1 deletions
diff --git a/customcontext/context.cpp b/customcontext/context.cpp
index de9df5b..3c9db42 100644
--- a/customcontext/context.cpp
+++ b/customcontext/context.cpp
@@ -76,6 +76,11 @@
#include "nonpreservedtexture.h"
#endif
+#ifdef CUSTOMCONTEXT_MSAA
+#include <private/qsgdefaultimagenode_p.h>
+#include <private/qsgdefaultrectanglenode_p.h>
+#endif
+
namespace CustomContext
@@ -88,7 +93,7 @@ Context::Context(QObject *parent)
{
m_useMultisampling = qgetenv("CUSTOMCONTEXT_NO_MULTISAMPLE").isEmpty();
if (m_useMultisampling) {
- m_sampleCount= 4;
+ m_sampleCount= 16;
QByteArray overrideSamples = qgetenv("CUSTOMCONTEXT_MULTISAMPLE_COUNT");
bool ok;
int override = overrideSamples.toInt(&ok);
@@ -136,6 +141,12 @@ Context::Context(QObject *parent)
m_nonPreservedTexture = qgetenv("CUSTOMCONTEXT_NO_NONPRESERVEDTEXTURE").isEmpty();
#endif
+#ifdef CUSTOMCONTEXT_MSAA
+ m_defaultImageNodes = qEnvironmentVariableIsSet("CUSTOMCONTEXT_DEFAULT_IMAGENODES");
+ m_defaultRectangleNodes = qEnvironmentVariableIsSet("CUSTOMCONTEXT_DEFAULT_RECTANGLENODES");
+#endif
+
+
#ifdef CUSTOMCONTEXT_DEBUG
@@ -176,6 +187,11 @@ Context::Context(QObject *parent)
qDebug(" - distance fields disabled");
#endif
+#ifdef CUSTOMCONTEXT_MSAA
+ qDebug(" - msaa rectangles: %s", !m_defaultRectangleNodes ? "yes" : "no");
+ qDebug(" - msaa images: %s", !m_defaultImageNodes ? "yes" : "no");
+#endif
+
#endif
}
@@ -403,6 +419,30 @@ QSGGlyphNode *Context::createGlyphNode()
}
#endif
+#ifdef CUSTOMCONTEXT_MSAA
+
+class MSAAImageNode : public QSGDefaultImageNode {
+public:
+ void setAntialiasing(bool) { }
+};
+
+class MSAARectangleNode : public QSGDefaultRectangleNode {
+public:
+ void setAntialiasing(bool) { }
+};
+
+QSGImageNode *Context::createImageNode()
+{
+ return m_defaultImageNodes ? QSGContext::createImageNode() : new MSAAImageNode();
+}
+
+QSGRectangleNode *Context::createRectangleNode()
+{
+ return m_defaultRectangleNodes ? QSGContext::createRectangleNode() : new MSAARectangleNode();
+}
+#endif
+
+
} // namespace
diff --git a/customcontext/context.h b/customcontext/context.h
index 6e4158e..41805f6 100644
--- a/customcontext/context.h
+++ b/customcontext/context.h
@@ -80,6 +80,11 @@ public:
QSGTexture *createTexture(const QImage &image) const;
QQuickTextureFactory *createTextureFactory(const QImage &image);
+#ifdef CUSTOMCONTEXT_MSAA
+ QSGImageNode *createImageNode();
+ QSGRectangleNode *createRectangleNode();
+#endif
+
#ifdef CUSTOMCONTEXT_NO_DFGLYPHS
QSGGlyphNode *createGlyphNode();
#endif
@@ -132,6 +137,12 @@ private:
friend class NonPreservedTextureFactory;
#endif
+#ifdef CUSTOMCONTEXT_MSAA
+ bool m_defaultRectangleNodes;
+ bool m_defaultImageNodes;
+#endif
+
+
};
diff --git a/customcontext/customcontext.pro b/customcontext/customcontext.pro
index 26392b9..1d4a467 100644
--- a/customcontext/customcontext.pro
+++ b/customcontext/customcontext.pro
@@ -139,6 +139,13 @@ nodfglyphs:{
message("nodfglyphs ...............: no")
}
+msaa:{
+ message("msaa .....................: yes")
+ DEFINES += CUSTOMCONTEXT_MSAA
+} else {
+ message("msaa .....................: no")
+}
+
message("");