aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/coreapi
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-08-02 21:04:44 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-12 10:46:41 +0200
commit57a70efe4c54bbfc8109933503c45cc43127c6ad (patch)
treee53457212e4abd004e377c5bc9c54047a77c1d17 /src/quick/scenegraph/coreapi
parentf56b68b61c8ae021526c2d433961323b7e41032c (diff)
Support opt-in QSGNode descriptions without breaking binary compat.
This define is quite useful for debugging scene graph internals, but it is disabled by default to conserve memory. For clarity, I renamed the define to QSG_RUNTIME_DESCRIPTION. Change-Id: Ie5ff44d67af38adc65d0d09255d8533dc7a33bff Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/quick/scenegraph/coreapi')
-rw-r--r--src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.cpp91
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.h12
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode_p.h12
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer.cpp2
5 files changed, 70 insertions, 49 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp b/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
index 448ec55a82..a343a81e1a 100644
--- a/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgdefaultrenderer.cpp
@@ -156,13 +156,11 @@ void QSGDefaultRenderer::nodeChanged(QSGNode *node, QSGNode::DirtyState state)
void QSGDefaultRenderer::render()
{
-#if defined (QML_RUNTIME_TESTING)
static bool dumpTree = qApp->arguments().contains(QLatin1String("--dump-tree"));
if (dumpTree) {
printf("\n\n");
QSGNodeDumper::dump(rootNode());
}
-#endif
#ifdef RENDERER_DEBUG
debugTimer.invalidate();
diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp
index 25f8f342c9..a4a47de216 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnode.cpp
@@ -302,6 +302,11 @@ void QSGNode::init()
}
}
#endif
+
+#ifdef QSG_RUNTIME_DESCRIPTION
+ if (d_ptr.isNull())
+ d_ptr.reset(new QSGNodePrivate());
+#endif
}
/*!
@@ -671,7 +676,12 @@ void QSGNode::markDirty(DirtyState bits)
}
}
-
+#ifdef QSG_RUNTIME_DESCRIPTION
+void qsgnode_set_description(QSGNode *node, const QString &description)
+{
+ QSGNodePrivate::setDescription(node, description);
+}
+#endif
/*!
\class QSGBasicGeometryNode
@@ -1422,10 +1432,10 @@ void QSGNodeVisitor::visitChildren(QSGNode *n)
QDebug operator<<(QDebug d, const QSGGeometryNode *n)
{
if (!n) {
- d << "QSGGeometryNode(null)";
+ d << "Geometry(null)";
return d;
}
- d << "QSGGeometryNode(" << hex << (void *) n << dec;
+ d << "GeometryNode(" << hex << (void *) n << dec;
const QSGGeometry *g = n->geometry();
@@ -1440,33 +1450,32 @@ QDebug operator<<(QDebug d, const QSGGeometryNode *n)
default: break;
}
- d << g->vertexCount();
+ d << "#V:" << g->vertexCount() << "#I:" << g->indexCount();
- if (g->attributeCount() > 0 && g->attributes()->type == GL_FLOAT) {
- float x1 = 1e10, x2 = -1e10, y1=1e10, y2=-1e10;
- int stride = g->sizeOfVertex();
- for (int i = 0; i < g->vertexCount(); ++i) {
- float x = ((float *)((char *)const_cast<QSGGeometry *>(g)->vertexData() + i * stride))[0];
- float y = ((float *)((char *)const_cast<QSGGeometry *>(g)->vertexData() + i * stride))[1];
+ if (g->attributeCount() > 0 && g->attributes()->type == GL_FLOAT) {
+ float x1 = 1e10, x2 = -1e10, y1=1e10, y2=-1e10;
+ int stride = g->sizeOfVertex();
+ for (int i = 0; i < g->vertexCount(); ++i) {
+ float x = ((float *)((char *)const_cast<QSGGeometry *>(g)->vertexData() + i * stride))[0];
+ float y = ((float *)((char *)const_cast<QSGGeometry *>(g)->vertexData() + i * stride))[1];
- x1 = qMin(x1, x);
- x2 = qMax(x2, x);
- y1 = qMin(y1, y);
- y2 = qMax(y2, y);
- }
+ x1 = qMin(x1, x);
+ x2 = qMax(x2, x);
+ y1 = qMin(y1, y);
+ y2 = qMax(y2, y);
+ }
- d << "x1=" << x1 << "y1=" << y1 << "x2=" << x2 << "y2=" << y2;
- }
+ d << "x1=" << x1 << "y1=" << y1 << "x2=" << x2 << "y2=" << y2;
+ }
}
- d << "order=" << n->renderOrder();
if (n->material())
- d << "effect=" << n->material() << "type=" << n->material()->type();
+ d << "materialtype=" << n->material()->type();
d << ')';
-#ifdef QML_RUNTIME_TESTING
- d << n->description;
+#ifdef QSG_RUNTIME_DESCRIPTION
+ d << QSGNodePrivate::description(n);
#endif
d << "dirty=" << hex << (int) n->dirtyState() << dec;
return d;
@@ -1475,10 +1484,10 @@ QDebug operator<<(QDebug d, const QSGGeometryNode *n)
QDebug operator<<(QDebug d, const QSGClipNode *n)
{
if (!n) {
- d << "QSGClipNode(null)";
+ d << "ClipNode(null)";
return d;
}
- d << "QSGClipNode(" << hex << (void *) n << dec;
+ d << "ClipNode(" << hex << (void *) n << dec;
if (n->childCount())
d << "children=" << n->childCount();
@@ -1486,8 +1495,8 @@ QDebug operator<<(QDebug d, const QSGClipNode *n)
d << "is rect?" << (n->isRectangular() ? "yes" : "no");
d << ')';
-#ifdef QML_RUNTIME_TESTING
- d << n->description;
+#ifdef QSG_RUNTIME_DESCRIPTION
+ d << QSGNodePrivate::description(n);
#endif
d << "dirty=" << hex << (int) n->dirtyState() << dec << (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
return d;
@@ -1496,11 +1505,11 @@ QDebug operator<<(QDebug d, const QSGClipNode *n)
QDebug operator<<(QDebug d, const QSGTransformNode *n)
{
if (!n) {
- d << "QSGTransformNode(null)";
+ d << "TransformNode(null)";
return d;
}
const QMatrix4x4 m = n->matrix();
- d << "QSGTransformNode(";
+ d << "TransformNode(";
d << hex << (void *) n << dec;
if (m.isIdentity())
d << "identity";
@@ -1508,8 +1517,8 @@ QDebug operator<<(QDebug d, const QSGTransformNode *n)
d << "translate" << m(0, 3) << m(1, 3) << m(2, 3);
else
d << "det=" << n->matrix().determinant();
-#ifdef QML_RUNTIME_TESTING
- d << n->description;
+#ifdef QSG_RUNTIME_DESCRIPTION
+ d << QSGNodePrivate::description(n);
#endif
d << "dirty=" << hex << (int) n->dirtyState() << dec << (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
d << ')';
@@ -1519,16 +1528,16 @@ QDebug operator<<(QDebug d, const QSGTransformNode *n)
QDebug operator<<(QDebug d, const QSGOpacityNode *n)
{
if (!n) {
- d << "QSGOpacityNode(null)";
+ d << "OpacityNode(null)";
return d;
}
- d << "QSGOpacityNode(";
+ d << "OpacityNode(";
d << hex << (void *) n << dec;
d << "opacity=" << n->opacity()
<< "combined=" << n->combinedOpacity()
<< (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
-#ifdef QML_RUNTIME_TESTING
- d << n->description;
+#ifdef QSG_RUNTIME_DESCRIPTION
+ d << QSGNodePrivate::description(n);
#endif
d << "dirty=" << hex << (int) n->dirtyState() << dec;
d << ')';
@@ -1539,13 +1548,13 @@ QDebug operator<<(QDebug d, const QSGOpacityNode *n)
QDebug operator<<(QDebug d, const QSGRootNode *n)
{
if (!n) {
- d << "QSGRootNode(null)";
+ d << "RootNode(null)";
return d;
}
- d << "QSGRootNode" << hex << (void *) n << "dirty=" << (int) n->dirtyState() << dec
+ d << "RootNode" << hex << (void *) n << "dirty=" << (int) n->dirtyState() << dec
<< (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
-#ifdef QML_RUNTIME_TESTING
- d << n->description;
+#ifdef QSG_RUNTIME_DESCRIPTION
+ d << QSGNodePrivate::description(n);
#endif
d << ')';
return d;
@@ -1556,7 +1565,7 @@ QDebug operator<<(QDebug d, const QSGRootNode *n)
QDebug operator<<(QDebug d, const QSGNode *n)
{
if (!n) {
- d << "QSGNode(null)";
+ d << "Node(null)";
return d;
}
switch (n->type()) {
@@ -1576,12 +1585,12 @@ QDebug operator<<(QDebug d, const QSGNode *n)
d << static_cast<const QSGOpacityNode *>(n);
break;
default:
- d << "QSGNode(" << hex << (void *) n << dec
+ d << "Node(" << hex << (void *) n << dec
<< "dirty=" << hex << (int) n->dirtyState()
<< "flags=" << (int) n->flags() << dec
<< (n->isSubtreeBlocked() ? "*BLOCKED*" : "");
-#ifdef QML_RUNTIME_TESTING
- d << n->description;
+#ifdef QSG_RUNTIME_DESCRIPTION
+ d << QSGNodePrivate::description(n);
#endif
d << ')';
break;
diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h
index d83e6bcc81..26af56f3d0 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.h
+++ b/src/quick/scenegraph/coreapi/qsgnode.h
@@ -49,7 +49,7 @@
QT_BEGIN_NAMESPACE
-//#define QML_RUNTIME_TESTING
+// #define QSG_RUNTIME_DESCRIPTION
class QSGRenderer;
@@ -146,10 +146,6 @@ public:
virtual void preprocess() { }
-#ifdef QML_RUNTIME_TESTING
- QString description;
-#endif
-
protected:
QSGNode(NodeType type);
QSGNode(QSGNodePrivate &dd, NodeType type);
@@ -172,9 +168,15 @@ private:
DirtyState m_dirtyState;
protected:
+ friend class QSGNodePrivate;
+
QScopedPointer<QSGNodePrivate> d_ptr;
};
+#ifdef QSG_RUNTIME_DESCRIPTION
+void qsgnode_set_description(QSGNode *node, const QString &description);
+#endif
+
class Q_QUICK_EXPORT QSGBasicGeometryNode : public QSGNode
{
public:
diff --git a/src/quick/scenegraph/coreapi/qsgnode_p.h b/src/quick/scenegraph/coreapi/qsgnode_p.h
index b0d8088af2..0b9bc67d1e 100644
--- a/src/quick/scenegraph/coreapi/qsgnode_p.h
+++ b/src/quick/scenegraph/coreapi/qsgnode_p.h
@@ -44,6 +44,8 @@
#include <qglobal.h>
+#include "qsgnode.h"
+
QT_BEGIN_NAMESPACE
class QSGNodePrivate
@@ -51,6 +53,16 @@ class QSGNodePrivate
public:
QSGNodePrivate() {}
virtual ~QSGNodePrivate() {}
+
+#ifdef QSG_RUNTIME_DESCRIPTION
+ static void setDescription(QSGNode *node, const QString &description) {
+ node->d_ptr->descr= description;
+ }
+ static QString description(const QSGNode *node) {
+ return node->d_ptr->descr;
+ }
+ QString descr;
+#endif
};
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
index 805cfaad0d..8412af13d9 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
@@ -762,7 +762,7 @@ void QSGNodeDumper::dump(QSGNode *n)
void QSGNodeDumper::visitNode(QSGNode *n)
{
- qDebug() << QString(m_indent * 2, QLatin1Char(' ')) << n;
+ qDebug() << QByteArray(m_indent * 2, ' ').constData() << n;
QSGNodeVisitor::visitNode(n);
}