diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-05-23 13:08:02 +1000 |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2011-05-23 13:08:02 +1000 |
commit | 2c5df92e860f8fba494b62ce6ee619766f004490 (patch) | |
tree | 44f12150baa11c88c2c2c0822307e5726f311ff2 /src | |
parent | 2e0b25c49bf0e0a485360654ce6d51d38607c97b (diff) | |
parent | 5695c61b11618b163a326afaa2f1b0bb4854339c (diff) |
Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qtdeclarative-staging into qtquick2
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/items/qsgimage.cpp | 7 | ||||
-rw-r--r-- | src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp | 63 | ||||
-rw-r--r-- | src/declarative/scenegraph/coreapi/qsgdefaultrenderer_p.h | 10 | ||||
-rw-r--r-- | src/declarative/scenegraph/coreapi/qsgnode.cpp | 33 | ||||
-rw-r--r-- | src/declarative/scenegraph/coreapi/qsgnode.h | 34 | ||||
-rw-r--r-- | src/declarative/scenegraph/util/qsgsimpletexturenode.cpp | 2 | ||||
-rw-r--r-- | src/qmltest/features/qmltestcase.prf | 25 |
7 files changed, 89 insertions, 85 deletions
diff --git a/src/declarative/items/qsgimage.cpp b/src/declarative/items/qsgimage.cpp index d280ef08a1..c77f7a47db 100644 --- a/src/declarative/items/qsgimage.cpp +++ b/src/declarative/items/qsgimage.cpp @@ -191,7 +191,6 @@ QSGTexture *QSGImage::texture() const QSGNode *QSGImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { Q_D(QSGImage); - //XXX Support mirror property if (!d->pix.texture() || width() <= 0 || height() <= 0) { delete oldNode; @@ -273,6 +272,12 @@ QSGNode *QSGImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) sourceRect.width() / d->pix.width(), sourceRect.height() / d->pix.height()); + if (d->mirror) { + qreal oldLeft = nsrect.left(); + nsrect.setLeft(nsrect.right()); + nsrect.setRight(oldLeft); + } + node->setHorizontalWrapMode(hWrap); node->setVerticalWrapMode(vWrap); node->setFiltering(d->smooth ? QSGTexture::Linear : QSGTexture::Nearest); diff --git a/src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp b/src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp index 56808436a2..e2bd8f6134 100644 --- a/src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp +++ b/src/declarative/scenegraph/coreapi/qsgdefaultrenderer.cpp @@ -161,6 +161,9 @@ T Heap<T, prealloc>::pop() QMLRenderer::QMLRenderer(QSGContext *context) : QSGRenderer(context) + , m_opaqueNodes(64) + , m_transparentNodes(64) + , m_tempNodes(64) , m_rebuild_lists(false) , m_needs_sorting(false) , m_sort_front_to_back(false) @@ -247,8 +250,8 @@ void QMLRenderer::render() m_currentMatrix = 0; if (m_rebuild_lists) { - m_opaqueNodes.clear(); - m_transparentNodes.clear(); + m_opaqueNodes.reset(); + m_transparentNodes.reset(); m_currentRenderOrder = 1; buildLists(rootNode()); m_rebuild_lists = false; @@ -260,10 +263,12 @@ void QMLRenderer::render() if (m_needs_sorting) { - qSort(m_opaqueNodes.begin(), m_opaqueNodes.end(), - m_sort_front_to_back - ? nodeLessThanWithRenderOrder - : nodeLessThan); + if (!m_opaqueNodes.isEmpty()) { + qSort(&m_opaqueNodes.first(), &m_opaqueNodes.first() + m_opaqueNodes.size(), + m_sort_front_to_back + ? nodeLessThanWithRenderOrder + : nodeLessThan); + } m_needs_sorting = false; } @@ -370,10 +375,10 @@ void QMLRenderer::buildLists(QSGNode *node) if ((m->flags() & QSGMaterial::Blending) || opacity < 1) { #endif geomNode->setRenderOrder(m_currentRenderOrder - 1); - m_transparentNodes.append(geomNode); + m_transparentNodes.add(geomNode); } else { geomNode->setRenderOrder(m_currentRenderOrder); - m_opaqueNodes.append(geomNode); + m_opaqueNodes.add(geomNode); m_currentRenderOrder += 2; } } @@ -398,37 +403,39 @@ void QMLRenderer::buildLists(QSGNode *node) endIndices[i] = m_transparentNodes.size(); } - Heap<Foo, 16> heap; - m_tempNodes.clear(); int childNodeCount = m_transparentNodes.size() - baseCount; - while (childNodeCount) { - for (int i = 0; i < count; ++i) { - if (beginIndices[i] != endIndices[i]) - heap.insert(Foo(i, m_transparentNodes.at(beginIndices[i]++))); - } - while (!heap.isEmpty()) { - Foo foo = heap.pop(); - m_tempNodes.append(foo.second); - --childNodeCount; - int i = foo.first; - if (beginIndices[i] != endIndices[i] && !nodeLessThan(m_transparentNodes.at(beginIndices[i]), foo.second)) - heap.insert(Foo(i, m_transparentNodes.at(beginIndices[i]++))); + if (childNodeCount) { + Heap<Foo, 16> heap; + m_tempNodes.reset(); + m_tempNodes.reserve(childNodeCount); + while (childNodeCount) { + for (int i = 0; i < count; ++i) { + if (beginIndices[i] != endIndices[i]) + heap.insert(Foo(i, m_transparentNodes.at(beginIndices[i]++))); + } + while (!heap.isEmpty()) { + Foo foo = heap.pop(); + m_tempNodes.add(foo.second); + --childNodeCount; + int i = foo.first; + if (beginIndices[i] != endIndices[i] && !nodeLessThan(m_transparentNodes.at(beginIndices[i]), foo.second)) + heap.insert(Foo(i, m_transparentNodes.at(beginIndices[i]++))); + } } - } - Q_ASSERT(m_tempNodes.size() == m_transparentNodes.size() - baseCount); + Q_ASSERT(m_tempNodes.size() == m_transparentNodes.size() - baseCount); - m_transparentNodes.resize(baseCount); - m_transparentNodes << m_tempNodes; + qMemCopy(&m_transparentNodes.at(baseCount), &m_tempNodes.at(0), m_tempNodes.size() * sizeof(QSGGeometryNode *)); + } } else { for (int i = 0; i < count; ++i) buildLists(node->childAtIndex(i)); } } -void QMLRenderer::renderNodes(const QVector<QSGGeometryNode *> &list) +void QMLRenderer::renderNodes(const QDataBuffer<QSGGeometryNode *> &list) { const float scale = 1.0f / m_currentRenderOrder; - int count = list.count(); + int count = list.size(); int currentRenderOrder = 0x80000000; //int clipChangeCount = 0; diff --git a/src/declarative/scenegraph/coreapi/qsgdefaultrenderer_p.h b/src/declarative/scenegraph/coreapi/qsgdefaultrenderer_p.h index 805388a06f..ca1f5592cf 100644 --- a/src/declarative/scenegraph/coreapi/qsgdefaultrenderer_p.h +++ b/src/declarative/scenegraph/coreapi/qsgdefaultrenderer_p.h @@ -44,6 +44,8 @@ #include "qsgrenderer_p.h" +#include <QtGui/private/qdatabuffer_p.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -65,16 +67,16 @@ public: private: void buildLists(QSGNode *node); - void renderNodes(const QVector <QSGGeometryNode *> &list); + void renderNodes(const QDataBuffer<QSGGeometryNode *> &list); const QSGClipNode *m_currentClip; QSGMaterial *m_currentMaterial; QSGMaterialShader *m_currentProgram; const QMatrix4x4 *m_currentMatrix; QMatrix4x4 m_renderOrderMatrix; - QVector<QSGGeometryNode *> m_opaqueNodes; - QVector<QSGGeometryNode *> m_transparentNodes; - QVector<QSGGeometryNode *> m_tempNodes; + QDataBuffer<QSGGeometryNode *> m_opaqueNodes; + QDataBuffer<QSGGeometryNode *> m_transparentNodes; + QDataBuffer<QSGGeometryNode *> m_tempNodes; bool m_rebuild_lists; bool m_needs_sorting; diff --git a/src/declarative/scenegraph/coreapi/qsgnode.cpp b/src/declarative/scenegraph/coreapi/qsgnode.cpp index 7e19339edc..3472c933d7 100644 --- a/src/declarative/scenegraph/coreapi/qsgnode.cpp +++ b/src/declarative/scenegraph/coreapi/qsgnode.cpp @@ -83,9 +83,24 @@ static void qt_print_node_count() QSGNode::QSGNode() : m_parent(0) + , m_type(BasicNodeType) , m_nodeFlags(OwnedByParent) , m_flags(0) { + init(); +} + +QSGNode::QSGNode(NodeType type) + : m_parent(0) + , m_type(type) + , m_nodeFlags(OwnedByParent) + , m_flags(0) +{ + init(); +} + +void QSGNode::init() +{ #ifndef QT_NO_DEBUG ++qt_node_count; static bool atexit_registered = false; @@ -94,7 +109,6 @@ QSGNode::QSGNode() atexit_registered = true; } #endif - } QSGNode::~QSGNode() @@ -369,8 +383,9 @@ void QSGNode::markDirty(DirtyFlags flags) /*! Creates a new basic geometry node. */ -QSGBasicGeometryNode::QSGBasicGeometryNode() - : m_geometry(0) +QSGBasicGeometryNode::QSGBasicGeometryNode(NodeType type) + : QSGNode(type) + , m_geometry(0) , m_matrix(0) , m_clip_list(0) { @@ -443,7 +458,8 @@ void QSGBasicGeometryNode::setGeometry(QSGGeometry *geometry) */ QSGGeometryNode::QSGGeometryNode() - : m_render_order(0) + : QSGBasicGeometryNode(GeometryNodeType) + , m_render_order(0) , m_material(0) , m_opaque_material(0) , m_opacity(1) @@ -608,6 +624,7 @@ void QSGGeometryNode::setInheritedOpacity(qreal opacity) */ QSGClipNode::QSGClipNode() + : QSGBasicGeometryNode(ClipNodeType) { } @@ -686,6 +703,7 @@ void QSGClipNode::setClipRect(const QRectF &rect) */ QSGTransformNode::QSGTransformNode() + : QSGNode(TransformNodeType) { } @@ -754,6 +772,10 @@ void QSGTransformNode::setCombinedMatrix(const QMatrix4x4 &matrix) Creates a new root node. */ +QSGRootNode::QSGRootNode() + : QSGNode(RootNodeType) +{ +} /*! @@ -812,7 +834,8 @@ void QSGRootNode::notifyNodeChange(QSGNode *node, DirtyFlags flags) The default opacity of nodes is 1. */ QSGOpacityNode::QSGOpacityNode() - : m_opacity(1) + : QSGNode(OpacityNodeType) + , m_opacity(1) , m_combined_opacity(1) { } diff --git a/src/declarative/scenegraph/coreapi/qsgnode.h b/src/declarative/scenegraph/coreapi/qsgnode.h index a905696218..a391b55bc5 100644 --- a/src/declarative/scenegraph/coreapi/qsgnode.h +++ b/src/declarative/scenegraph/coreapi/qsgnode.h @@ -126,7 +126,7 @@ public: int childCount() const { return m_children.size(); } QSGNode *childAtIndex(int i) const { return m_children.at(i); } - virtual NodeType type() const { return BasicNodeType; } + inline NodeType type() const { return m_type; } void clearDirty() { m_flags = 0; } void markDirty(DirtyFlags flags); @@ -145,22 +145,21 @@ public: #endif protected: + QSGNode(NodeType type); + // When a node is destroyed, it will detach from the scene graph and the renderer will be // notified about the change. If the node is detached in the base node's destructor, the - // renderer can't check what type the node originally was because the node's type() method is - // virtual and will return the base node type. The renderer might therefore react incorrectly - // to the change. There are a few of ways I can think of to solve the problem: - // - The renderer must take into account that the notify method might be called from a node's - // destructor. - // - The node can have a type property that is set in the constructor. - // - All the node destructors must call a common destroy method. - // I choose the third option since that will allow the renderer to treat the nodes as their - // proper types. + // renderer can't safely cast the node to its original type, since at this point it has been + // partly destroyed already. To solve this problem, all the node destructors must call a common + // destroy method. void destroy(); private: + void init(); + QSGNode *m_parent; + NodeType m_type; QList<QSGNode *> m_children; Flags m_nodeFlags; @@ -183,7 +182,6 @@ public: // void setUsagePattern(UsagePattern pattern); // UsagePattern usagePattern() const { return m_pattern; } - QSGBasicGeometryNode(); ~QSGBasicGeometryNode(); void setGeometry(QSGGeometry *geometry); @@ -193,6 +191,9 @@ public: const QMatrix4x4 *matrix() const { return m_matrix; } const QSGClipNode *clipList() const { return m_clip_list; } +protected: + QSGBasicGeometryNode(NodeType type); + private: friend class QSGNodeUpdater; QSGGeometry *m_geometry; @@ -222,8 +223,6 @@ public: QSGMaterial *activeMaterial() const; - virtual NodeType type() const { return GeometryNodeType; } - void setRenderOrder(int order); int renderOrder() const { return m_render_order; } @@ -246,8 +245,6 @@ public: QSGClipNode(); ~QSGClipNode(); - virtual NodeType type() const { return ClipNodeType; } - void setIsRectangular(bool rectHint); bool isRectangular() const { return m_is_rectangular; } @@ -268,8 +265,6 @@ public: QSGTransformNode(); ~QSGTransformNode(); - virtual NodeType type() const { return TransformNodeType; } - void setMatrix(const QMatrix4x4 &matrix); const QMatrix4x4 &matrix() const { return m_matrix; } @@ -285,8 +280,8 @@ private: class Q_DECLARATIVE_EXPORT QSGRootNode : public QSGNode { public: + QSGRootNode(); ~QSGRootNode(); - NodeType type() const { return RootNodeType; } private: void notifyNodeChange(QSGNode *node, DirtyFlags flags); @@ -311,11 +306,8 @@ public: void setCombinedOpacity(qreal opacity); qreal combinedOpacity() const { return m_combined_opacity; } - virtual QSGNode::NodeType type() const { return OpacityNodeType; } - bool isSubtreeBlocked() const; - private: qreal m_opacity; qreal m_combined_opacity; diff --git a/src/declarative/scenegraph/util/qsgsimpletexturenode.cpp b/src/declarative/scenegraph/util/qsgsimpletexturenode.cpp index 3438d16a7a..a3c96dcd2b 100644 --- a/src/declarative/scenegraph/util/qsgsimpletexturenode.cpp +++ b/src/declarative/scenegraph/util/qsgsimpletexturenode.cpp @@ -52,7 +52,7 @@ static void qsgsimpletexturenode_update(QSGGeometry *g, return; QSize ts = texture->textureSize(); - QRectF sourceRect(0, ts.height(), ts.width(), -ts.height()); + QRectF sourceRect(0, 0, ts.width(), ts.height()); QSGGeometry::updateTexturedRectGeometry(g, rect, texture->convertToNormalizedSourceRect(sourceRect)); } diff --git a/src/qmltest/features/qmltestcase.prf b/src/qmltest/features/qmltestcase.prf deleted file mode 100644 index a3d66e659e..0000000000 --- a/src/qmltest/features/qmltestcase.prf +++ /dev/null @@ -1,25 +0,0 @@ -CONFIG += testcase - -!symbian { - INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtQuickTest -} else { - load(data_caging_paths) - - INCLUDEPATH+=$$MW_LAYER_PUBLIC_EXPORT_PATH(QtQuickTest) -} - -QT += declarative - -win32:CONFIG(debug, debug|release) { - LIBS += -lQtQuickTest$${QT_LIBINFIX}d -} else { - LIBS += -lQtQuickTest$${QT_LIBINFIX} -} - -# If the .pro file specified an IMPORTPATH, then add that to -# the command-line when the test is run. -!isEmpty(IMPORTPATH) { - load(testcase) - for(import, IMPORTPATH): check.commands += -import \"$$import\" -} -DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$OUT_PWD\\\"\" |